Bei NewClass ReturnType hinzuefuegt

modified:   src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java
	modified:   src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java
This commit is contained in:
pl@gohorb.ba-horb.de 2023-01-24 14:35:51 +01:00
parent 9dca8ccdaa
commit 04508a85f1
2 changed files with 14 additions and 9 deletions

View File

@ -210,12 +210,13 @@ public class StatementGenerator {
}else throw new NotImplementedException(); }else throw new NotImplementedException();
ArgumentList argumentList = convert(methodInvocationContext.argumentList()); ArgumentList argumentList = convert(methodInvocationContext.argumentList());
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes = argumentList.getArguments().stream() ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature = argumentList.getArguments().stream()
.map(x -> TypePlaceholder.fresh(methodInvocationContext.getStart())) .map(x -> TypePlaceholder.fresh(methodInvocationContext.getStart()))
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
signature.add(TypePlaceholder.fresh(methodInvocationContext.getStart())); //ReturnType
MethodCall ret = new MethodCall(TypePlaceholder.fresh(methodInvocationContext.getStart()), MethodCall ret = new MethodCall(TypePlaceholder.fresh(methodInvocationContext.getStart()),
getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(methodInvocationContext.getStart()), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(methodInvocationContext.getStart()),
argTypes, methodInvocationContext.getStart()); signature, methodInvocationContext.getStart());
ret.setStatement(); ret.setStatement();
return ret; return ret;
} }
@ -302,10 +303,11 @@ public class StatementGenerator {
RefType newClass = (RefType) TypeGenerator.convertTypeName(identifier.getText(),genericArgs,identifier.getSymbol(),reg,generics); RefType newClass = (RefType) TypeGenerator.convertTypeName(identifier.getText(),genericArgs,identifier.getSymbol(),reg,generics);
ArgumentList args = convert(newExpression.argumentList()); ArgumentList args = convert(newExpression.argumentList());
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes = args.getArguments().stream() ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature = args.getArguments().stream()
.map(x -> TypePlaceholder.fresh(newExpression.getStart())) .map(x -> TypePlaceholder.fresh(newExpression.getStart()))
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
Statement ret = new NewClass(newClass, args, null, argTypes, newExpression.getStart()); signature.add(TypePlaceholder.fresh(newExpression.getStart())); //ReturnType
Statement ret = new NewClass(newClass, args, null, signature, newExpression.getStart());
ret.setStatement(); ret.setStatement();
return ret; return ret;
} }
@ -862,10 +864,11 @@ public class StatementGenerator {
RefType newClass = (RefType) TypeGenerator.convertTypeName(identifier.getText(),genericArgs,identifier.getSymbol(),reg,generics); RefType newClass = (RefType) TypeGenerator.convertTypeName(identifier.getText(),genericArgs,identifier.getSymbol(),reg,generics);
ArgumentList args = convert(newExpression.argumentList()); ArgumentList args = convert(newExpression.argumentList());
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes = args.getArguments().stream() ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature = args.getArguments().stream()
.map(x -> TypePlaceholder.fresh(newExpression.getStart())) .map(x -> TypePlaceholder.fresh(newExpression.getStart()))
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
return new NewClass(newClass, args, null, argTypes, newExpression.getStart()); signature.add(TypePlaceholder.fresh(newExpression.getStart())); //ReturnType
return new NewClass(newClass, args, null, signature, newExpression.getStart());
} }
private Expression convert(Java8Parser.LiteralContext literal) { private Expression convert(Java8Parser.LiteralContext literal) {
@ -923,12 +926,13 @@ public class StatementGenerator {
} }
ArgumentList argumentList = convert(methodInvocationContext.argumentList()); ArgumentList argumentList = convert(methodInvocationContext.argumentList());
ArrayList<RefTypeOrTPHOrWildcardOrGeneric> argTypes = argumentList.getArguments().stream() ArrayList<RefTypeOrTPHOrWildcardOrGeneric> signature = argumentList.getArguments().stream()
.map(x -> TypePlaceholder.fresh(methodInvocationContext.getStart())) .map(x -> TypePlaceholder.fresh(methodInvocationContext.getStart()))
.collect(Collectors.toCollection(ArrayList::new)); .collect(Collectors.toCollection(ArrayList::new));
signature.add(TypePlaceholder.fresh(methodInvocationContext.getStart())); //ReturnType
MethodCall ret = new MethodCall(TypePlaceholder.fresh(methodInvocationContext.getStart()), MethodCall ret = new MethodCall(TypePlaceholder.fresh(methodInvocationContext.getStart()),
getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(methodInvocationContext.getStart()), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(methodInvocationContext.getStart()),
argTypes, methodInvocationContext.getStart()); signature, methodInvocationContext.getStart());
return ret; return ret;
} }

View File

@ -666,7 +666,8 @@ public class TYPEStmt implements StatementVisitor{
} }
//Zuordnung von MethodCall.signature(ReturnType) zu dem ReturnType der ausgewaehlten Methode (assumption.returnType) //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)); System.out.println(foMethod.name);
ret.add(new Pair(foMethod.signature.get(foMethod.signature.size()-1), assumption.getReturnType(), PairOperator.EQUALSDOT));
return ret; return ret;
} }