modified: ../../../main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java
modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java Generische Typvariablen im Unify durch Tag im ReferenceType eingefuehrt
This commit is contained in:
parent
6a2a8313e6
commit
1edc023ed9
@ -225,12 +225,15 @@ public class UnifyTypeFactory {
|
|||||||
return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (RefType) tr);
|
return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (RefType) tr);
|
||||||
}else if(tr instanceof WildcardType){
|
}else if(tr instanceof WildcardType){
|
||||||
return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (WildcardType) tr);
|
return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (WildcardType) tr);
|
||||||
|
}else if(tr instanceof GenericRefType){
|
||||||
|
return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (GenericRefType) tr);
|
||||||
}else throw new NotImplementedException();
|
}else throw new NotImplementedException();
|
||||||
}else throw new NotImplementedException();
|
}else throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RefTypeOrTPHOrWildcardOrGeneric convert(ReferenceType t, Map<String,TypePlaceholder> tphs) {
|
public static RefTypeOrTPHOrWildcardOrGeneric convert(ReferenceType t, Map<String,TypePlaceholder> tphs) {
|
||||||
if(JavaClassName.Void.equals(t.getName()))return new Void(new NullToken());
|
if(JavaClassName.Void.equals(t.getName()))return new Void(new NullToken());
|
||||||
|
if (t.isGenTypeVar()) return new GenericRefType(t.getName(),new NullToken());
|
||||||
RefType ret = new RefType(new JavaClassName(t.getName()),convert(t.getTypeParams(), tphs),new NullToken());
|
RefType ret = new RefType(new JavaClassName(t.getName()),convert(t.getTypeParams(), tphs),new NullToken());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -11,26 +11,43 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor;
|
|||||||
* @author Florian Steurer
|
* @author Florian Steurer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class ReferenceType extends UnifyType {
|
public class ReferenceType extends UnifyType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The buffered hashCode
|
* The buffered hashCode
|
||||||
*/
|
*/
|
||||||
private final int hashCode;
|
private final int hashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gibt an, ob der ReferenceType eine generische Typvariable ist
|
||||||
|
*/
|
||||||
|
private final boolean genericTypeVar;
|
||||||
|
|
||||||
|
|
||||||
public <T> UnifyType accept(UnifyTypeVisitor<T> visitor, T ht) {
|
public <T> UnifyType accept(UnifyTypeVisitor<T> visitor, T ht) {
|
||||||
return visitor.visit(this, ht);
|
return visitor.visit(this, ht);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ReferenceType(String name) {
|
||||||
|
super(name, new TypeParams());
|
||||||
|
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
||||||
|
genericTypeVar = true;
|
||||||
|
}
|
||||||
|
|
||||||
public ReferenceType(String name, UnifyType... params) {
|
public ReferenceType(String name, UnifyType... params) {
|
||||||
super(name, new TypeParams(params));
|
super(name, new TypeParams(params));
|
||||||
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
||||||
|
genericTypeVar = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReferenceType(String name, TypeParams params) {
|
public ReferenceType(String name, TypeParams params) {
|
||||||
super(name, params);
|
super(name, params);
|
||||||
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
||||||
|
genericTypeVar = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGenTypeVar () {
|
||||||
|
return genericTypeVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package bytecode;
|
package bytecode;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
public class Id {
|
public class Id {
|
||||||
|
|
||||||
id(b){
|
<A> id(A b){
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user