polyglot.ext.jl.types
Class PrimitiveType_c

java.lang.Object
  extended by polyglot.ext.jl.types.TypeObject_c
      extended by polyglot.ext.jl.types.Type_c
          extended by polyglot.ext.jl.types.PrimitiveType_c
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Named, PrimitiveType, Qualifier, Type, TypeObject, Copy
Direct Known Subclasses:
PaoPrimitiveType_c

public class PrimitiveType_c
extends Type_c
implements PrimitiveType

An PrimitiveType_c represents a primitive type.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface polyglot.types.PrimitiveType
PrimitiveType.Kind
 
Field Summary
protected  PrimitiveType.Kind kind
           
 
Fields inherited from class polyglot.ext.jl.types.TypeObject_c
position, ts
 
Fields inherited from interface polyglot.types.PrimitiveType
BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT, VOID
 
Constructor Summary
protected PrimitiveType_c()
          Used for deserializing types.
  PrimitiveType_c(TypeSystem ts, PrimitiveType.Kind kind)
           
 
Method Summary
 boolean descendsFromImpl(Type ancestor)
          Return true if this type descends from ancestor.
 boolean equalsImpl(TypeObject t)
          Default implementation is pointer equality.
 java.lang.String fullName()
          Full dotted-name of the type object.
 int hashCode()
           
 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 isCastValidImpl(Type toType)
          Requires: all type arguments are canonical.
 boolean isChar()
          Return true if char.
 boolean isDouble()
          Return true if double.
 boolean isFloat()
          Return true if float.
 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 isNumeric()
          Return true if double, float, long, int, short, byte, or char.
 boolean isPrimitive()
          Return true if a primitive type.
 boolean isShort()
          Return true if short.
 boolean isVoid()
          Return true if void.
 PrimitiveType.Kind kind()
          The kind of primitive.
 java.lang.String name()
          Simple name of the type object.
 boolean numericConversionValidImpl(long value)
          Returns true if literal value value can be converted to this primitive type.
 boolean numericConversionValidImpl(java.lang.Object value)
          Returns true if literal value value can be converted to this primitive type.
 PrimitiveType toPrimitive()
          Returns a non-null iff isPrimitive() returns true.
 java.lang.String toString()
          Yields a string representing this type.
 java.lang.String translate(Resolver c)
          Return a string into which to translate the type.
 java.lang.String wrapperTypeString(TypeSystem ts)
          A string representing the type used to box this primitive.
 
Methods inherited from class polyglot.ext.jl.types.Type_c
arrayOf, arrayOf, descendsFrom, isArray, isCastValid, isClass, isComparable, isImplicitCastValid, isNull, isPackage, isReference, isSubtype, isSubtypeImpl, isThrowable, isType, isUncheckedException, numericConversionValid, numericConversionValid, toArray, toClass, toNull, toPackage, toReference, toType
 
Methods inherited from class polyglot.ext.jl.types.TypeObject_c
copy, equals, position, typeSystem
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface polyglot.types.Type
arrayOf, arrayOf, descendsFrom, isArray, isCastValid, isClass, isComparable, isImplicitCastValid, isNull, isReference, isSubtype, isSubtypeImpl, isThrowable, isUncheckedException, numericConversionValid, numericConversionValid, toArray, toClass, toNull, toReference
 
Methods inherited from interface polyglot.types.Qualifier
isPackage, isType, toPackage, toType
 
Methods inherited from interface polyglot.types.TypeObject
position, typeSystem
 
Methods inherited from interface polyglot.util.Copy
copy
 

Field Detail

kind

protected PrimitiveType.Kind kind
Constructor Detail

PrimitiveType_c

protected PrimitiveType_c()
Used for deserializing types.


PrimitiveType_c

public PrimitiveType_c(TypeSystem ts,
                       PrimitiveType.Kind kind)
Method Detail

kind

public PrimitiveType.Kind kind()
Description copied from interface: PrimitiveType
The kind of primitive.

Specified by:
kind in interface PrimitiveType

toString

public java.lang.String toString()
Description copied from class: Type_c
Yields a string representing this type. The string should be consistent with equality. That is, if this.equals(anotherType), then it should be that this.toString().equals(anotherType.toString()). The string does not have to be a legal Java identifier. It is suggested, but not required, that it be an easily human readable representation, and thus useful in error messages and generated output.

Specified by:
toString in interface Type
Specified by:
toString in class Type_c

translate

public java.lang.String translate(Resolver c)
Description copied from class: Type_c
Return a string into which to translate the type.

Specified by:
translate in interface Type
Specified by:
translate in class Type_c
Parameters:
c - A resolver in which to lookup this type to determine if the type is unique in the given resolver.

isCanonical

public boolean isCanonical()
Description copied from interface: TypeObject
Return true if the type object contains no unknown/ambiguous types.

Specified by:
isCanonical in interface TypeObject
Overrides:
isCanonical in class Type_c

isPrimitive

public boolean isPrimitive()
Description copied from interface: Type
Return true if a primitive type.

Specified by:
isPrimitive in interface Type
Overrides:
isPrimitive in class Type_c

toPrimitive

public PrimitiveType toPrimitive()
Description copied from class: Type_c
Returns a non-null iff isPrimitive() returns true.

Specified by:
toPrimitive in interface Type
Overrides:
toPrimitive in class Type_c

isVoid

public boolean isVoid()
Description copied from interface: Type
Return true if void.

Specified by:
isVoid in interface Type
Overrides:
isVoid in class Type_c

isBoolean

public boolean isBoolean()
Description copied from interface: Type
Return true if boolean.

Specified by:
isBoolean in interface Type
Overrides:
isBoolean in class Type_c

isChar

public boolean isChar()
Description copied from interface: Type
Return true if char.

Specified by:
isChar in interface Type
Overrides:
isChar in class Type_c

isByte

public boolean isByte()
Description copied from interface: Type
Return true if byte.

Specified by:
isByte in interface Type
Overrides:
isByte in class Type_c

isShort

public boolean isShort()
Description copied from interface: Type
Return true if short.

Specified by:
isShort in interface Type
Overrides:
isShort in class Type_c

isInt

public boolean isInt()
Description copied from interface: Type
Return true if int.

Specified by:
isInt in interface Type
Overrides:
isInt in class Type_c

isLong

public boolean isLong()
Description copied from interface: Type
Return true if long.

Specified by:
isLong in interface Type
Overrides:
isLong in class Type_c

isFloat

public boolean isFloat()
Description copied from interface: Type
Return true if float.

Specified by:
isFloat in interface Type
Overrides:
isFloat in class Type_c

isDouble

public boolean isDouble()
Description copied from interface: Type
Return true if double.

Specified by:
isDouble in interface Type
Overrides:
isDouble in class Type_c

isIntOrLess

public boolean isIntOrLess()
Description copied from interface: Type
Return true if int, short, byte, or char.

Specified by:
isIntOrLess in interface Type
Overrides:
isIntOrLess in class Type_c

isLongOrLess

public boolean isLongOrLess()
Description copied from interface: Type
Return true if long, int, short, byte, or char.

Specified by:
isLongOrLess in interface Type
Overrides:
isLongOrLess in class Type_c

isNumeric

public boolean isNumeric()
Description copied from interface: Type
Return true if double, float, long, int, short, byte, or char.

Specified by:
isNumeric in interface Type
Overrides:
isNumeric in class Type_c

hashCode

public int hashCode()
Overrides:
hashCode in class TypeObject_c

equalsImpl

public boolean equalsImpl(TypeObject t)
Description copied from class: TypeObject_c
Default implementation is pointer equality.

Specified by:
equalsImpl in interface TypeObject
Overrides:
equalsImpl in class TypeObject_c
See Also:
TypeObject_c.equalsImpl(TypeObject), Object.hashCode()

wrapperTypeString

public java.lang.String wrapperTypeString(TypeSystem ts)
Description copied from interface: PrimitiveType
A string representing the type used to box this primitive.

Specified by:
wrapperTypeString in interface PrimitiveType

name

public java.lang.String name()
Description copied from interface: Named
Simple name of the type object. Anonymous classes do not have names.

Specified by:
name in interface Named

fullName

public java.lang.String fullName()
Description copied from interface: Named
Full dotted-name of the type object. For a package, top level class, top level interface, or primitive type, this is the fully qualified name. For a member class or interface that is directly enclosed in a class or interface with a fully qualified name, then this is the fully qualified name of the member class or interface. For local and anonymous classes, this method returns a string that is not the fully qualified name (as these classes do not have fully qualified names), but that may be suitable for debugging or error messages.

Specified by:
fullName in interface Named

descendsFromImpl

public boolean descendsFromImpl(Type ancestor)
Description copied from class: Type_c
Return true if this type descends from ancestor.

Specified by:
descendsFromImpl in interface Type
Overrides:
descendsFromImpl in class Type_c

isImplicitCastValidImpl

public boolean isImplicitCastValidImpl(Type toType)
Description copied from class: Type_c
Return true if a value of this type can be assigned to a variable of type toType.

Specified by:
isImplicitCastValidImpl in interface Type
Overrides:
isImplicitCastValidImpl in class Type_c

isCastValidImpl

public boolean isCastValidImpl(Type toType)
Requires: all type arguments are canonical. ToType is not a NullType. Returns true iff a cast from this to toType is valid; in other words, some non-null members of this are also members of toType.

Specified by:
isCastValidImpl in interface Type
Overrides:
isCastValidImpl in class Type_c

numericConversionValidImpl

public boolean numericConversionValidImpl(long value)
Returns true if literal value value can be converted to this primitive type. This method should be removed. It is kept for backward compatibility.

Specified by:
numericConversionValidImpl in interface Type
Overrides:
numericConversionValidImpl in class Type_c

numericConversionValidImpl

public boolean numericConversionValidImpl(java.lang.Object value)
Returns true if literal value value can be converted to this primitive type.

Specified by:
numericConversionValidImpl in interface Type
Overrides:
numericConversionValidImpl in class Type_c