|
|
@ -115,6 +115,10 @@ public class VarType { // TODO: optimize switch |
|
|
|
return v; |
|
|
|
return v; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isFalseBoolean() { |
|
|
|
|
|
|
|
return (convinfo & VarType.FALSEBOOLEAN) != 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean isSuperset(VarType val) { |
|
|
|
public boolean isSuperset(VarType val) { |
|
|
|
|
|
|
|
|
|
|
|
return this.equals(val) || this.isStrictSuperset(val); |
|
|
|
return this.equals(val) || this.isStrictSuperset(val); |
|
|
@ -165,6 +169,10 @@ public class VarType { // TODO: optimize switch |
|
|
|
// type1 and type2 must not be null
|
|
|
|
// type1 and type2 must not be null
|
|
|
|
public static VarType getCommonMinType(VarType type1, VarType type2) { |
|
|
|
public static VarType getCommonMinType(VarType type1, VarType type2) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(type1.type == CodeConstants.TYPE_BOOLEAN && type2.type == CodeConstants.TYPE_BOOLEAN) { // special case booleans
|
|
|
|
|
|
|
|
return type1.isFalseBoolean() ? type2 : type1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(type1.isSuperset(type2)) { |
|
|
|
if(type1.isSuperset(type2)) { |
|
|
|
return type2; |
|
|
|
return type2; |
|
|
|
} else if(type2.isSuperset(type1)) { |
|
|
|
} else if(type2.isSuperset(type1)) { |
|
|
@ -189,6 +197,10 @@ public class VarType { // TODO: optimize switch |
|
|
|
// type1 and type2 must not be null
|
|
|
|
// type1 and type2 must not be null
|
|
|
|
public static VarType getCommonSupertype(VarType type1, VarType type2) { |
|
|
|
public static VarType getCommonSupertype(VarType type1, VarType type2) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(type1.type == CodeConstants.TYPE_BOOLEAN && type2.type == CodeConstants.TYPE_BOOLEAN) { // special case booleans
|
|
|
|
|
|
|
|
return type1.isFalseBoolean() ? type1 : type2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(type1.isSuperset(type2)) { |
|
|
|
if(type1.isSuperset(type2)) { |
|
|
|
return type1; |
|
|
|
return type1; |
|
|
|
} else if(type2.isSuperset(type1)) { |
|
|
|
} else if(type2.isSuperset(type1)) { |
|
|
@ -232,12 +244,17 @@ public class VarType { // TODO: optimize switch |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean equals(Object o) { |
|
|
|
public boolean equals(Object o) { |
|
|
|
if(o == this) return true; |
|
|
|
|
|
|
|
if(o == null || !(o instanceof VarType)) return false; |
|
|
|
if(o == this) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(o == null || !(o instanceof VarType)) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
VarType vt = (VarType) o; |
|
|
|
VarType vt = (VarType) o; |
|
|
|
return type == vt.type && arraydim == vt.arraydim && |
|
|
|
return type == vt.type && arraydim == vt.arraydim && InterpreterUtil.equalObjects(value, vt.value); |
|
|
|
InterpreterUtil.equalObjects(value, vt.value); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void parseTypeString(String strtype, boolean cltype) { |
|
|
|
private void parseTypeString(String strtype, boolean cltype) { |
|
|
|