diff --git a/src/main/java/de/dhbwstuttgart/target/bytecode/Codegen.java b/src/main/java/de/dhbwstuttgart/target/bytecode/Codegen.java index 7c781a6c..71cbb1f9 100755 --- a/src/main/java/de/dhbwstuttgart/target/bytecode/Codegen.java +++ b/src/main/java/de/dhbwstuttgart/target/bytecode/Codegen.java @@ -1,6 +1,5 @@ package de.dhbwstuttgart.target.bytecode; -import de.dhbwstuttgart.syntaxtree.statement.Block; import de.dhbwstuttgart.target.tree.*; import de.dhbwstuttgart.target.tree.expression.*; import de.dhbwstuttgart.target.tree.type.*; @@ -751,7 +750,7 @@ public class Codegen { private void generate(State state, TargetExpression expr) { var mv = state.mv; switch (expr) { - case TargetClassName className: + case TargetClassName ignored: break; // NOP case TargetBlock block: { var localCounter = state.localCounter; diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index fb1ea80a..10f3452f 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -345,6 +345,8 @@ public class ASTToTargetAST { for (var pair : oldInput) { if (!referenced.contains(pair.getLeft())) { input.remove(pair); + if (pair instanceof PairTPHsmallerTPH ptph) + equality.put(ptph.left, ptph.right); for (var pair2 : oldInput) { if (pair2.getRight().equals(pair.getLeft())) { input.remove(pair2); @@ -565,7 +567,7 @@ public class ASTToTargetAST { Set convert(Set> result) { return result.stream().map(p -> { if (p instanceof PairTPHsmallerTPH pair) { - return new TargetGeneric(pair.left.getName(), new TargetGenericType(pair.right.getName())); + return new TargetGeneric(pair.left.getName(), convert(pair.right)); } else if (p instanceof PairTPHequalRefTypeOrWildcardType pair) { return new TargetGeneric(pair.left.getName(), convert(pair.right)); } else { @@ -576,13 +578,14 @@ public class ASTToTargetAST { public TargetClass convert(ClassOrInterface input) { currentClass = input; + var generics = sigma.generics(input); TargetBlock fieldInitializer = null; if (input.getfieldInitializations().isPresent()) fieldInitializer = convert(input.getfieldInitializations().get().block); TargetBlock finalFieldInitializer = fieldInitializer; return new TargetClass(input.getModifiers(), input.getClassName().toString(), convert(input.getSuperClass()), - convert(sigma.generics(input)), + convert(generics), input.getSuperInterfaces().stream().map(this::convert).toList(), input.getConstructors().stream().map(constructor -> this.convert(constructor, finalFieldInitializer)).flatMap(List::stream).toList(), input.getFieldDecl().stream().map(this::convert).toList(), diff --git a/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java b/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java index 8ca6e052..680a2140 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/StatementToTargetExpression.java @@ -79,7 +79,7 @@ public class StatementToTargetExpression implements StatementVisitor { }); result = new TargetLambdaExpression( - new TargetFunNType(parameters.size(), parameters.stream().map(MethodParameter::type).toList()), + converter.convert(lambdaExpression.getType()), captures, parameters, converter.convert(lambdaExpression.getReturnType()), converter.convert(lambdaExpression.methodBody) ); }