Type Constraints angepasst
This commit is contained in:
parent
b0ef4aecd6
commit
cccc9f4d49
@ -43,6 +43,25 @@ public class AS_Abstract {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static AS_Argument find_AS_Argument(FormalParameter f, Method m , List<AS_Abstract> 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<AS_Abstract> ass ) {
|
||||
|
||||
// if
|
||||
|
@ -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
|
||||
@ -87,10 +89,6 @@ public class Algo_Type {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -121,10 +119,6 @@ public class Algo_Type {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Gettermethoden
|
||||
public Object getResult_cl_t() {
|
||||
return result_cl_t;
|
||||
|
@ -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,13 +11,12 @@ 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
|
||||
@ -31,31 +28,21 @@ public class Algo_TypeExpr {
|
||||
// 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<AS_Abstract> ass, List<Statement> statements) {
|
||||
|
||||
this.res_constriant_set = new ArrayList<TC_Abstract>();
|
||||
res_expression_typed = "";
|
||||
|
||||
|
||||
|
||||
// Methode enthält kein Statement
|
||||
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)) {
|
||||
@ -78,22 +65,15 @@ public class Algo_TypeExpr {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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:
|
||||
* 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<AS_Abstract> ass, List<Statement> statements) {
|
||||
String res = "";
|
||||
@ -107,14 +87,30 @@ public class Algo_TypeExpr {
|
||||
if (statements.size() == 1) {
|
||||
if (statements.get(0).getClass() == Return.class) {
|
||||
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<Statement> liste = new ArrayList<Statement>();
|
||||
liste.add((Statement) fvar.receiver);
|
||||
String reciever_str = expression2code(ass, liste);
|
||||
|
||||
return reciever_str + "." + exp_str;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public static String statement2code(List<AS_Abstract> ass, Statement statement) {
|
||||
|
||||
// TODO: Else if
|
||||
@ -125,11 +121,19 @@ public class Algo_TypeExpr {
|
||||
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;
|
||||
@ -148,9 +152,6 @@ public class Algo_TypeExpr {
|
||||
return "Fehler";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<TC_Abstract> generate(List<AS_Abstract> ass, List<Statement> exp) {
|
||||
|
||||
// Methoden enhält keine Statements
|
||||
@ -159,7 +160,6 @@ public class Algo_TypeExpr {
|
||||
this.res_expression_typed = null;
|
||||
}
|
||||
|
||||
|
||||
// Methoden enthält ein Return Statement
|
||||
if (exp.size() == 1) {
|
||||
Statement std = (Statement) exp.get(0);
|
||||
@ -171,24 +171,21 @@ public class Algo_TypeExpr {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<TC_Abstract> generate_return(List<AS_Abstract> 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<TC_Abstract>();
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
@ -198,26 +195,14 @@ public class Algo_TypeExpr {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<TC_Abstract> 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
|
||||
@ -227,35 +212,35 @@ public class Algo_TypeExpr {
|
||||
if (o.getClass().equals(LocalVar.class)) {
|
||||
LocalVar v = (LocalVar) o;
|
||||
return get_rt_Type_of_LocalVar(v, ass);
|
||||
}
|
||||
else if (o.getClass().equals(MethodCall.class)) {
|
||||
} 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 {
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static TV_Alpha get_rt_Type_of_LocalVar(LocalVar v, List<AS_Abstract> ass) {
|
||||
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<AS_Abstract> 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<AS_Abstract> 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<AS_Abstract> ass) {
|
||||
@ -264,7 +249,6 @@ public class Algo_TypeExpr {
|
||||
return get_rt_Type_of(ex, ass).toString();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Erstellen der Constraints.
|
||||
// Auch dieses erstellen muss Rekursiv erfolgen
|
||||
@ -273,20 +257,14 @@ public class Algo_TypeExpr {
|
||||
public static List<TC_Abstract> generateConstraint(ClassOrInterface cl, List<AS_Abstract> ass) {
|
||||
List<TC_Abstract> result = new ArrayList<>();
|
||||
|
||||
|
||||
// 1. Generate Field Constraints
|
||||
result.addAll(generateFieldConstraints(cl, ass));
|
||||
// 2. Generate Method Constraints
|
||||
result.addAll(generateMethodConstraints(cl, ass));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static List<TC_Field> generateFieldConstraints(ClassOrInterface cl, List<AS_Abstract> ass) {
|
||||
List<TC_Field> result = new ArrayList<>();
|
||||
|
||||
@ -299,53 +277,58 @@ public class Algo_TypeExpr {
|
||||
}
|
||||
|
||||
/*
|
||||
* 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<TC_Method> generateMethodConstraints(ClassOrInterface cl, List<AS_Abstract> ass) {
|
||||
List<TC_Method> result = new ArrayList<>();
|
||||
public static List<TC_Abstract> generateMethodConstraints(ClassOrInterface es, List<AS_Abstract> ass) {
|
||||
|
||||
List<TC_Abstract> constraints = new ArrayList<TC_Abstract>();
|
||||
|
||||
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<TC_Abstract> generateMethodConstraints(Expression ex, List<AS_Abstract> 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
|
||||
List<TC_Abstract> result = new ArrayList<>();
|
||||
return result;
|
||||
} else if (ex.getClass().equals(FieldVar.class)) {
|
||||
FieldVar v = (FieldVar) ex;
|
||||
List<TC_Abstract> res = generateMethodConstraints(v.getReceiver(), ass);
|
||||
TV_Abstract rt_type = get_rt_Type_of(v.getReceiver(),ass);
|
||||
|
||||
|
||||
}
|
||||
else if (ex.getClass().equals(MethodCall.class)) {
|
||||
// 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<TC_Abstract> res = generateMethodConstraints(m_call.get_Receiver().get_Expression(), ass);
|
||||
TV_Abstract rt_type = get_rt_Type_of(m_call, ass);
|
||||
|
||||
|
||||
TC_Method tc = new TC_Method(cl,m);
|
||||
res.add(new TC_Dummy("Klasse? " , m_call.get_Name() , "Arguments" , "ReturnType: " + rt_type.toString() , "Typvar: ?" ));
|
||||
return res;
|
||||
|
||||
result.add(tc);
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Darf nicht vorkommen
|
||||
System.out.println("Fehler - Type Expression");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -61,13 +61,13 @@ public class CodeGenerator {
|
||||
String rt_type = Algo_TypeExpr.get_Return_typed(m, ass);
|
||||
|
||||
|
||||
|
||||
String code = rt_type +" " + m.getName() + " ( " ;
|
||||
|
||||
// Generate Formalparameter
|
||||
List<FormalParameter> 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() + ", ";
|
||||
}
|
||||
|
||||
|
23
src/de/dhbwstuttgart/strucTypes/TC_Dummy.java
Normal file
23
src/de/dhbwstuttgart/strucTypes/TC_Dummy.java
Normal file
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -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,19 +17,39 @@ 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;
|
||||
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() {
|
||||
|
||||
if (cl != null) {
|
||||
return "Mue( " + cl.getClassName().toString() + "," + method.getName() + "...)" ;
|
||||
}
|
||||
else {
|
||||
return String.format("Mue( %s , %s ..." , typvar.toString() , method_call.get_Name() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
18
src/de/dhbwstuttgart/strucTypes/TV_Dummy.java
Normal file
18
src/de/dhbwstuttgart/strucTypes/TV_Dummy.java
Normal file
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
5
src/de/dhbwstuttgart/strucTypes2/Assumption.java
Normal file
5
src/de/dhbwstuttgart/strucTypes2/Assumption.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.dhbwstuttgart.strucTypes2;
|
||||
|
||||
public class Assumption {
|
||||
|
||||
}
|
7
src/de/dhbwstuttgart/strucTypes2/Assumptions_Map.java
Normal file
7
src/de/dhbwstuttgart/strucTypes2/Assumptions_Map.java
Normal file
@ -0,0 +1,7 @@
|
||||
package de.dhbwstuttgart.strucTypes2;
|
||||
|
||||
public class Assumptions_Map {
|
||||
|
||||
private Map<TypePlaceholder, TVar> assumption_Map = new HashMap<>();
|
||||
|
||||
}
|
36
src/de/dhbwstuttgart/strucTypes2/CodeGenerator.java
Normal file
36
src/de/dhbwstuttgart/strucTypes2/CodeGenerator.java
Normal file
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
27
src/de/dhbwstuttgart/strucTypes2/Collect_Types.java
Normal file
27
src/de/dhbwstuttgart/strucTypes2/Collect_Types.java
Normal file
@ -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<RefTypeOrTPHOrWildcardOrGeneric,String> collect(SourceFile sf) {
|
||||
|
||||
Map<RefTypeOrTPHOrWildcardOrGeneric,String> typen = new HashMap<>();
|
||||
|
||||
|
||||
// Sammle Typen aus Klassen
|
||||
|
||||
|
||||
|
||||
|
||||
return typen;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
5
src/de/dhbwstuttgart/strucTypes2/TV_Abstract.java
Normal file
5
src/de/dhbwstuttgart/strucTypes2/TV_Abstract.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.dhbwstuttgart.strucTypes2;
|
||||
|
||||
public class TV_Abstract {
|
||||
|
||||
}
|
5
src/de/dhbwstuttgart/strucTypes2/TV_Argument.java
Normal file
5
src/de/dhbwstuttgart/strucTypes2/TV_Argument.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.dhbwstuttgart.strucTypes2;
|
||||
|
||||
public class TV_Argument {
|
||||
|
||||
}
|
42
src/de/dhbwstuttgart/strucTypes2/TV_Field.java
Normal file
42
src/de/dhbwstuttgart/strucTypes2/TV_Field.java
Normal file
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
15
src/de/dhbwstuttgart/strucTypes2/TV_Type.java
Normal file
15
src/de/dhbwstuttgart/strucTypes2/TV_Type.java
Normal file
@ -0,0 +1,15 @@
|
||||
package de.dhbwstuttgart.strucTypes2;
|
||||
|
||||
import de.dhbwstuttgart.typecheck.JavaClassName;
|
||||
|
||||
public class TV_Type extends TV_Abstract {
|
||||
|
||||
|
||||
private JavaClassName name;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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); }
|
||||
|
||||
|
74
test/strucTypes2/GeneralParserTest.java
Normal file
74
test/strucTypes2/GeneralParserTest.java
Normal file
@ -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<String> filenames = new ArrayList<String>();
|
||||
//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);
|
||||
}
|
||||
|
||||
}
|
16
test/strucTypes2/StructuralTypesSimple3.jav
Normal file
16
test/strucTypes2/StructuralTypesSimple3.jav
Normal file
@ -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); }
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user