polyglot.ext.jl.types
Class ArrayType_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.ReferenceType_c
              extended by polyglot.ext.jl.types.ArrayType_c
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ArrayType, Qualifier, ReferenceType, Type, TypeObject, Copy

public class ArrayType_c
extends ReferenceType_c
implements ArrayType

An ArrayType represents an array of base java types.

See Also:
Serialized Form

Field Summary
protected  Type base
           
protected  java.util.List fields
           
protected  java.util.List interfaces
           
protected  java.util.List methods
           
 
Fields inherited from class polyglot.ext.jl.types.TypeObject_c
position, ts
 
Constructor Summary
protected ArrayType_c()
          Used for deserializing types.
  ArrayType_c(TypeSystem ts, Position pos, Type base)
           
 
Method Summary
 Type base()
          Get the base type of the array.
 ArrayType base(Type base)
          Set the base type of the array.
 MethodInstance cloneMethod()
          Get the clone() method.
 int dims()
          Return the number of dimensions in this array type.
 boolean equalsImpl(TypeObject t)
          Default implementation is pointer equality.
 FieldInstance fieldNamed(java.lang.String name)
          Get a field of the type by name.
 java.util.List fields()
          Get the fields of the array type.
 int hashCode()
           
 java.util.List interfaces()
          Get the interfaces implemented by the array type.
 boolean isArray()
          Return true if an array type.
 boolean isCanonical()
          Returns true iff the type is canonical.
 boolean isCastValidImpl(Type toType)
          Requires: all type arguments are canonical.
 boolean isImplicitCastValidImpl(Type toType)
          Return true if a value of this type can be assigned to a variable of type toType.
 FieldInstance lengthField()
          Get the length field.
 java.util.List methods()
          Get the methods implemented by the array type.
 Type superType()
          Get the super type of the array type.
 ArrayType toArray()
          Returns a non-null iff isArray() returns true.
 java.lang.String toString()
          Yields a string representing this type.
 java.lang.String translate(Resolver c)
          Translate the type.
 Type ultimateBase()
          Get the ulitimate base type of the array.
 
Methods inherited from class polyglot.ext.jl.types.ReferenceType_c
descendsFromImpl, hasMethod, hasMethodImpl, isReference, methods, methodsNamed, toReference
 
Methods inherited from class polyglot.ext.jl.types.Type_c
arrayOf, arrayOf, descendsFrom, isBoolean, isByte, isCastValid, isChar, isClass, isComparable, isDouble, isFloat, isImplicitCastValid, isInt, isIntOrLess, isLong, isLongOrLess, isNull, isNumeric, isPackage, isPrimitive, isShort, isSubtype, isSubtypeImpl, isThrowable, isType, isUncheckedException, isVoid, numericConversionValid, numericConversionValid, numericConversionValidImpl, numericConversionValidImpl, toClass, toNull, toPackage, toPrimitive, 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.ReferenceType
hasMethod, hasMethodImpl, methods, methodsNamed
 
Methods inherited from interface polyglot.types.Type
arrayOf, arrayOf, descendsFrom, descendsFromImpl, isBoolean, isByte, isCastValid, isChar, isClass, isComparable, isDouble, isFloat, isImplicitCastValid, isInt, isIntOrLess, isLong, isLongOrLess, isNull, isNumeric, isPrimitive, isReference, isShort, isSubtype, isSubtypeImpl, isThrowable, isUncheckedException, isVoid, numericConversionValid, numericConversionValid, numericConversionValidImpl, numericConversionValidImpl, toClass, toNull, toPrimitive, 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

base

protected Type base

fields

protected java.util.List fields

methods

protected java.util.List methods

interfaces

protected java.util.List interfaces
Constructor Detail

ArrayType_c

protected ArrayType_c()
Used for deserializing types.


ArrayType_c

public ArrayType_c(TypeSystem ts,
                   Position pos,
                   Type base)
Method Detail

base

public Type base()
Get the base type of the array.

Specified by:
base in interface ArrayType

base

public ArrayType base(Type base)
Set the base type of the array.

Specified by:
base in interface ArrayType

ultimateBase

public Type ultimateBase()
Get the ulitimate base type of the array.

Specified by:
ultimateBase in interface ArrayType

dims

public int dims()
Description copied from interface: ArrayType
Return the number of dimensions in this array type. e.g., for A[], return 1; for A[][], return 2, etc.

Specified by:
dims in interface ArrayType

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)
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()
Returns true iff the type is canonical.

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

isArray

public boolean isArray()
Description copied from interface: Type
Return true if an array type.

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

toArray

public ArrayType toArray()
Description copied from class: Type_c
Returns a non-null iff isArray() returns true.

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

methods

public java.util.List methods()
Get the methods implemented by the array type.

Specified by:
methods in interface ReferenceType
Specified by:
methods in class ReferenceType_c
Returns:
A list of MethodInstance.
See Also:
MethodInstance

fields

public java.util.List fields()
Get the fields of the array type.

Specified by:
fields in interface ReferenceType
Specified by:
fields in class ReferenceType_c
Returns:
A list of FieldInstance.
See Also:
FieldInstance

cloneMethod

public MethodInstance cloneMethod()
Get the clone() method.

Specified by:
cloneMethod in interface ArrayType

fieldNamed

public FieldInstance fieldNamed(java.lang.String name)
Get a field of the type by name.

Specified by:
fieldNamed in interface ReferenceType

lengthField

public FieldInstance lengthField()
Get the length field.

Specified by:
lengthField in interface ArrayType

superType

public Type superType()
Get the super type of the array type.

Specified by:
superType in interface ReferenceType
Specified by:
superType in class ReferenceType_c

interfaces

public java.util.List interfaces()
Get the interfaces implemented by the array type.

Specified by:
interfaces in interface ReferenceType
Specified by:
interfaces in class ReferenceType_c
Returns:
A list of Type.
See Also:
Type

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()

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 ReferenceType_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 ReferenceType_c