Merge branch 'bytecode2' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into bytecode2

This commit is contained in:
Fayez Abu Alia 2018-08-06 14:47:26 +02:00
commit dc535ad9b7
3 changed files with 23 additions and 2 deletions

View File

@ -17,6 +17,7 @@ import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.Block; import de.dhbwstuttgart.syntaxtree.statement.Block;
import de.dhbwstuttgart.syntaxtree.statement.Statement; import de.dhbwstuttgart.syntaxtree.statement.Statement;
import de.dhbwstuttgart.syntaxtree.type.WildcardType;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
/** /**
@ -201,8 +202,19 @@ public class ASTFactory {
//Diese entfernen: //Diese entfernen:
name = name.split("<")[0]; name = name.split("<")[0];
} }
RefType ret = new RefType(new JavaClassName(name), params, new NullToken()); if(type instanceof java.lang.reflect.WildcardType){
return ret; java.lang.reflect.WildcardType wildcardType = (java.lang.reflect.WildcardType) type;
if(wildcardType.getLowerBounds().length > 0){
return new SuperWildcardType(convertType(wildcardType.getLowerBounds()[0]), new NullToken());
}else if(wildcardType.getUpperBounds().length > 0){
return new ExtendsWildcardType(convertType(wildcardType.getUpperBounds()[0]), new NullToken());
}else{//Es handelt sich um den '?'-Typ:
return new ExtendsWildcardType(createObjectType(), new NullToken());
}
}else{
RefType ret = new RefType(new JavaClassName(name), params, new NullToken());
return ret;
}
} }
} }

View File

@ -34,6 +34,10 @@ public class ExtendsWildcardType extends WildcardType{
return false; return false;
} }
@Override
public String toString() {
return "? extends "+innerType.toString();
}
@Override @Override
public void accept(ASTVisitor visitor) { public void accept(ASTVisitor visitor) {

View File

@ -35,6 +35,11 @@ public class SuperWildcardType extends WildcardType{
return this.innerType; return this.innerType;
} }
@Override
public String toString() {
return "? super "+innerType.toString();
}
@Override @Override
public boolean isExtends() { public boolean isExtends() {
return false; return false;