Fix yTest
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 4m45s
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 4m45s
This commit is contained in:
parent
7037bdf9ef
commit
a654f55deb
@ -1,11 +1,13 @@
|
||||
package de.dhbwstuttgart.bytecode;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Break;
|
||||
import de.dhbwstuttgart.target.tree.TargetGeneric;
|
||||
import de.dhbwstuttgart.target.tree.type.*;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import java.sql.Array;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@ -35,19 +37,33 @@ public class FunNGenerator {
|
||||
public List<TargetType> parameters = new ArrayList<>();
|
||||
final String descriptor;
|
||||
public final List<TargetType> inParams;
|
||||
public final List<TargetType> realParams;
|
||||
|
||||
public GenericParameters(List<TargetType> params, int numReturns) {
|
||||
this.inParams = params;
|
||||
this.realParams = params;
|
||||
this.inParams = flattenTypeParams(params);
|
||||
var type = new TargetRefType(FunNGenerator.getSuperClassName(params.size() - 1, numReturns), params);
|
||||
descriptor = applyDescriptor(type, this);
|
||||
}
|
||||
|
||||
private static List<TargetType> flattenTypeParams(List<TargetType> params) {
|
||||
var res = new ArrayList<TargetType>();
|
||||
for (var param : params) {
|
||||
if (param instanceof TargetSpecializedType tspec) {
|
||||
res.addAll(flattenTypeParams(tspec.params()));
|
||||
} else {
|
||||
res.add(param);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public TargetType getReturnType() {
|
||||
return FunNGenerator.getReturnType(inParams);
|
||||
return FunNGenerator.getReturnType(realParams);
|
||||
}
|
||||
|
||||
public List<TargetType> getArguments() {
|
||||
return FunNGenerator.getArguments(inParams);
|
||||
return FunNGenerator.getArguments(realParams);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,7 +178,7 @@ public class FunNGenerator {
|
||||
}
|
||||
|
||||
public static String getSpecializedClassName(GenericParameters gep) {
|
||||
return getSpecializedClassName(getArguments(gep.inParams), getReturnType(gep.inParams));
|
||||
return getSpecializedClassName(gep.getArguments(), gep.getReturnType());
|
||||
}
|
||||
|
||||
public static String getSpecializedClassName(List<TargetType> argumentTypes, TargetType returnType) {
|
||||
|
@ -34,6 +34,7 @@ public class ASTFactory {
|
||||
private static final HashMap<java.lang.Class, ClassOrInterface> cache = new HashMap<>();
|
||||
|
||||
public static ClassOrInterface createClass(java.lang.Class jreClass) {
|
||||
System.out.println(jreClass);
|
||||
if (cache.containsKey(jreClass))
|
||||
return cache.get(jreClass);
|
||||
|
||||
@ -173,6 +174,7 @@ public class ASTFactory {
|
||||
superClass = (RefType) createType(java.lang.Object.class);
|
||||
}
|
||||
List<RefType> implementedInterfaces = new ArrayList<>();
|
||||
System.out.println(jreClass);
|
||||
for (Type jreInterface : jreClass.getGenericInterfaces()) {
|
||||
implementedInterfaces.add((RefType) createType(jreInterface));
|
||||
}
|
||||
|
@ -652,14 +652,12 @@ public abstract class GenerateGenerics {
|
||||
}
|
||||
|
||||
void normalize(Set<Pair> result, Set<Pair> classGenerics, Set<TPH> usedTphs) {
|
||||
outer:
|
||||
for (var tph : usedTphs) {
|
||||
for (var p1 : new HashSet<>(result)) {
|
||||
if (p1 instanceof PairLT ptph && ptph.left.equals(ptph.right))
|
||||
if (p1 instanceof PairLT ptph && ptph.left.resolve().equals(ptph.right.resolve()))
|
||||
result.remove(p1); // TODO This is a bit strange
|
||||
if (p1.left.equals(tph)) continue outer;
|
||||
}
|
||||
|
||||
for (var tph : usedTphs) {
|
||||
if (classGenerics == null || classGenerics.stream().noneMatch((pair) -> pair.left.equals(tph)))
|
||||
addToPairs(result, new PairEQ(tph, ASTToTargetAST.OBJECT));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user