From ed00aeb056698bcecc846786f8c6794595babb97 Mon Sep 17 00:00:00 2001 From: Etienne Zink Date: Tue, 29 Mar 2022 16:20:14 +0200 Subject: [PATCH] Fixed bug mit der korrekten Signatur im Bytecode der FunN Typen. Verbesserung der BytecodeGenMethod -> Nun werden die korrekt resolveten Typen verwendet. --- .../java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java | 4 +++- .../de/dhbwstuttgart/bytecode/funN/FunNGenerator.java | 2 +- .../dhbwstuttgart/bytecode/signature/TypeToSignature.java | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java b/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java index 8fcebbf06..5cbcfca99 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java @@ -831,8 +831,10 @@ public class BytecodeGenMethod implements StatementVisitor { //ToDo Etienne: Double Check RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(methodCall.getType()); List argumentTypes = methodCall - .argTypes + .arglist + .getArguments() .stream() + .map(TypableStatement::getType) .map(resolver::resolve) .collect(Collectors.toList()); FunNUtilities funNUtilities = FunNGenerator.getInstance(); diff --git a/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java b/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java index 46e219aa7..8bd512b80 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java @@ -82,7 +82,7 @@ public class FunNGenerator implements FunNUtilities{ .concat(argumentTypes.stream(), Stream.of(returnType)) .collect(Collectors.toList()); RefType superFunN = new RefType(new JavaClassName(getSuperClassName(argumentTypes.size())), parameters , null); - StringBuilder funNClassSignature = new StringBuilder(objectSignature + (superFunN.acceptTV(new TypeToSignature()))); + StringBuilder funNClassSignature = new StringBuilder(objectSignature + (superFunN.acceptTV(new TypeToSignature(false)))); boolean containsGeneric = false; String genericSignature = "<"; diff --git a/src/main/java/de/dhbwstuttgart/bytecode/signature/TypeToSignature.java b/src/main/java/de/dhbwstuttgart/bytecode/signature/TypeToSignature.java index 8e5a87dd9..0026b85f5 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/signature/TypeToSignature.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/signature/TypeToSignature.java @@ -19,7 +19,7 @@ import de.dhbwstuttgart.syntaxtree.type.TypeVisitor; public class TypeToSignature implements TypeVisitor { private List constraints; - private final boolean superFunN; + private final boolean specializedFunN; public TypeToSignature() { this(new ArrayList<>(), true); } @@ -29,16 +29,16 @@ public class TypeToSignature implements TypeVisitor { this(constraints, true); } - public TypeToSignature(List constraints, boolean superFunN){ + public TypeToSignature(List constraints, boolean specializedFunN){ this.constraints = constraints; - this.superFunN = superFunN; + this.specializedFunN = specializedFunN; } @Override public String visit(RefType refType) { if(refType.getName().toString().equals("void")) return "V"; - if (refType.getName().toString().matches("Fun\\d+\\$\\$") && !superFunN){ + if (refType.getName().toString().matches("Fun\\d+\\$\\$") && specializedFunN){ FunNUtilities funNUtilities = FunNGenerator.getInstance(); return funNUtilities.getSpecializedSignature(funNUtilities.getArguments(refType.getParaList()), funNUtilities.getReturnType(refType.getParaList())); }