TPHs, die nicht in ParameterListe der Methode vorkommen, werden in Signature geschrieben

This commit is contained in:
Fayez Abu Alia 2018-06-19 14:56:22 +02:00
parent 162ca3eb27
commit 23eab0c9a4
2 changed files with 33 additions and 4 deletions

View File

@ -283,12 +283,16 @@ public class BytecodeGen implements ASTVisitor {
break;
}
}
HashMap<TypePlaceholder, TypePlaceholder> subAndSuperTph = new HashMap<>();
for(GenericInsertPair p : allPairs) {
// Tph2.jav
if(subAndSuperTph.containsKey(p.TA1)) {
if(methodTphs.contains(subAndSuperTph.get(p.TA1)))
continue;
}
subAndSuperTph.put(p.TA1, p.TA2);
}
int numOfVisitedPairs = 0;
for(TypePlaceholder subTph: subAndSuperTph.keySet()) {
@ -320,7 +324,6 @@ public class BytecodeGen implements ASTVisitor {
TypePlaceholder subTphRes = tphsInRel.get(0);
// Die größte Supertype
TypePlaceholder superTphRes = tphsInRel.get(tphsInRel.size()-1);
int i = 2;
while(!methodTphs.contains(superTphRes) && (tphsInRel.size()-i) >0) {
superTphRes = tphsInRel.get(tphsInRel.size()-i);
@ -330,7 +333,6 @@ public class BytecodeGen implements ASTVisitor {
GenericInsertPair sPair = new GenericInsertPair(subTphRes, superTphRes);
simplifiedPairs.add(sPair);
}
return simplifiedPairs;
}

View File

@ -147,6 +147,33 @@ public class Signature {
}
}
for(GenericInsertPair p:methodPairs) {
String name = p.TA1.getName()+"$";
if(!genericsAndBoundsMethod.containsKey(name)) {
sw.visitFormalTypeParameter(name);
sw.visitClassBound().visitTypeVariable(p.TA2.getName()+"$");
genericsAndBoundsMethod.put(name, p.TA2.getName()+"$");
}
}
ArrayList<TypePlaceholder> types = new ArrayList<>();
ArrayList<TypePlaceholder> superTypes = new ArrayList<>();
for(GenericInsertPair p : methodPairs) {
types.add(p.TA1);
superTypes.add(p.TA2);
}
for(GenericInsertPair p : methodPairs) {
String name = p.TA2.getName()+"$";
if(!types.contains(p.TA2) && !genericsAndBoundsMethod.containsKey(name)) {
String bound = Type.getInternalName(Object.class);
sw.visitFormalTypeParameter(name);
sw.visitClassBound().visitClassType(bound);
genericsAndBoundsMethod.put(name, bound);
sw.visitClassBound().visitEnd();
}
}
}
// visit each method-parameter to create the signature