Fixed bug mit der korrekten Signatur im Bytecode der FunN Typen.

Verbesserung der BytecodeGenMethod -> Nun werden die korrekt resolveten Typen verwendet.
This commit is contained in:
Etienne Zink 2022-03-29 16:20:14 +02:00
parent 7012010462
commit ed00aeb056
3 changed files with 8 additions and 6 deletions

View File

@ -831,8 +831,10 @@ public class BytecodeGenMethod implements StatementVisitor {
//ToDo Etienne: Double Check //ToDo Etienne: Double Check
RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(methodCall.getType()); RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(methodCall.getType());
List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = methodCall List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = methodCall
.argTypes .arglist
.getArguments()
.stream() .stream()
.map(TypableStatement::getType)
.map(resolver::resolve) .map(resolver::resolve)
.collect(Collectors.toList()); .collect(Collectors.toList());
FunNUtilities funNUtilities = FunNGenerator.getInstance(); FunNUtilities funNUtilities = FunNGenerator.getInstance();

View File

@ -82,7 +82,7 @@ public class FunNGenerator implements FunNUtilities{
.concat(argumentTypes.stream(), Stream.of(returnType)) .concat(argumentTypes.stream(), Stream.of(returnType))
.collect(Collectors.toList()); .collect(Collectors.toList());
RefType superFunN = new RefType(new JavaClassName(getSuperClassName(argumentTypes.size())), parameters , null); 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; boolean containsGeneric = false;
String genericSignature = "<"; String genericSignature = "<";

View File

@ -19,7 +19,7 @@ import de.dhbwstuttgart.syntaxtree.type.TypeVisitor;
public class TypeToSignature implements TypeVisitor<String> { public class TypeToSignature implements TypeVisitor<String> {
private List<GenericsGeneratorResult> constraints; private List<GenericsGeneratorResult> constraints;
private final boolean superFunN; private final boolean specializedFunN;
public TypeToSignature() { this(new ArrayList<>(), true); } public TypeToSignature() { this(new ArrayList<>(), true); }
@ -29,16 +29,16 @@ public class TypeToSignature implements TypeVisitor<String> {
this(constraints, true); this(constraints, true);
} }
public TypeToSignature(List<GenericsGeneratorResult> constraints, boolean superFunN){ public TypeToSignature(List<GenericsGeneratorResult> constraints, boolean specializedFunN){
this.constraints = constraints; this.constraints = constraints;
this.superFunN = superFunN; this.specializedFunN = specializedFunN;
} }
@Override @Override
public String visit(RefType refType) { public String visit(RefType refType) {
if(refType.getName().toString().equals("void")) if(refType.getName().toString().equals("void"))
return "V"; return "V";
if (refType.getName().toString().matches("Fun\\d+\\$\\$") && !superFunN){ if (refType.getName().toString().matches("Fun\\d+\\$\\$") && specializedFunN){
FunNUtilities funNUtilities = FunNGenerator.getInstance(); FunNUtilities funNUtilities = FunNGenerator.getInstance();
return funNUtilities.getSpecializedSignature(funNUtilities.getArguments(refType.getParaList()), funNUtilities.getReturnType(refType.getParaList())); return funNUtilities.getSpecializedSignature(funNUtilities.getArguments(refType.getParaList()), funNUtilities.getReturnType(refType.getParaList()));
} }