public abstract class Type_c extends TypeObject_c implements Type
Type
. This implements most of
the "isa" and "cast" methods of the type and methods which just dispatch to
the type system.position, ts
Modifier | Constructor and Description |
---|---|
protected |
Type_c()
Used for deserializing types.
|
|
Type_c(TypeSystem ts)
Creates a new type in the given a TypeSystem.
|
|
Type_c(TypeSystem ts,
Position pos)
Creates a new type in the given a TypeSystem at a given position.
|
Modifier and Type | Method and Description |
---|---|
ArrayType |
arrayOf()
Return an array of this type.
|
ArrayType |
arrayOf(int dims)
Return a
dims -array of this type. |
boolean |
descendsFrom(Type ancestor)
Return true if this type descends from
ancestor . |
boolean |
descendsFromImpl(Type ancestor)
Return true if this type descends from
ancestor . |
boolean |
isArray()
Return true if an array type.
|
boolean |
isBoolean()
Return true if boolean.
|
boolean |
isByte()
Return true if byte.
|
boolean |
isCanonical()
Return true if the type object contains no unknown/ambiguous types.
|
boolean |
isCastValid(Type toType)
Return true if this type can be cast to
toType . |
boolean |
isCastValidImpl(Type toType)
Return true if this type can be cast to
toType . |
boolean |
isChar()
Return true if char.
|
boolean |
isClass()
Return true if a class type.
|
boolean |
isComparable(Type t)
Return true if the types can be compared; that is, if they have
the same type system.
|
boolean |
isDouble()
Return true if double.
|
boolean |
isFloat()
Return true if float.
|
boolean |
isImplicitCastValid(Type toType)
Return true if a value of this type can be assigned to a variable of
type
toType . |
boolean |
isImplicitCastValidImpl(Type toType)
Return true if a value of this type can be assigned to a variable of
type
toType . |
boolean |
isInt()
Return true if int.
|
boolean |
isIntOrLess()
Return true if int, short, byte, or char.
|
boolean |
isLong()
Return true if long.
|
boolean |
isLongOrLess()
Return true if long, int, short, byte, or char.
|
boolean |
isNull()
Return true if a null type.
|
boolean |
isNumeric()
Return true if double, float, long, int, short, byte, or char.
|
boolean |
isPackage()
Return true if the qualifier is a package.
|
boolean |
isPrimitive()
Return true if a primitive type.
|
boolean |
isReference()
Return true if a reference type.
|
boolean |
isShort()
Return true if short.
|
boolean |
isSubtype(Type ancestor)
Return true if this type is a subtype of
ancestor . |
boolean |
isSubtypeImpl(Type ancestor)
Return true if this type is a subtype of
ancestor . |
boolean |
isThrowable()
Return true if a subclass of
Throwable . |
boolean |
isType()
Return true if the qualifier is a type.
|
boolean |
isUncheckedException()
Return true if an unchecked exception.
|
boolean |
isVoid()
Return true if void.
|
boolean |
numericConversionValid(long value)
Deprecated.
|
boolean |
numericConversionValid(java.lang.Object value)
Return true a literal
value can be converted to this type. |
boolean |
numericConversionValidImpl(long value)
Deprecated.
|
boolean |
numericConversionValidImpl(java.lang.Object value)
Return true a literal
value can be converted to this type. |
void |
print(CodeWriter w)
Output a compilable representation of this type to
w . |
ArrayType |
toArray()
Cast the type to an array type, or null.
|
ClassType |
toClass()
Cast the type to a class type, or null.
|
NullType |
toNull()
Cast the type to a null type, or null.
|
Package |
toPackage()
Cast the qualifier to a package, or return null.
|
PrimitiveType |
toPrimitive()
Cast the type to a primitive type, or null.
|
ReferenceType |
toReference()
Cast the type to a reference type, or null.
|
abstract java.lang.String |
toString()
Yields a string representing this type.
|
Type |
toType()
Cast the qualifier to a type, or return null.
|
abstract java.lang.String |
translate(Resolver c)
Return a string into which to translate the type.
|
boolean |
typeEquals(Type t)
Return true if this type is equivalent to t.
|
boolean |
typeEqualsImpl(Type t)
Return true if this type is equivalent to t.
|
copy, equals, equalsImpl, hashCode, position, typeSystem
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
equalsImpl, position, typeSystem
protected Type_c()
public Type_c(TypeSystem ts)
public Type_c(TypeSystem ts, Position pos)
public abstract java.lang.String translate(Resolver c)
Type
public boolean isType()
Qualifier
public boolean isPackage()
Qualifier
public Type toType()
Qualifier
public Package toPackage()
Qualifier
public boolean isCanonical()
TypeObject
isCanonical
in interface TypeObject
public boolean isPrimitive()
Type
isPrimitive
in interface Type
public boolean isNumeric()
Type
public boolean isIntOrLess()
Type
isIntOrLess
in interface Type
public boolean isLongOrLess()
Type
isLongOrLess
in interface Type
public boolean isVoid()
Type
public boolean isBoolean()
Type
public boolean isChar()
Type
public boolean isByte()
Type
public boolean isShort()
Type
public boolean isInt()
Type
public boolean isLong()
Type
public boolean isFloat()
Type
public boolean isDouble()
Type
public boolean isReference()
Type
isReference
in interface Type
public boolean isNull()
Type
public boolean isClass()
Type
public boolean isArray()
Type
public boolean isThrowable()
Type
Throwable
.isThrowable
in interface Type
public boolean isUncheckedException()
Type
isUncheckedException
in interface Type
public ClassType toClass()
Type
public NullType toNull()
Type
public ReferenceType toReference()
Type
toReference
in interface Type
isReference()
returns true.public PrimitiveType toPrimitive()
Type
toPrimitive
in interface Type
isPrimitive()
returns true.public ArrayType toArray()
Type
public ArrayType arrayOf(int dims)
Type
dims
-array of this type.public ArrayType arrayOf()
Type
public final boolean typeEquals(Type t)
Type
typeEquals
in interface Type
t
- Type to compare topublic boolean typeEqualsImpl(Type t)
Type
typeEqualsImpl
in interface Type
t
- Type to compare topublic final boolean isSubtype(Type ancestor)
Type
ancestor
.public boolean isSubtypeImpl(Type ancestor)
Type
ancestor
.isSubtypeImpl
in interface Type
public final boolean descendsFrom(Type ancestor)
Type
ancestor
.descendsFrom
in interface Type
public boolean descendsFromImpl(Type ancestor)
Type
ancestor
.descendsFromImpl
in interface Type
public final boolean isCastValid(Type toType)
Type
toType
.isCastValid
in interface Type
public boolean isCastValidImpl(Type toType)
Type
toType
.isCastValidImpl
in interface Type
public final boolean isImplicitCastValid(Type toType)
Type
toType
.isImplicitCastValid
in interface Type
public boolean isImplicitCastValidImpl(Type toType)
Type
toType
.isImplicitCastValidImpl
in interface Type
@Deprecated public final boolean numericConversionValid(long value)
Type
value
can be converted to this type.numericConversionValid
in interface Type
@Deprecated public boolean numericConversionValidImpl(long value)
Type
value
can be converted to this type.numericConversionValidImpl
in interface Type
public final boolean numericConversionValid(java.lang.Object value)
Type
value
can be converted to this type.numericConversionValid
in interface Type
public boolean numericConversionValidImpl(java.lang.Object value)
Type
value
can be converted to this type.numericConversionValidImpl
in interface Type
public boolean isComparable(Type t)
Type
isComparable
in interface Type
public abstract java.lang.String toString()
Type
public void print(CodeWriter w)
w
.
This implementation generates whatever representation is produced
by toString()
. To satisfy the specification of
Type.toString()
, this implementation needs to be overridden
if toString
does not produce a compilable representation.