diff --git a/src/de/dhbwstuttgart/strucTypes/AS_Abstract.java b/src/de/dhbwstuttgart/strucTypes/AS_Abstract.java index a77627e7..5e7cbc16 100644 --- a/src/de/dhbwstuttgart/strucTypes/AS_Abstract.java +++ b/src/de/dhbwstuttgart/strucTypes/AS_Abstract.java @@ -43,6 +43,25 @@ public class AS_Abstract { } + + + public static AS_Argument find_AS_Argument(FormalParameter f, Method m , List ass ) { + AS_Argument res = null; + + for (AS_Abstract as : ass) { + if ( as.getClass().equals(AS_Argument.class) ) { + AS_Argument asa = (AS_Argument) as; + if (f == asa.fp) { + if (asa.tv_alpha.method == m) { + res = asa; + } + } + } + } + return res; + } + + public static AS_Argument find_AS_Argument_by_Name(String name, List ass ) { // if diff --git a/src/de/dhbwstuttgart/strucTypes/Algo_Type.java b/src/de/dhbwstuttgart/strucTypes/Algo_Type.java index 64a57bc9..9f0aea2c 100644 --- a/src/de/dhbwstuttgart/strucTypes/Algo_Type.java +++ b/src/de/dhbwstuttgart/strucTypes/Algo_Type.java @@ -6,7 +6,9 @@ import java.util.List; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.Field; import de.dhbwstuttgart.syntaxtree.Method; -import de.dhbwstuttgart.syntaxtree.SourceFile; + + + public class Algo_Type { @@ -61,7 +63,7 @@ public class Algo_Type { } // ASS = AssAll vereinigt mit ass_arguments (wird oben erledigt) - //-> assAll.addAll(ass_arguments); + // (Test) Beispielhafte Ausgabe der Assumptions @@ -84,11 +86,7 @@ public class Algo_Type { // Hier ist ein Fehler -> der Contraint bezieht sich auf die Expression } - - - - - + } @@ -121,10 +119,6 @@ public class Algo_Type { - - - - // Gettermethoden public Object getResult_cl_t() { return result_cl_t; diff --git a/src/de/dhbwstuttgart/strucTypes/Algo_TypeExpr.java b/src/de/dhbwstuttgart/strucTypes/Algo_TypeExpr.java index 80bca2ae..64d79bb6 100644 --- a/src/de/dhbwstuttgart/strucTypes/Algo_TypeExpr.java +++ b/src/de/dhbwstuttgart/strucTypes/Algo_TypeExpr.java @@ -3,8 +3,6 @@ package de.dhbwstuttgart.strucTypes; import java.util.ArrayList; import java.util.List; -import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Receiver; - import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.Field; import de.dhbwstuttgart.syntaxtree.Method; @@ -13,339 +11,324 @@ import de.dhbwstuttgart.syntaxtree.statement.Expression; import de.dhbwstuttgart.syntaxtree.statement.FieldVar; import de.dhbwstuttgart.syntaxtree.statement.LocalVar; import de.dhbwstuttgart.syntaxtree.statement.MethodCall; +import de.dhbwstuttgart.syntaxtree.statement.Receiver; import de.dhbwstuttgart.syntaxtree.statement.Return; import de.dhbwstuttgart.syntaxtree.statement.Statement; public class Algo_TypeExpr { - - - + /* * * Hier sind die Ergebnisse * * - */ - // Ergebnisse: Expression Typed und Constraint-Set - List res_constriant_set; - //TODO Hier muss noch ein passendes Datenformat gefunden werden - String res_expression_typed; - - - - + */ + // Ergebnisse: Expression Typed und Constraint-Set + List res_constriant_set; + // TODO Hier muss noch ein passendes Datenformat gefunden werden + String res_expression_typed; + public Algo_TypeExpr() { - + } - - - - + // übergabe der assumptions und der Statments der Methode - public Algo_TypeExpr(List ass , List statements ) { - - this.res_constriant_set = new ArrayList(); - res_expression_typed = ""; - - - + public Algo_TypeExpr(List ass, List statements) { + + this.res_constriant_set = new ArrayList(); + res_expression_typed = ""; + // Methode enthält kein Statement - if (statements.size() == 0 ) { + if (statements.size() == 0) { System.out.println("Not Implemmented"); } - - - + // Methode enthält nur ein Return Statement das ein feld zurückgibt if (statements.size() == 1) { - if (statements.get(0).getClass().equals(Return.class)) { - Return exp_rt = (Return) statements.get(0); - if (exp_rt.get_Expression().getClass().equals(LocalVar.class )) { + if (statements.get(0).getClass().equals(Return.class)) { + Return exp_rt = (Return) statements.get(0); + if (exp_rt.get_Expression().getClass().equals(LocalVar.class)) { LocalVar lvar = (LocalVar) exp_rt.get_Expression(); - - String feldname = lvar.get_expression(); - + + String feldname = lvar.get_expression(); + for (AS_Abstract as : ass) { if (as.getClass().equals(AS_Argument.class)) { - AS_Argument as_arg = (AS_Argument) as; + AS_Argument as_arg = (AS_Argument) as; if (as_arg.fp.getName().equals(feldname)) { res_expression_typed = feldname + " : " + as_arg.tv_alpha.toString(); - // res_constraint_set - } + // res_constraint_set + } } - } - } + } + } } } - - - // Methode nur ein Return statment das ein feld zurückgibt und eine Methode aufruft - - - //-> Es muss so sein dass ich diese Return Statement beurteilen kann - - - - + + // Methode nur ein Return statment das ein feld zurückgibt und eine + // Methode aufruft + } - - + /* - * Methode generiert Quellcode aus einer Methode - * Letztendlich wird in der Methode der gesamte Datentyp durchwandert und erstellt - * Nach dem selben Schema muss auch die generierung der Constriants erfolgen: - */ - public static String expression2code(List ass , List statements ) { - String res = ""; - - // Leere methode + * Methode generiert Quellcode aus einer Methode Letztendlich wird in der + * Methode der gesamte Datentyp durchwandert und erstellt Nach dem selben + * Schema muss auch die generierung der Constriants erfolgen: + */ + public static String expression2code(List ass, List statements) { + String res = ""; + + // Leere methode if (statements.size() == 0) { - res = "---"; + res = "---"; } - - // Methode mit einer Return Expression + + // Methode mit einer Return Expression if (statements.size() == 1) { if (statements.get(0).getClass() == Return.class) { - Return ret = (Return) statements.get(0); - Statement ret2 = (Statement) ret.get_Expression(); - res = statement2code(ass,ret2); - } - } + Return ret = (Return) statements.get(0); + if (ret.getClass().equals(Statement.class)) { + Statement ret2 = (Statement) ret.get_Expression(); + res = statement2code(ass, ret2); + } else if (ret.getClass().equals(FieldVar.class)) { + + // Neu Implementiert - funktioniert es ?? + Expression ex = (Expression) ret; + FieldVar fvar = (FieldVar) ex; + + String exp_str = fvar.getFieldVarName(); + + // Statement Cast evtl. problematisch + List liste = new ArrayList(); + liste.add((Statement) fvar.receiver); + String reciever_str = expression2code(ass, liste); + + return reciever_str + "." + exp_str; + + } + } + } return res; } - - - public static String statement2code(List ass , Statement statement) { - + + public static String statement2code(List ass, Statement statement) { + // TODO: Else if - - if ( statement.getClass().equals(LocalVar.class) ) { + + if (statement.getClass().equals(LocalVar.class)) { LocalVar lvar = (LocalVar) statement; - String exp_str = lvar.get_expression(); + String exp_str = lvar.get_expression(); return exp_str; } - - + + // fieldvar muss ausgelagert werden weil es von Expression ableitett if (statement.getClass().equals(FieldVar.class)) { - // FieldVar ist nicht implementiert + // Neu Implementiert - funktioniert es ?? + Expression ex = (Expression) statement; + FieldVar fvar = (FieldVar) ex; + + String exp_str = fvar.getFieldVarName(); + + // Statement Cast evtl. problematisch + String reciever_str = statement2code(ass, (Statement) fvar.receiver); + + return reciever_str + "." + exp_str; } - - + if (statement.getClass().equals(MethodCall.class)) { - MethodCall mtcall = (MethodCall) statement; - Statement receiver = (Statement) mtcall.get_Receiver().get_Expression(); - String str = statement2code(ass,receiver); + MethodCall mtcall = (MethodCall) statement; + Statement receiver = (Statement) mtcall.get_Receiver().get_Expression(); + String str = statement2code(ass, receiver); ArgumentList list = mtcall.get_ArgList(); - String arg_str = ""; + String arg_str = ""; for (Expression exp : list.getArguments()) { // TODO Cast evtl ist falsch - Statement st = (Statement) exp; - arg_str = arg_str + statement2code(ass,st); + Statement st = (Statement) exp; + arg_str = arg_str + statement2code(ass, st); } - // Todo Implementing Types: - return str + "."+ mtcall.get_Name() + "( " + arg_str + " )"; - } - return "Fehler"; + // Todo Implementing Types: + return str + "." + mtcall.get_Name() + "( " + arg_str + " )"; + } + return "Fehler"; } - - - - + public List generate(List ass, List exp) { - + // Methoden enhält keine Statements if (exp.size() == 0) { - this.res_constriant_set = null; - this.res_expression_typed = null; + this.res_constriant_set = null; + this.res_expression_typed = null; } - - + // Methoden enthält ein Return Statement if (exp.size() == 1) { - Statement std = (Statement) exp.get(0); + Statement std = (Statement) exp.get(0); if (std.getClass() == Return.class) { - Return ret = (Return) std; - generate_return(ass, ret); + Return ret = (Return) std; + generate_return(ass, ret); } } - return null; + return null; } - - + public List generate_return(List ass, Return ret) { - + Expression exp = ret.get_Expression(); - - + if (exp.getClass() == LocalVar.class) { LocalVar lvar = (LocalVar) exp; // TODO wie soll ich hier mit der Language umgehen - return new ArrayList(); - } - - - if (exp.getClass() == FieldVar.class) { - + return new ArrayList(); } - - + + if (exp.getClass() == FieldVar.class) { + // Hier kommt der Constraint für die Field Var hinein. + + } + if (exp.getClass() == MethodCall.class) { - MethodCall mt_call = (MethodCall) exp; - + MethodCall mt_call = (MethodCall) exp; + // Constraint - - } - return null; + + } + return null; } - - - public List getRes_constriant_set() { return res_constriant_set; } - - - public String getRes_expression_typed() { return res_expression_typed; } - - - - - - // Neuer Versuch mit neuer herangehensweise um den Typen zu berechnen /* * Es werden die Typen der Methoden berechnet und als String ausgegeben */ public static TV_Abstract get_rt_Type_of(Expression o, List ass) { - + if (o.getClass().equals(LocalVar.class)) { - LocalVar v = (LocalVar) o; - return get_rt_Type_of_LocalVar(v, ass); + LocalVar v = (LocalVar) o; + return get_rt_Type_of_LocalVar(v, ass); + } else if (o.getClass().equals(MethodCall.class)) { + MethodCall m_call = (MethodCall) o; + return get_rt_Type_of_MethodCall(m_call, ass); + } else if (o.getClass().equals(FieldVar.class)) { + FieldVar fvar = (FieldVar) o; + String type_fvar = get_rt_Type_of_FieldVar(fvar, ass); + return new TV_Dummy(type_fvar); + } else { + return null; } - else if (o.getClass().equals(MethodCall.class)) { - MethodCall m_call = (MethodCall) o; - return get_rt_Type_of_MethodCall(m_call, ass); - } - else if (o.getClass().equals(FieldVar.class)){ - // FieldVar ist noch nicht implementiert - return null; - } - else { - return null; - } } - - + public static TV_Alpha get_rt_Type_of_LocalVar(LocalVar v, List ass) { - AS_Argument arg = AS_Abstract.find_AS_Argument_by_Name(v.get_expression(), ass); - return arg.tv_alpha; + AS_Argument arg = AS_Abstract.find_AS_Argument_by_Name(v.get_expression(), ass); + return arg.tv_alpha; } - - - public static TV_ReturnType2 get_rt_Type_of_MethodCall(MethodCall mt_call, List ass) { - TV_Abstract tv_receiver = get_rt_Type_of(mt_call.get_Receiver().get_Expression(), ass); - TV_ReturnType2 res = new TV_ReturnType2(mt_call.get_Name(), tv_receiver.toString() ); - return res; + + public static TV_ReturnType2 get_rt_Type_of_MethodCall(MethodCall mt_call, List ass) { + TV_Abstract tv_receiver = get_rt_Type_of(mt_call.get_Receiver().get_Expression(), ass); + TV_ReturnType2 res = new TV_ReturnType2(mt_call.get_Name(), tv_receiver.toString()); + return res; } - - - - + + public static String get_rt_Type_of_FieldVar(FieldVar fvar, List ass) { + + TV_Abstract exp = get_rt_Type_of(fvar.getReceiver(), ass); + + return "DeltaXXX ( " + fvar.getFieldVarName() + "," + exp.toString() + ")"; + } + // Neuer Versuch eine Methode berechneten Typen auszugeben - public static String get_Return_typed(Method m, List ass) { - Return r = (Return) m.get_Block().statements.get(0); - Expression ex = r.get_Expression(); - return get_rt_Type_of(ex,ass).toString(); + public static String get_Return_typed(Method m, List ass) { + Return r = (Return) m.get_Block().statements.get(0); + Expression ex = r.get_Expression(); + return get_rt_Type_of(ex, ass).toString(); } - - + // ------------------------------------------------------------------------ - // Erstellen der Constraints. + // Erstellen der Constraints. // Auch dieses erstellen muss Rekursiv erfolgen // ------------------------------- - - public static List generateConstraint(ClassOrInterface cl, List ass ) { - List result = new ArrayList<>(); - - + + public static List generateConstraint(ClassOrInterface cl, List ass) { + List result = new ArrayList<>(); + // 1. Generate Field Constraints - result.addAll(generateFieldConstraints(cl,ass)); - // 2. Generate Method Constraints - result.addAll(generateMethodConstraints(cl,ass)); - - - - - - return result; + result.addAll(generateFieldConstraints(cl, ass)); + // 2. Generate Method Constraints + result.addAll(generateMethodConstraints(cl, ass)); + + return result; } - - - public static List generateFieldConstraints(ClassOrInterface cl, List ass ) { - List result = new ArrayList<>(); - + + public static List generateFieldConstraints(ClassOrInterface cl, List ass) { + List result = new ArrayList<>(); + for (Field f : cl.getFieldDecl()) { - AS_Field as = (AS_Field) AS_Abstract.find_AS_Field(f, ass); - TC_Field constraint = new TC_Field(cl,f, as.get_TV_Field()); - result.add(constraint); - } - return result; + AS_Field as = (AS_Field) AS_Abstract.find_AS_Field(f, ass); + TC_Field constraint = new TC_Field(cl, f, as.get_TV_Field()); + result.add(constraint); + } + return result; } - + /* - * Leider hat das erstellen der Constraints für die Methoden nicht mehr funktioniert - * Aus dies muss Rekursiv erfolgen + * Leider hat das erstellen der Constraints für die Methoden nicht mehr + * funktioniert Aus dies muss Rekursiv erfolgen */ - public static List generateMethodConstraints(ClassOrInterface cl, List ass) { - List result = new ArrayList<>(); + public static List generateMethodConstraints(ClassOrInterface es, List ass) { - for(Method m : cl.getMethods()) { - - Return r = (Return) m.get_Block().getStatements().get(0); - Expression ex = r.get_Expression(); - if (ex.getClass().equals(LocalVar.class)) { - // Kein Constraint - } - else if (ex.getClass().equals(FieldVar.class)){ - // Noch nicht implementiert - - - } - else if (ex.getClass().equals(MethodCall.class)) { - MethodCall m_call = (MethodCall) ex; - - - TC_Method tc = new TC_Method(cl,m); - - result.add(tc); - - - } - else { - // Darf nicht vorkommen - System.out.println("Fehler - Type Expression"); - } - - - } - return result; + List constraints = new ArrayList(); + + for (Method m : es.getMethods() ) { + Return r = (Return) m.get_Block().statements.get(0); + constraints.addAll(generateMethodConstraints(r.get_Expression(), ass)); + } + return constraints; } - - - - - - - - + + public static List generateMethodConstraints(Expression ex, List ass) { + + + + + if (ex.getClass().equals(LocalVar.class)) { + List result = new ArrayList<>(); + return result; + } else if (ex.getClass().equals(FieldVar.class)) { + FieldVar v = (FieldVar) ex; + List res = generateMethodConstraints(v.getReceiver(), ass); + TV_Abstract rt_type = get_rt_Type_of(v.getReceiver(),ass); + + + // NEW TC field TC_Field() + res.add(new TC_Dummy(String.format("TC_Field: ( %s , %s , %s )" , rt_type.toString() , v.getFieldVarName() , "TV_Field(" + rt_type.toString() + " , " + v.getFieldVarName() ) )); + + return res; + + } else if (ex.getClass().equals(MethodCall.class)) { + MethodCall m_call = (MethodCall) ex; + List res = generateMethodConstraints(m_call.get_Receiver().get_Expression(), ass); + TV_Abstract rt_type = get_rt_Type_of(m_call, ass); + + + res.add(new TC_Dummy("Klasse? " , m_call.get_Name() , "Arguments" , "ReturnType: " + rt_type.toString() , "Typvar: ?" )); + return res; + + } else { + // Darf nicht vorkommen + System.out.println("Fehler - Type Expression"); + return null; + } + } + + } diff --git a/src/de/dhbwstuttgart/strucTypes/CodeGenerator.java b/src/de/dhbwstuttgart/strucTypes/CodeGenerator.java index 93dd2801..7de42fbc 100644 --- a/src/de/dhbwstuttgart/strucTypes/CodeGenerator.java +++ b/src/de/dhbwstuttgart/strucTypes/CodeGenerator.java @@ -58,8 +58,7 @@ public class CodeGenerator { public static String generateMethod(Method m, List ass ) { - String rt_type = Algo_TypeExpr.get_Return_typed(m, ass); - + String rt_type = Algo_TypeExpr.get_Return_typed(m, ass); String code = rt_type +" " + m.getName() + " ( " ; @@ -67,7 +66,8 @@ public class CodeGenerator { // Generate Formalparameter List fp = m.getParameterList().getFormalparalist(); for (FormalParameter f : fp ) { - AS_Argument arg = AS_Abstract.find_AS_Argument(f, ass); + //AS_Argument arg = AS_Abstract.find_AS_Argument(f, ass); + AS_Argument arg = AS_Abstract.find_AS_Argument(f, m, ass); code = code + arg.get_code() + ", "; } diff --git a/src/de/dhbwstuttgart/strucTypes/TC_Dummy.java b/src/de/dhbwstuttgart/strucTypes/TC_Dummy.java new file mode 100644 index 00000000..06fbaa56 --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes/TC_Dummy.java @@ -0,0 +1,23 @@ +package de.dhbwstuttgart.strucTypes; + +public class TC_Dummy extends TC_Abstract { + + private String dummy; + + public TC_Dummy(String inhalt) { + this.dummy = inhalt; + } + + public TC_Dummy(String type1, String method, String arguments_of_type , String returntype , String typvar) { + this.dummy = String.format("Mue( %s , %s , %s, (%s , %s )) " , type1, method, arguments_of_type, returntype, typvar); + } + + + public String toString() { + return dummy; + } + + + + +} diff --git a/src/de/dhbwstuttgart/strucTypes/TC_Method.java b/src/de/dhbwstuttgart/strucTypes/TC_Method.java index 9603bfe5..8f222eef 100644 --- a/src/de/dhbwstuttgart/strucTypes/TC_Method.java +++ b/src/de/dhbwstuttgart/strucTypes/TC_Method.java @@ -2,6 +2,7 @@ package de.dhbwstuttgart.strucTypes; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.Method; +import de.dhbwstuttgart.syntaxtree.statement.MethodCall; /* Formal Idea: * @@ -16,18 +17,38 @@ public class TC_Method extends TC_Abstract { // Not completely implemented in the moment private ClassOrInterface cl; + private TV_Abstract typvar; private Method method; + private MethodCall method_call; - + // variante 1 -> Klasse ist bekannt public TC_Method(ClassOrInterface cl, Method method ) { super(); this.cl = cl; - this.method = method; + this.method = method; + typvar = null; + } + + // variante 2 -> Klasse ist nicht bekannt + public TC_Method(TV_Abstract typvar, MethodCall method_call) { + super(); + this.cl = null; + this.method = null; + this.typvar = typvar; + this.method_call = method_call; } + + public String toString() { - return "Mue( " + cl.getClassName().toString() + "," + method.getName() + "...)" ; + + if (cl != null) { + return "Mue( " + cl.getClassName().toString() + "," + method.getName() + "...)" ; + } + else { + return String.format("Mue( %s , %s ..." , typvar.toString() , method_call.get_Name() ); + } } diff --git a/src/de/dhbwstuttgart/strucTypes/TV_Dummy.java b/src/de/dhbwstuttgart/strucTypes/TV_Dummy.java new file mode 100644 index 00000000..486fb042 --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes/TV_Dummy.java @@ -0,0 +1,18 @@ +package de.dhbwstuttgart.strucTypes; + +public class TV_Dummy extends TV_Abstract { + + + private String type = ""; + + + public TV_Dummy(String type) { + this.type = type; + } + + public String toString() { + return type; + } + + +} diff --git a/src/de/dhbwstuttgart/strucTypes2/Assumption.java b/src/de/dhbwstuttgart/strucTypes2/Assumption.java new file mode 100644 index 00000000..afeabe8b --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes2/Assumption.java @@ -0,0 +1,5 @@ +package de.dhbwstuttgart.strucTypes2; + +public class Assumption { + +} diff --git a/src/de/dhbwstuttgart/strucTypes2/Assumptions_Map.java b/src/de/dhbwstuttgart/strucTypes2/Assumptions_Map.java new file mode 100644 index 00000000..824c4c51 --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes2/Assumptions_Map.java @@ -0,0 +1,7 @@ +package de.dhbwstuttgart.strucTypes2; + +public class Assumptions_Map { + + private Map assumption_Map = new HashMap<>(); + +} diff --git a/src/de/dhbwstuttgart/strucTypes2/CodeGenerator.java b/src/de/dhbwstuttgart/strucTypes2/CodeGenerator.java new file mode 100644 index 00000000..f3b94025 --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes2/CodeGenerator.java @@ -0,0 +1,36 @@ +package de.dhbwstuttgart.strucTypes2; + +import sun.reflect.generics.reflectiveObjects.NotImplementedException; + +import de.dhbwstuttgart.syntaxtree.ClassOrInterface; +import de.dhbwstuttgart.syntaxtree.SourceFile; + + + + +public class CodeGenerator { + + + + public static String generate_code_from_SourceFile(SourceFile sf) { + String res = ""; + + throw new NotImplementedException(); + + } + + + public static String generate_code_from_Class(ClassOrInterface cl) { + throw new NotImplementedException(); + } + + + + + + + + + + +} diff --git a/src/de/dhbwstuttgart/strucTypes2/Collect_Types.java b/src/de/dhbwstuttgart/strucTypes2/Collect_Types.java new file mode 100644 index 00000000..4861c694 --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes2/Collect_Types.java @@ -0,0 +1,27 @@ +package de.dhbwstuttgart.strucTypes2; + +import java.util.HashMap; +import java.util.Map; + +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; + +public class Collect_Types { + + + public static Map collect(SourceFile sf) { + + Map typen = new HashMap<>(); + + + // Sammle Typen aus Klassen + + + + + return typen; + } + + + +} diff --git a/src/de/dhbwstuttgart/strucTypes2/TV_Abstract.java b/src/de/dhbwstuttgart/strucTypes2/TV_Abstract.java new file mode 100644 index 00000000..28a35597 --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes2/TV_Abstract.java @@ -0,0 +1,5 @@ +package de.dhbwstuttgart.strucTypes2; + +public class TV_Abstract { + +} diff --git a/src/de/dhbwstuttgart/strucTypes2/TV_Argument.java b/src/de/dhbwstuttgart/strucTypes2/TV_Argument.java new file mode 100644 index 00000000..4a2251df --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes2/TV_Argument.java @@ -0,0 +1,5 @@ +package de.dhbwstuttgart.strucTypes2; + +public class TV_Argument { + +} diff --git a/src/de/dhbwstuttgart/strucTypes2/TV_Field.java b/src/de/dhbwstuttgart/strucTypes2/TV_Field.java new file mode 100644 index 00000000..e96067d7 --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes2/TV_Field.java @@ -0,0 +1,42 @@ +package de.dhbwstuttgart.strucTypes2; + +import de.dhbwstuttgart.syntaxtree.Field; + +public class TV_Field extends TV_Abstract { + + private TV_Abstract type_of_class; + private Field field; + + public TV_Field(TV_Abstract type_of_class, Field field) { + super(); + this.type_of_class = type_of_class; + this.field = field; + } + + + public TV_Abstract getType_of_class() { + return type_of_class; + } + + public void setType_of_class(TV_Abstract type_of_class) { + this.type_of_class = type_of_class; + } + + public Field getField() { + return field; + } + + public void setField(Field field) { + this.field = field; + } + + + + + + + + + + +} diff --git a/src/de/dhbwstuttgart/strucTypes2/TV_Type.java b/src/de/dhbwstuttgart/strucTypes2/TV_Type.java new file mode 100644 index 00000000..ae9b538f --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes2/TV_Type.java @@ -0,0 +1,15 @@ +package de.dhbwstuttgart.strucTypes2; + +import de.dhbwstuttgart.typecheck.JavaClassName; + +public class TV_Type extends TV_Abstract { + + + private JavaClassName name; + + + + + + +} diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/FieldVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/FieldVar.java index 0eac0866..8423e38c 100644 --- a/src/de/dhbwstuttgart/syntaxtree/statement/FieldVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/FieldVar.java @@ -40,4 +40,19 @@ public class FieldVar extends Expression { ret.addOderConstraint(oderConstraints); return ret; } + + // @ Sebastian + public String getFieldVarName() { + return fieldVarName; + } + + // @ Sebastian + public Expression getReceiver() { + return receiver; + } + + + + + } diff --git a/test/strucTypes/GeneralParserTest.java b/test/strucTypes/GeneralParserTest.java index 63b1972a..9a735265 100644 --- a/test/strucTypes/GeneralParserTest.java +++ b/test/strucTypes/GeneralParserTest.java @@ -41,7 +41,8 @@ public class GeneralParserTest{ //filenames.add("GenericFieldVarTest.jav"); //filenames.add("FieldVarTest.jav"); - filenames.add("StructuralTypesField.jav"); + filenames.add("StructuralTypesSimple3.jav"); + //filenames.add("StructuralTypesField.jav"); //filenames.add("Main.jav"); JavaTXParser parser = new JavaTXParser(); diff --git a/test/strucTypes/StructuralTypesSimple3.jav b/test/strucTypes/StructuralTypesSimple3.jav index 738c2602..fb01208a 100644 --- a/test/strucTypes/StructuralTypesSimple3.jav +++ b/test/strucTypes/StructuralTypesSimple3.jav @@ -3,12 +3,12 @@ class A { A f1; - A f2; - + f2; - mt1(x) { return x; } + + mt1(x1) { return x1; } - //mt2(x) { return x.feld ; } + mt2(x2) { return x2.feld_von_x ; } mt3(x,y,z) { return x.sub(y).add(z); } diff --git a/test/strucTypes2/GeneralParserTest.java b/test/strucTypes2/GeneralParserTest.java new file mode 100644 index 00000000..2f21e653 --- /dev/null +++ b/test/strucTypes2/GeneralParserTest.java @@ -0,0 +1,74 @@ +package strucTypes2; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import de.dhbwstuttgart.parser.JavaTXParser; +import de.dhbwstuttgart.strucTypes.AS_Abstract; +import de.dhbwstuttgart.strucTypes.TC_Abstract; +import de.dhbwstuttgart.strucTypes.Algo_Type; +import de.dhbwstuttgart.strucTypes.Algo_TypeExpr; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.statement.CastExpr; +import sun.reflect.generics.reflectiveObjects.NotImplementedException; + +import org.junit.Test; + + +/** + * Dieser Test pr�ft nur, ob .java-Dateien fehlerfrei geparst werden. + * Der dabei erstellte Syntaxbaum wird nicht kontrolliert. + * @author janulrich + * + */ +public class GeneralParserTest{ + private static final String rootDirectory = System.getProperty("user.dir")+"/test/strucTypes/"; + + @Test + public void run(){ + + /* + * Auflistung aller Files die getestet werden sollen + */ + List filenames = new ArrayList(); + //filenames.add("FieldInitializationTest.jav"); + //filenames.add("ImportTest.jav"); + //filenames.add("StatementsTest.jav"); + //filenames.add("ImportTestGeneric.jav"); + //filenames.add("BoundedParameter.jav"); + //filenames.add("GenericFieldVarTest.jav"); + //filenames.add("FieldVarTest.jav"); + + filenames.add("StructuralTypesSimple3.jav"); + //filenames.add("StructuralTypesField.jav"); + //filenames.add("Main.jav"); + + JavaTXParser parser = new JavaTXParser(); + try{ + for(String filename : filenames) { + + System.out.println("Teste: "+ filename); + + SourceFile sf = parser.parse(new File(rootDirectory + filename)); + + SourceFile sfdebug = sf; + + + // Hier soll der CodeGenerator hin. + + + + + + + } + }catch(Exception exc){ + exc.printStackTrace(); + fail(); + } + assertTrue("Tests durchlaufen",filenames.size()>0); + } + +} diff --git a/test/strucTypes2/StructuralTypesSimple3.jav b/test/strucTypes2/StructuralTypesSimple3.jav new file mode 100644 index 00000000..a774fc5d --- /dev/null +++ b/test/strucTypes2/StructuralTypesSimple3.jav @@ -0,0 +1,16 @@ + +class A { + + A f1; + + A f2; + + + mt1(x) { return x; } + + mt2(x) { return x.feld_von_x ; } + + mt3(x,y,z) { return x.sub(y).add(z); } + +} +