From 04508a85f1ecef4fbf9398bc1c35d9ee2bb9d05f Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Tue, 24 Jan 2023 14:35:51 +0100 Subject: [PATCH] Bei NewClass ReturnType hinzuefuegt modified: src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java modified: src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java --- .../StatementGenerator.java | 20 +++++++++++-------- .../typeinference/typeAlgo/TYPEStmt.java | 3 ++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index f638957d9..feebbe032 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -210,12 +210,13 @@ public class StatementGenerator { }else throw new NotImplementedException(); ArgumentList argumentList = convert(methodInvocationContext.argumentList()); - ArrayList argTypes = argumentList.getArguments().stream() + ArrayList signature = argumentList.getArguments().stream() .map(x -> TypePlaceholder.fresh(methodInvocationContext.getStart())) .collect(Collectors.toCollection(ArrayList::new)); + signature.add(TypePlaceholder.fresh(methodInvocationContext.getStart())); //ReturnType MethodCall ret = new MethodCall(TypePlaceholder.fresh(methodInvocationContext.getStart()), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(methodInvocationContext.getStart()), - argTypes, methodInvocationContext.getStart()); + signature, methodInvocationContext.getStart()); ret.setStatement(); return ret; } @@ -302,10 +303,11 @@ public class StatementGenerator { RefType newClass = (RefType) TypeGenerator.convertTypeName(identifier.getText(),genericArgs,identifier.getSymbol(),reg,generics); ArgumentList args = convert(newExpression.argumentList()); - ArrayList argTypes = args.getArguments().stream() + ArrayList signature = args.getArguments().stream() .map(x -> TypePlaceholder.fresh(newExpression.getStart())) .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(); return ret; } @@ -862,10 +864,11 @@ public class StatementGenerator { RefType newClass = (RefType) TypeGenerator.convertTypeName(identifier.getText(),genericArgs,identifier.getSymbol(),reg,generics); ArgumentList args = convert(newExpression.argumentList()); - ArrayList argTypes = args.getArguments().stream() + ArrayList signature = args.getArguments().stream() .map(x -> TypePlaceholder.fresh(newExpression.getStart())) .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) { @@ -923,12 +926,13 @@ public class StatementGenerator { } ArgumentList argumentList = convert(methodInvocationContext.argumentList()); - ArrayList argTypes = argumentList.getArguments().stream() + ArrayList signature = argumentList.getArguments().stream() .map(x -> TypePlaceholder.fresh(methodInvocationContext.getStart())) .collect(Collectors.toCollection(ArrayList::new)); + signature.add(TypePlaceholder.fresh(methodInvocationContext.getStart())); //ReturnType MethodCall ret = new MethodCall(TypePlaceholder.fresh(methodInvocationContext.getStart()), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(methodInvocationContext.getStart()), - argTypes, methodInvocationContext.getStart()); + signature, methodInvocationContext.getStart()); return ret; } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index e9c39fed7..803e0df1d 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -666,7 +666,8 @@ public class TYPEStmt implements StatementVisitor{ } //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; }