diff --git a/src/de/dhbwstuttgart/strucTypes3/AssumptionGenerator.java b/src/de/dhbwstuttgart/strucTypes3/AssumptionGenerator.java index 1ec57122..b24bcfce 100644 --- a/src/de/dhbwstuttgart/strucTypes3/AssumptionGenerator.java +++ b/src/de/dhbwstuttgart/strucTypes3/AssumptionGenerator.java @@ -50,11 +50,11 @@ public class AssumptionGenerator { for (FormalParameter p : m.getParameterList().getFormalparalist()) { String pName = p.getName(); String pType = p.getType().toString(); - typeArg = typeArg + String.format("%s : %s", pName, pType); + typeArg = typeArg + String.format("%s :%s ", pName, pType); ass.put(p.getName(), p.getType()); } argAss.put(m, ass); - System.out.println(String.format("Methodenname: %s , Arguments: %s -> ReturnType %s", methodName, typeArg, + System.out.println(String.format("Methodenname: %s , Arguments: %s -> ReturnType %s ", methodName, typeArg, returnType)); } diff --git a/src/de/dhbwstuttgart/strucTypes3/HelpMethoden.java b/src/de/dhbwstuttgart/strucTypes3/HelpMethoden.java index e0ad99cc..4d74f23a 100644 --- a/src/de/dhbwstuttgart/strucTypes3/HelpMethoden.java +++ b/src/de/dhbwstuttgart/strucTypes3/HelpMethoden.java @@ -121,7 +121,7 @@ public class HelpMethoden { // LocalVar (Constraints für den Algo, Constraints für die Interfaces // usw. ) - // LocalVar + // LocalVar ------------------------------------------------------------------------------------------ if (expression.getClass().equals(LocalVar.class)) { LocalVar lvar = (LocalVar) expression; List constraints = new ArrayList(); @@ -130,7 +130,7 @@ public class HelpMethoden { constraints.add(constraint); return constraints; } - // FeldVar + // FeldVar ------------------------------------------------------------------------------------------ else if (expression.getClass().equals(FieldVar.class)) { FieldVar fieldVar = (FieldVar) expression; Expression receiver = fieldVar.getReceiver(); @@ -146,7 +146,7 @@ public class HelpMethoden { return constraints; } - // MethodCall + // MethodCall ------------------------------------------------------------------------------------------ else if (expression.getClass().equals(MethodCall.class)) { MethodCall methodCall = (MethodCall) expression; @@ -162,13 +162,20 @@ public class HelpMethoden { } // An dieser Stelle wird der Methoden Constraint erstellt - List argumentTypesVars = new ArrayList<>(); + /* + * + */ + List argumentTypesVars = new ArrayList<>(); List argumentTypes = new ArrayList<>(); + Integer index_arg = 1; for (Expression arg : methodCall.get_ArgList().getArguments()) { - argumentTypesVars.add(arg.getType()); + argumentTypesVars.add(new MyTypeVar(methodCall.get_Name(), index_arg , receiver.getType())); + index_arg = index_arg +1; constraints.addAll(HelpMethoden.TypeExpr(ass, arg, method, cl)); + argumentTypes.add(arg.getType()); } + /* // Es wird der Typ des übergabeparameter erstellt List puffer = new ArrayList<>(); for (RefTypeOrTPHOrWildcardOrGeneric type : argumentTypesVars) { @@ -185,15 +192,11 @@ public class HelpMethoden { } } + constraints.addAll(puffer); - - - - - + */ MethodConstraint methodConstraint = new MethodConstraint(receiver.getType(), methodCall.get_Name(), argumentTypes, methodCall.getType(), argumentTypesVars ); - constraints.add(methodConstraint); return constraints; diff --git a/src/de/dhbwstuttgart/strucTypes3/MethodConstraint.java b/src/de/dhbwstuttgart/strucTypes3/MethodConstraint.java index 12679f26..8812a7da 100644 --- a/src/de/dhbwstuttgart/strucTypes3/MethodConstraint.java +++ b/src/de/dhbwstuttgart/strucTypes3/MethodConstraint.java @@ -14,11 +14,11 @@ class MethodConstraint extends ConstraintAbstract { private String methodName; private List argumentTypes; private RefTypeOrTPHOrWildcardOrGeneric returnType; - private List argumentTypeVars; + private List argumentTypeVars; public MethodConstraint(RefTypeOrTPHOrWildcardOrGeneric receiver, String methodName, List argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType, - List argumentTypeVars) { + List argumentTypeVars) { super(); this.receiver = receiver; this.methodName = methodName; diff --git a/src/de/dhbwstuttgart/strucTypes3/MyTypeVar.java b/src/de/dhbwstuttgart/strucTypes3/MyTypeVar.java new file mode 100644 index 00000000..2f864a46 --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes3/MyTypeVar.java @@ -0,0 +1,53 @@ +package de.dhbwstuttgart.strucTypes3; + +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; + +public class MyTypeVar { + + private String method_name; + private Integer index_Argument; + private RefTypeOrTPHOrWildcardOrGeneric typevar; + + public MyTypeVar(String method_name, Integer index_Argument, RefTypeOrTPHOrWildcardOrGeneric typevar) { + super(); + this.method_name = method_name; + this.index_Argument = index_Argument; + this.typevar = typevar; + } + + + + public String getMethod_name() { + return method_name; + } + + public void setMethod_name(String method_name) { + this.method_name = method_name; + } + + public Integer getIndex_Argument() { + return index_Argument; + } + + public void setIndex_Argument(Integer index_Argument) { + this.index_Argument = index_Argument; + } + + public RefTypeOrTPHOrWildcardOrGeneric getTypevar() { + return typevar; + } + + public void setTypevar(RefTypeOrTPHOrWildcardOrGeneric typevar) { + this.typevar = typevar; + } + + public String toString() { + return String.format("TypVar?( %s , %s , %s )" , method_name , index_Argument , typevar ); + } + + + + + + +} diff --git a/test/strucTypes3/StructuralTypesSimpleSkript.jav b/test/strucTypes3/StructuralTypesSimpleSkript.jav index 70c53673..fd0b55c5 100644 --- a/test/strucTypes3/StructuralTypesSimpleSkript.jav +++ b/test/strucTypes3/StructuralTypesSimpleSkript.jav @@ -1,10 +1,7 @@ -class A { - - mt(x,y,z) { return x.sub(y).add(z); } - - - + +class A { + mt(x,y,z) { return x.sub(y).add(z); } }