Package it.unive.lisa.type
Interface Type
-
- All Known Subinterfaces:
ArrayType,BooleanType,NumericType,PointerType,StringType,UnitType
- All Known Implementing Classes:
BoolType,IntType,NullType,StringType,TypeTokenType,Untyped,VoidType
public interface TypeType interface. Any instance of a concrete type, instance of Type, should be unique and implemented following the singleton design pattern (see for instanceUntypedclass).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Collection<Type>allInstances()Yields all possible instances of this type, including itself.default ArrayTypeasArrayType()default BooleanTypeasBooleanType()default NullTypeasNullType()default NumericTypeasNumericType()default PointerTypeasPointerType()default StringTypeasStringType()default TypeTokenTypeasTypeTokenType()default UnitTypeasUnitType()default UntypedasUntyped()default VoidTypeasVoidType()booleancanBeAssignedTo(Type other)Determines if the type represented by thisTypeobject is either the same as, or is a subtype of, the type represented byother.TypecommonSupertype(Type other)Yields the most specific common supertype between thisTypeand the given one.default booleanisArrayType()Yieldstrueif and only if this type is an instance ofArrayType.default booleanisBooleanType()Yieldstrueif and only if this type is an instance ofBooleanType.default booleanisNullType()Yieldstrueif and only if this type is an instance ofNullType.default booleanisNumericType()Yieldstrueif and only if this type is an instance ofNumericType.default booleanisPointerType()Yieldstrueif and only if this type is an instance ofPointerType.default booleanisStringType()Yieldstrueif and only if this type is an instance ofStringType.default booleanisTypeTokenType()Yieldstrueif and only if this type is an instance ofTypeTokenType.default booleanisUnitType()Yieldstrueif and only if this type is an instance ofUnitType.default booleanisUntyped()Yieldstrueif and only if this type is an instance ofUntyped.default booleanisVoidType()Yieldstrueif and only if this type is an instance ofVoidType.
-
-
-
Method Detail
-
isNumericType
default boolean isNumericType()
Yieldstrueif and only if this type is an instance ofNumericType.- Returns:
trueif that condition holds
-
asNumericType
default NumericType asNumericType()
Returns this type casted as aNumericType, only ifisNumericType()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
NumericType, ornull
-
isBooleanType
default boolean isBooleanType()
Yieldstrueif and only if this type is an instance ofBooleanType.- Returns:
trueif that condition holds
-
asBooleanType
default BooleanType asBooleanType()
Returns this type casted as aBooleanType, only ifisBooleanType()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
BooleanType, ornull
-
isStringType
default boolean isStringType()
Yieldstrueif and only if this type is an instance ofStringType.- Returns:
trueif that condition holds
-
asStringType
default StringType asStringType()
Returns this type casted as aStringType, only ifisStringType()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
StringType, ornull
-
isUntyped
default boolean isUntyped()
Yieldstrueif and only if this type is an instance ofUntyped.- Returns:
trueif that condition holds
-
asUntyped
default Untyped asUntyped()
Returns this type casted as anUntyped, only ifisUntyped()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
Untyped, ornull
-
isVoidType
default boolean isVoidType()
Yieldstrueif and only if this type is an instance ofVoidType.- Returns:
trueif that condition holds
-
asVoidType
default VoidType asVoidType()
Returns this type casted as aVoidType, only ifisVoidType()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
VoidType, ornull
-
isPointerType
default boolean isPointerType()
Yieldstrueif and only if this type is an instance ofPointerType.- Returns:
trueif that condition holds
-
asPointerType
default PointerType asPointerType()
Returns this type casted as aPointerType, only ifisPointerType()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
PointerType, ornull
-
isArrayType
default boolean isArrayType()
Yieldstrueif and only if this type is an instance ofArrayType.- Returns:
trueif that condition holds
-
asArrayType
default ArrayType asArrayType()
Returns this type casted as aArrayType, only ifisArrayType()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
ArrayType, ornull
-
isNullType
default boolean isNullType()
Yieldstrueif and only if this type is an instance ofNullType.- Returns:
trueif that condition holds
-
asNullType
default NullType asNullType()
Returns this type casted as aNullType, only ifisNullType()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
NullType, ornull
-
isUnitType
default boolean isUnitType()
Yieldstrueif and only if this type is an instance ofUnitType.- Returns:
trueif that condition holds
-
asUnitType
default UnitType asUnitType()
Returns this type casted as aUnitType, only ifisUnitType()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
UnitType, ornull
-
isTypeTokenType
default boolean isTypeTokenType()
Yieldstrueif and only if this type is an instance ofTypeTokenType.- Returns:
trueif that condition holds
-
asTypeTokenType
default TypeTokenType asTypeTokenType()
Returns this type casted as aTypeTokenType, only ifisTypeTokenType()yieldstrue. Otherwise, this method returnsnull.- Returns:
- this type casted as
TypeTokenType, ornull
-
canBeAssignedTo
boolean canBeAssignedTo(Type other)
Determines if the type represented by thisTypeobject is either the same as, or is a subtype of, the type represented byother. It returnstrueif so, and returnsfalseotherwise.- Parameters:
other- the other type- Returns:
trueif that condition holds
-
commonSupertype
Type commonSupertype(Type other)
Yields the most specific common supertype between thisTypeand the given one. If no common supertype exists, this method returnsUntyped.INSTANCE.- Parameters:
other- the other type- Returns:
- the most specific common supertype between
thisandother
-
allInstances
java.util.Collection<Type> allInstances()
Yields all possible instances of this type, including itself.- Returns:
- the possible instances
-
-