In MethodCall argTypes durch signature ersetzt und ReturnType eingefuegt.

modified:   src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java
	modified:   src/main/java/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
	modified:   src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java
This commit is contained in:
pl@gohorb.ba-horb.de 2023-01-24 12:05:26 +01:00
parent 2ab3becf44
commit 2448969426
3 changed files with 14 additions and 7 deletions

View File

@ -803,11 +803,12 @@ public class StatementGenerator {
}else { }else {
Java8Parser.MethodInvocation_lf_primaryContext ctxt = e.methodInvocation_lf_primary(); Java8Parser.MethodInvocation_lf_primaryContext ctxt = e.methodInvocation_lf_primary();
String methodName = ctxt.Identifier().toString(); String methodName = ctxt.Identifier().toString();
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes = ctxt.argumentList().expression().stream() ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature = ctxt.argumentList().expression().stream()
.map(x -> TypePlaceholder.fresh(e.getStart())) .map(x -> TypePlaceholder.fresh(e.getStart()))
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
signature.add(TypePlaceholder.fresh(e.getStart())); //ReturnType
return new MethodCall(TypePlaceholder.fresh(e.getStart()), getReceiver(expr), methodName, return new MethodCall(TypePlaceholder.fresh(e.getStart()), getReceiver(expr), methodName,
convert(ctxt.argumentList()), TypePlaceholder.fresh(e.getStart()), argTypes, e.getStart()); convert(ctxt.argumentList()), TypePlaceholder.fresh(e.getStart()), signature, e.getStart());
} }
} }

View File

@ -25,16 +25,18 @@ public class MethodCall extends Statement
public final ArgumentList arglist; public final ArgumentList arglist;
public RefTypeOrTPHOrWildcardOrGeneric receiverType; public RefTypeOrTPHOrWildcardOrGeneric receiverType;
public final ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes; //sind Tphs, repraesentieren im Resultset die Typen der aufgerufenen Methoden
//sind Tphs, repraesentieren im Resultset die Signatur der aufgerufenen Methoden, letztes Element ist der Returntyp
public final ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature;
public MethodCall(RefTypeOrTPHOrWildcardOrGeneric retType, Receiver receiver, String methodName, ArgumentList argumentList, public MethodCall(RefTypeOrTPHOrWildcardOrGeneric retType, Receiver receiver, String methodName, ArgumentList argumentList,
RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes, Token offset){ RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature, Token offset){
super(retType,offset); super(retType,offset);
this.arglist = argumentList; this.arglist = argumentList;
this.name = methodName; this.name = methodName;
this.receiver = receiver; this.receiver = receiver;
this.receiverType = receiverType; this.receiverType = receiverType;
this.argTypes = argTypes; this.signature = signature;
} }

View File

@ -655,8 +655,8 @@ public class TYPEStmt implements StatementVisitor{
RefTypeOrTPHOrWildcardOrGeneric argType = foMethod.arglist.getArguments().get(i).getType(); RefTypeOrTPHOrWildcardOrGeneric argType = foMethod.arglist.getArguments().get(i).getType();
RefTypeOrTPHOrWildcardOrGeneric assType = assumption.getArgTypes(resolver).get(i); RefTypeOrTPHOrWildcardOrGeneric assType = assumption.getArgTypes(resolver).get(i);
//Zuordnung von MethoCall.argTypes zu der Argumenttypen der ausgewaehlten Methode (assumption.params) //Zuordnung von MethoCall.signature (Argumenttypen) zu der Argumenttypen der ausgewaehlten Methode (assumption.params)
ret.add(new Pair(foMethod.argTypes.get(i), assumption.getArgTypes().get(i), PairOperator.EQUALSDOT)); ret.add(new Pair(foMethod.signature.get(i), assumption.getArgTypes().get(i), PairOperator.EQUALSDOT));
ret.add(new Pair(argType, assType, PairOperator.SMALLERDOT)); ret.add(new Pair(argType, assType, PairOperator.SMALLERDOT));
@ -664,6 +664,10 @@ public class TYPEStmt implements StatementVisitor{
// ret.add(new Pair(foMethod.argTypes.get(i), assType, PairOperator.EQUALSDOT)); // ret.add(new Pair(foMethod.argTypes.get(i), assType, PairOperator.EQUALSDOT));
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE //Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
} }
//Zuordnung von MethodCall.signature(ReturnType) zu dem ReturnType der ausgewaehlten Methode (assumption.returnType)
ret.add(new Pair(foMethod.signature.get(foMethod.signature.size()), assumption.getReturnType(), PairOperator.EQUALSDOT));
return ret; return ret;
} }