Methodenconstraint neu definiert, Typvariable eingefügt)

This commit is contained in:
sebastian 2017-04-04 14:52:55 +02:00
parent d4e32794ff
commit a9b9c46d84
5 changed files with 74 additions and 21 deletions

View File

@ -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));
}

View File

@ -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<ConstraintAbstract> constraints = new ArrayList<ConstraintAbstract>();
@ -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<RefTypeOrTPHOrWildcardOrGeneric> argumentTypesVars = new ArrayList<>();
/*
*
*/
List<MyTypeVar> argumentTypesVars = new ArrayList<>();
List<RefTypeOrTPHOrWildcardOrGeneric> 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<SubTypeConstraint> 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;

View File

@ -14,11 +14,11 @@ class MethodConstraint extends ConstraintAbstract {
private String methodName;
private List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes;
private RefTypeOrTPHOrWildcardOrGeneric returnType;
private List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypeVars;
private List<MyTypeVar> argumentTypeVars;
public MethodConstraint(RefTypeOrTPHOrWildcardOrGeneric receiver, String methodName,
List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType,
List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypeVars) {
List<MyTypeVar> argumentTypeVars) {
super();
this.receiver = receiver;
this.methodName = methodName;

View File

@ -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 );
}
}

View File

@ -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); }
}