modified: src/de/dhbwstuttgart/bytecode/BytecodeGen.java

modified:   src/de/dhbwstuttgart/bytecode/signature/Signature.java
	modified:   src/de/dhbwstuttgart/bytecode/signature/TypeToSignature.java
	modified:   test/bytecode/javFiles/Merge.jav
	modified:   test/bytecode/javFiles/OL.jav
	modified:   test/bytecode/javFiles/Tph.jav
	modified:   test/bytecode/javFiles/Tph3.jav
	new file:   test/bytecode/javFiles/WC.jav
This commit is contained in:
Fayez Abu Alia 2018-08-13 18:28:41 +02:00
parent 7d9976e638
commit 77d397fc53
8 changed files with 64 additions and 17 deletions

View File

@ -247,7 +247,6 @@ public class BytecodeGen implements ASTVisitor {
}
}
}
//TODO: Test if the return-type or any of the parameter is a parameterized type. (VP)
//then create the descriptor with the new syntax.

View File

@ -19,6 +19,7 @@ import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.syntaxtree.type.WildcardType;
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
@ -442,6 +443,42 @@ public class Signature {
sv.visitTypeVariable(sig2.substring(1, sig2.length()));
}
break;
case "SWC":
System.out.println("SWC---Signature");
SuperWildcardType swc = (SuperWildcardType) t;
String sigInner = swc.getInnerType().acceptTV(new TypeToSignature());
if(swc.getInnerType() instanceof TypePlaceholder) {
sv.visitTypeArgument('-').visitTypeVariable(sigInner.substring(1, sigInner.length()));
} else if(swc.getInnerType() instanceof RefType) {
if(sigInner.contains("$$")) {
sv.visitTypeArgument('-').visitInterface().visitClassType(sigInner.substring(1,sigInner.length()));
}else {
sv.visitTypeArgument('-').visitClassType(sigInner.substring(1,sigInner.length()));
}
}else {
sv.visitTypeArgument('-').visitTypeVariable(sigInner.substring(1));
}
break;
case "EWC":
System.out.println("EWC---Signature");
SuperWildcardType ewc = (SuperWildcardType) t;
String esigInner = ewc.getInnerType().acceptTV(new TypeToSignature());
if(ewc.getInnerType() instanceof TypePlaceholder) {
sv.visitTypeArgument('+').visitTypeVariable(esigInner.substring(1, esigInner.length()));
} else if(ewc.getInnerType() instanceof RefType) {
if(esigInner.contains("$$")) {
sv.visitTypeArgument('+').visitInterface().visitClassType(esigInner.substring(1,esigInner.length()));
}else {
sv.visitTypeArgument('+').visitClassType(esigInner.substring(1,esigInner.length()));
}
}else {
sv.visitTypeArgument('+').visitTypeVariable(esigInner.substring(1));
}
break;
default:
if(!isParameterType)

View File

@ -48,7 +48,7 @@ public class TypeToSignature implements TypeVisitor<String> {
@Override
public String visit(SuperWildcardType superWildcardType) {
// throw new NotImplementedException();
return "+" + superWildcardType.getInnerType().acceptTV(new TypeToSignature());
return "-" + superWildcardType.getInnerType().acceptTV(new TypeToSignature());
}
@Override
@ -60,7 +60,7 @@ public class TypeToSignature implements TypeVisitor<String> {
@Override
public String visit(ExtendsWildcardType extendsWildcardType) {
// throw new NotImplementedException();
return "-" + extendsWildcardType.getInnerType().acceptTV(new TypeToSignature());
return "+" + extendsWildcardType.getInnerType().acceptTV(new TypeToSignature());
}
@Override

View File

@ -10,11 +10,11 @@ class Merge {
}
/*
sort(in){
var firstHalf = in.subList(1,2);
var secondHalf = in.subList(1,2);
return merge(sort(firstHalf), sort(secondHalf));
}
*/
}

View File

@ -14,7 +14,7 @@ public class OL {
public class OLMain {
main(java.lang.Integer x) {
main(x) {
var ol;
ol = new OL();
return ol.m(x);

View File

@ -1,9 +1,9 @@
public class Tph {
m(a,b){
// var c = m2(b);
// return c;
return m2(b);
var c = m2(b);
return c;
// return m2(b);
}
m2(b){

View File

@ -1,10 +1,13 @@
public class Tph3 {
m(a,b){
var c = m2(a,b);
return c;
}
m2(a,b){
return m(a,b);
}
// m(a,b){
// var c = m2(a,b);
// return c;
// }
//
// m2(a,b){
// return m(a,b);
// }
m1(x, y) { m2(x); x = y; }
m2(y) { m1(y, y); }
}

View File

@ -0,0 +1,8 @@
import java.lang.Integer;
import java.util.List;
public class WC {
void m (List<? super Integer> a, List<? extends Integer> b) {
}
}