Bug 98 gefixt, kleine Aenderung in Signature Klasse und Tph4 Test eingefuegt
This commit is contained in:
parent
f3e60e50ef
commit
adf675e595
@ -323,9 +323,13 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
tphsInRel.put(tphsInRel.size(), superTph);
|
tphsInRel.put(tphsInRel.size(), superTph);
|
||||||
|
|
||||||
numOfVisitedPairs++;
|
numOfVisitedPairs++;
|
||||||
|
boolean isCycle = false;
|
||||||
while(subAndSuperTph.containsKey(superTph)) {
|
while(subAndSuperTph.containsKey(superTph)) {
|
||||||
superTph = subAndSuperTph.get(superTph);
|
superTph = subAndSuperTph.get(superTph);
|
||||||
|
if(tphsInRel.containsValue(superTph)) {
|
||||||
|
isCycle = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
tphsInRel.put(tphsInRel.size(), superTph);
|
tphsInRel.put(tphsInRel.size(), superTph);
|
||||||
numOfVisitedPairs++;
|
numOfVisitedPairs++;
|
||||||
}
|
}
|
||||||
@ -361,7 +365,8 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
// Y muss durch Object ersetzt.
|
// Y muss durch Object ersetzt.
|
||||||
|
|
||||||
// Zweite Operand für die Fälle wie in Lambda.jav (Paramtrisierte Typen)
|
// 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);
|
GenericInsertPair sPair = new GenericInsertPair(subTphRes, superTphRes);
|
||||||
simplifiedPairs.add(sPair);
|
simplifiedPairs.add(sPair);
|
||||||
}
|
}
|
||||||
|
@ -112,12 +112,10 @@ public class Signature {
|
|||||||
// z.B: Type = TPH K => wird eine Formal Type Parameter K$ erzeugt und Bound = Object
|
// z.B: Type = TPH K => wird eine Formal Type Parameter K$ erzeugt und Bound = Object
|
||||||
if(!isConstructor) {
|
if(!isConstructor) {
|
||||||
String ret = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToSignature());
|
String ret = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToSignature());
|
||||||
System.out.println("RET:::: " + ret);
|
|
||||||
if(!ret.equals("V")) {
|
if(!ret.equals("V")) {
|
||||||
// TODO TypeToSignature nochmal kontrollieren und schauen ob man dort wirklich
|
// TODO TypeToSignature nochmal kontrollieren und schauen ob man dort wirklich
|
||||||
// T... braucht und L ...
|
// T... braucht und L ...
|
||||||
if(ret.contains("$") && !ret.contains("$$")) {
|
if(ret.contains("$") && !ret.contains("$$")) {
|
||||||
// String g = ret.substring(4,ret.length())+"$";
|
|
||||||
if(genericsAndBounds.containsKey(ret)) {
|
if(genericsAndBounds.containsKey(ret)) {
|
||||||
genericsAndBoundsMethod.put(ret.substring(1), genericsAndBounds.get(ret.substring(1)));
|
genericsAndBoundsMethod.put(ret.substring(1), genericsAndBounds.get(ret.substring(1)));
|
||||||
}else {
|
}else {
|
||||||
@ -143,9 +141,7 @@ public class Signature {
|
|||||||
RefTypeOrTPHOrWildcardOrGeneric t = methodParamsAndTypes.get(paramName);
|
RefTypeOrTPHOrWildcardOrGeneric t = methodParamsAndTypes.get(paramName);
|
||||||
String pT = t.acceptTV(new TypeToSignature());
|
String pT = t.acceptTV(new TypeToSignature());
|
||||||
// S.o
|
// S.o
|
||||||
// if(pT.substring(0,4).equals("TPH ")) {
|
|
||||||
if(t instanceof TypePlaceholder) {
|
if(t instanceof TypePlaceholder) {
|
||||||
// String gP = pT.substring(4,pT.length())+"$";
|
|
||||||
String gP = t.acceptTV(new TypeToSignature());
|
String gP = t.acceptTV(new TypeToSignature());
|
||||||
if(!genericsAndBounds.containsKey(gP.substring(1)) && !genericsAndBoundsMethod.containsKey(gP.substring(1))) {
|
if(!genericsAndBounds.containsKey(gP.substring(1)) && !genericsAndBoundsMethod.containsKey(gP.substring(1))) {
|
||||||
sw.visitFormalTypeParameter(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())
|
// 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());
|
String sig2 = r.acceptTV(new TypeToSignature());
|
||||||
if(!(r instanceof TypePlaceholder)) {
|
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 {
|
} else {
|
||||||
System.out.println(r.getClass()+" Signature TPH: "+r.acceptTV(new TypeToSignature()));
|
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()));
|
sv.visitTypeVariable(sig2.substring(1, sig2.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class MatrixTest {
|
|||||||
//Matrix m3 = m1.mul(vv1);
|
//Matrix m3 = m1.mul(vv1);
|
||||||
Method mul = classToTest.getDeclaredMethod("mul", Vector.class);
|
Method mul = classToTest.getDeclaredMethod("mul", Vector.class);
|
||||||
Object result = mul.invoke(instanceOfClass_m1, instanceOfClass_m2);
|
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<Vector<Integer>> res = new Vector<Vector<Integer>>();
|
||||||
Vector<Integer> v5 = new Vector<Integer> ();
|
Vector<Integer> v5 = new Vector<Integer> ();
|
||||||
|
@ -30,7 +30,7 @@ public class Tph3Test {
|
|||||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||||
compiler.generateBytecode(pathToClassFile);
|
compiler.generateBytecode(pathToClassFile);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
classToTest = loader.loadClass("Tph2");
|
classToTest = loader.loadClass("Tph3");
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
test/bytecode/javFiles/Tph4.jav
Normal file
12
test/bytecode/javFiles/Tph4.jav
Normal 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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user