Bug 98 gefixt, kleine Aenderung in Signature Klasse und Tph4 Test eingefuegt

This commit is contained in:
Fayez Abu Alia 2018-07-25 16:45:59 +02:00
parent f3e60e50ef
commit adf675e595
5 changed files with 26 additions and 13 deletions

View File

@ -323,9 +323,13 @@ public class BytecodeGen implements ASTVisitor {
tphsInRel.put(tphsInRel.size(), superTph);
numOfVisitedPairs++;
boolean isCycle = false;
while(subAndSuperTph.containsKey(superTph)) {
superTph = subAndSuperTph.get(superTph);
if(tphsInRel.containsValue(superTph)) {
isCycle = true;
break;
}
tphsInRel.put(tphsInRel.size(), superTph);
numOfVisitedPairs++;
}
@ -361,7 +365,8 @@ public class BytecodeGen implements ASTVisitor {
// Y muss durch Object ersetzt.
// Zweite Operand für die Fälle wie in Lambda.jav (Paramtrisierte Typen)
if(methodTphs.contains(superTphRes) || !tphExtractor.allTPHS.containsKey(superTphRes)) {
if((methodTphs.contains(superTphRes) || !tphExtractor.allTPHS.containsKey(superTphRes))
&& !subTphRes.equals(superTphRes)) {
GenericInsertPair sPair = new GenericInsertPair(subTphRes, superTphRes);
simplifiedPairs.add(sPair);
}

View File

@ -112,12 +112,10 @@ public class Signature {
// z.B: Type = TPH K => wird eine Formal Type Parameter K$ erzeugt und Bound = Object
if(!isConstructor) {
String ret = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToSignature());
System.out.println("RET:::: " + ret);
if(!ret.equals("V")) {
// TODO TypeToSignature nochmal kontrollieren und schauen ob man dort wirklich
// T... braucht und L ...
if(ret.contains("$") && !ret.contains("$$")) {
// String g = ret.substring(4,ret.length())+"$";
if(genericsAndBounds.containsKey(ret)) {
genericsAndBoundsMethod.put(ret.substring(1), genericsAndBounds.get(ret.substring(1)));
}else {
@ -143,9 +141,7 @@ public class Signature {
RefTypeOrTPHOrWildcardOrGeneric t = methodParamsAndTypes.get(paramName);
String pT = t.acceptTV(new TypeToSignature());
// S.o
// if(pT.substring(0,4).equals("TPH ")) {
if(t instanceof TypePlaceholder) {
// String gP = pT.substring(4,pT.length())+"$";
String gP = t.acceptTV(new TypeToSignature());
if(!genericsAndBounds.containsKey(gP.substring(1)) && !genericsAndBoundsMethod.containsKey(gP.substring(1))) {
sw.visitFormalTypeParameter(gP.substring(1));
@ -393,16 +389,16 @@ public class Signature {
// das braucht man nicht es reicht: sv.visitTypeVariable(r.acceptTV(new TypeToSignature())
//
// if(!r.acceptTV(new TypeToSignature()).substring(0, 4).equals("TPH ")) {
String sig2 = r.acceptTV(new TypeToSignature());
if(!(r instanceof TypePlaceholder)) {
if(sig2.contains("$$")) {
sv.visitInterface().visitClassType(sig2.substring(1, sig2.length()));
} else {
sv.visitClassType(sig2.substring(1, sig2.length()));
}
// sv.visitInterface().visitClassType(r.acceptTV(new TypeToSignature()));
// sv.visitClassType(r.acceptTV(new TypeToSignature()));
sv.visitClassType(sig2.substring(1, sig2.length()));
} else {
System.out.println(r.getClass()+" Signature TPH: "+r.acceptTV(new TypeToSignature()));
// sv.visitTypeVariable(r.acceptTV(new TypeToSignature()).substring(4)+"$");
sv.visitTypeVariable(sig2.substring(1, sig2.length()));
}

View File

@ -69,7 +69,7 @@ public class MatrixTest {
//Matrix m3 = m1.mul(vv1);
Method mul = classToTest.getDeclaredMethod("mul", Vector.class);
Object result = mul.invoke(instanceOfClass_m1, instanceOfClass_m2);
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m1.toString() + " = " + result.toString());
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
Vector<Vector<Integer>> res = new Vector<Vector<Integer>>();
Vector<Integer> v5 = new Vector<Integer> ();

View File

@ -30,7 +30,7 @@ public class Tph3Test {
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Tph2");
classToTest = loader.loadClass("Tph3");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
}

View File

@ -0,0 +1,12 @@
public class Tph4{
m(a,b){
var c = m2(b);
var d = m2(c);
return a;
}
m2(b){
return b
}
}