Fix Tph2
This commit is contained in:
parent
b0c1d5d96d
commit
5503f3723c
@ -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;
|
||||
|
@ -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<TargetGeneric> convert(Set<ResultPair<?, ?>> 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(),
|
||||
|
@ -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)
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user