com.togethersoft.sca.ast
Interface AstTypeReference

All Known Subinterfaces:
AstType

public interface AstTypeReference

The common interface representing a reference to a type. AstTypeReference can be used to refer to the following types:


Field Summary
static int TID_BAD
          Constant representing the bad type.
static int TID_BOOLEAN
          Constant representing the boolean type.
static int TID_BYTE
          Constant representing the byte type.
static int TID_CHAR
          Constant representing the char type.
static int TID_CLASS
          Constant representing a class type.
static int TID_DOUBLE
          Constant representing the double type.
static int TID_FLOAT
          Constant representing the float type.
static int TID_INT
          Constant representing the int type.
static int TID_INTERFACE
          Constant representing an interface type.
static int TID_LONG
          Constant representing the long type.
static int TID_NULL
          Constant representing the null type.
static int TID_SHORT
          Constant representing the short type.
static int TID_VOID
          Constant representing the void type.
 
Method Summary
 AstType getBaseType()
          Returns the base type of this type.
 int getKind()
          Returns the kind of this type encoded as an integer.
 java.lang.String getSignature()
          Returns the signature of this type.
 java.lang.String getTypeName()
          Returns the fully qualified name of this type optionally followed by brackets for array types.
 boolean isAssignableTo(AstTypeReference type)
          Indicates whether an expression of this type can be assigned to a variable of the given type without explicit type conversion.
 boolean isDerivedFrom(AstTypeReference type)
          Indicates whether this type is a subtype of the specified type.
 int numDimensions()
          Returns number of dimensions for array types.
 

Field Detail

TID_BAD

public static final int TID_BAD
Constant representing the bad type.

TID_BOOLEAN

public static final int TID_BOOLEAN
Constant representing the boolean type.

TID_BYTE

public static final int TID_BYTE
Constant representing the byte type.

TID_CHAR

public static final int TID_CHAR
Constant representing the char type.

TID_CLASS

public static final int TID_CLASS
Constant representing a class type.

TID_DOUBLE

public static final int TID_DOUBLE
Constant representing the double type.

TID_FLOAT

public static final int TID_FLOAT
Constant representing the float type.

TID_INT

public static final int TID_INT
Constant representing the int type.

TID_INTERFACE

public static final int TID_INTERFACE
Constant representing an interface type.

TID_LONG

public static final int TID_LONG
Constant representing the long type.

TID_NULL

public static final int TID_NULL
Constant representing the null type.

TID_SHORT

public static final int TID_SHORT
Constant representing the short type.

TID_VOID

public static final int TID_VOID
Constant representing the void type.
Method Detail

getBaseType

public AstType getBaseType()
Returns the base type of this type. For array types, the base type is the element type of the array. For non-array types, the base type is the type itself. For primitive types, this returns null.

getKind

public int getKind()
Returns the kind of this type encoded as an integer.

getSignature

public java.lang.String getSignature()
Returns the signature of this type. The signature format is described in Section 4.3.2 of The JavaTM Virtual Machine Specification. '#' character is used to represent bad types that cannot be evaluated.

For example, a variable declared as double d[][][] would return "[[[D".


getTypeName

public java.lang.String getTypeName()
Returns the fully qualified name of this type optionally followed by brackets for array types.

For example, this will return java/lang/String[] for an array of Strings.


isAssignableTo

public boolean isAssignableTo(AstTypeReference type)
Indicates whether an expression of this type can be assigned to a variable of the given type without explicit type conversion.

isDerivedFrom

public boolean isDerivedFrom(AstTypeReference type)
Indicates whether this type is a subtype of the specified type.

Returns true if the following conditions are met:

See Also:
AstType.isDerivedFrom(com.togethersoft.sca.ast.AstType)

numDimensions

public int numDimensions()
Returns number of dimensions for array types. For instance, this returns 2 for the int[][] type. Returns 0 for non-array types.