gov.llnl.babel.symbols
Class Type

java.lang.Object
  extended by gov.llnl.babel.symbols.ASTNode
      extended by gov.llnl.babel.symbols.Type

public class Type
extends ASTNode

The Type class defines a SIDL type, such as a primitive type (boolean, char, dcomplex, double, fcomplex, float, int, long, opaque, and string), arrays, and user-defined types (enum, interface, or class). A Type object may also be created for a void return type from a method.


Field Summary
static int ARRAY
           
static int BOOLEAN
           
static int CHAR
           
static int CLASS
           
static int COLUMN_MAJOR
           
static int DCOMPLEX
           
static int DOUBLE
           
static int ENUM
           
static int FCOMPLEX
           
static int FLOAT
           
static int INT
           
static int INTERFACE
           
static int LONG
           
static int MAX_TYPE_IND
           
static int MIN_TYPE_IND
           
static int OPAQUE
           
static int PACKAGE
           
static int ROW_MAJOR
           
static java.lang.String[] s_names
           
static int STRING
           
static int STRUCT
           
static int SYMBOL
           
static int UNSPECIFIED
           
static int VOID
           
 
Fields inherited from class gov.llnl.babel.symbols.ASTNode
d_frozen
 
Constructor Summary
Type(int type)
          Create a new primitive type (boolean, char, dcomplex, double, fcomplex, float, int, long, opaque, and string).
Type(SymbolID id, Context context)
          Create a new type given a user-defined symbol identifier.
Type(SymbolID id, int type, Type arr_type, int dim, int order, Context context)
          Explicit constructor.
Type(Type type, int dim, int order, Context context)
          Create a new array.
Type(Type type, int dim, java.util.Vector indices, Context context)
          Create a new array provided the array type, dimension, and order.
 
Method Summary
 void addArrayIndex(AssertionExpression s)
          This adds an index variable on the end of the index vector.
 void addArrayIndex(java.lang.String s)
          This adds an index variable on the end of the index vector.
 boolean equals(java.lang.Object object)
          Return TRUE if the specified object is considered to be the same as this object; otherwise, return FALSE.
 void freeze()
           
 int getArrayDimension()
          If this type is an array, then return the dimension.
 java.util.List getArrayIndexExprs()
          Return the list of rarray expressions.
 java.util.Collection getArrayIndices()
          This returns the set of indices needed for this rarray.
 int getArrayOrder()
          Return the storage order, if this is an array; otherwise, return zero.
 Type getArrayType()
          If this is an array, return the array type.
 java.lang.String getArrayTypeName()
          Returns the array type name or the null string if not applicable.
 int getBasicType()
           
 int getDetailedType()
          Return the integer that identifies the type of this type.
 java.lang.String getIndexString()
          Return a string representation of the list of index variables.
 SymbolID getSymbolID()
          Return the symbol identifier if this is a symbol type; otherwise, return null.
 int getType()
          Return the integer that identifies the type of this type.
 java.lang.String getTypeName()
          Return the name of the type.
static java.lang.String getTypeName(int type)
          Return the name of the type given the specified type value or, if not recognized, simply a null string.
 java.lang.String getTypeString()
          Return a string representation of the type for printing out the types in a method signature.
 boolean hasArrayOrderSpec()
          Return true if and only if the type is an array with an ordering specification.
 int hashCode()
           
 boolean isArray()
          Return TRUE if the type is an array; otherwise, return FALSE.
 boolean isGenericArray()
          Return true iff this type is a generic array type.
 boolean isNumericArray()
          Return TRUE if the type is a numeric array; otherwise, return FALSE.
 boolean isPrimitive()
          Return TRUE if the type is one of the standard primitive types, including strings; otherwise, return FALSE.
 boolean isRarray()
          Returns true if this Type is an rarray, false otherwise.
 boolean isString()
          Return TRUE if the type is a string; otherwise, return FALSE.
 boolean isStruct()
          Return TRUE if the type is an struct; otherwise, return FALSE.
 boolean isSymbol()
          Return TRUE if the type is a symbol; otherwise, return FALSE.
 
Methods inherited from class gov.llnl.babel.symbols.ASTNode
checkFrozen, clone, protectCollection, protectList, protectMap, protectSet
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VOID

public static final int VOID
See Also:
Constant Field Values

BOOLEAN

public static final int BOOLEAN
See Also:
Constant Field Values

CHAR

public static final int CHAR
See Also:
Constant Field Values

DCOMPLEX

public static final int DCOMPLEX
See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
See Also:
Constant Field Values

FCOMPLEX

public static final int FCOMPLEX
See Also:
Constant Field Values

FLOAT

public static final int FLOAT
See Also:
Constant Field Values

INT

public static final int INT
See Also:
Constant Field Values

LONG

public static final int LONG
See Also:
Constant Field Values

OPAQUE

public static final int OPAQUE
See Also:
Constant Field Values

STRING

public static final int STRING
See Also:
Constant Field Values

ENUM

public static final int ENUM
See Also:
Constant Field Values

STRUCT

public static final int STRUCT
See Also:
Constant Field Values

CLASS

public static final int CLASS
See Also:
Constant Field Values

INTERFACE

public static final int INTERFACE
See Also:
Constant Field Values

PACKAGE

public static final int PACKAGE
See Also:
Constant Field Values

SYMBOL

public static final int SYMBOL
See Also:
Constant Field Values

ARRAY

public static final int ARRAY
See Also:
Constant Field Values

MIN_TYPE_IND

public static final int MIN_TYPE_IND
See Also:
Constant Field Values

MAX_TYPE_IND

public static final int MAX_TYPE_IND
See Also:
Constant Field Values

s_names

public static final java.lang.String[] s_names

UNSPECIFIED

public static final int UNSPECIFIED
See Also:
Constant Field Values

COLUMN_MAJOR

public static final int COLUMN_MAJOR
See Also:
Constant Field Values

ROW_MAJOR

public static final int ROW_MAJOR
See Also:
Constant Field Values
Constructor Detail

Type

public Type(int type)
Create a new primitive type (boolean, char, dcomplex, double, fcomplex, float, int, long, opaque, and string). Use the other constructors to create a symbol or array type.

Parameters:
type - The value of this primitive type object.

Type

public Type(SymbolID id,
            Context context)
Create a new type given a user-defined symbol identifier. This symbol identifier will represent an enum, interface, or class.

Parameters:
id - The identifier of with this symbol object.

Type

public Type(Type type,
            int dim,
            int order,
            Context context)
Create a new array.

Parameters:
type - The type of this array object.
dim - The dimension of this array.
order - The desired storage order of this array.

Type

public Type(Type type,
            int dim,
            java.util.Vector indices,
            Context context)
Create a new array provided the array type, dimension, and order.

Parameters:
indices - this can be a ArrayList of String's or AssertionExpression's. Any String elements are converted to AssertionExpression's.

Type

public Type(SymbolID id,
            int type,
            Type arr_type,
            int dim,
            int order,
            Context context)
Explicit constructor.

Method Detail

getType

public int getType()
Return the integer that identifies the type of this type. If the type is ENUM, STRUCT, INTERFACE, or CLASS, it is returned as the generic SYMBOL (for historical purposes).


getBasicType

public int getBasicType()

getTypeName

public java.lang.String getTypeName()
Return the name of the type. Assumption: 1) The type attribute is valid and in range.


getTypeName

public static java.lang.String getTypeName(int type)
Return the name of the type given the specified type value or, if not recognized, simply a null string.


getDetailedType

public int getDetailedType()
Return the integer that identifies the type of this type. If type == SYMBOL, this method will try to further refine the type to one of (CLASS, INTERFACE, ENUM, STRUCT). This may, in fact, fail if the type is undefined (via a forward reference) and then SYMBOL is returned.


isPrimitive

public boolean isPrimitive()
Return TRUE if the type is one of the standard primitive types, including strings; otherwise, return FALSE.


isString

public boolean isString()
Return TRUE if the type is a string; otherwise, return FALSE.


isSymbol

public boolean isSymbol()
Return TRUE if the type is a symbol; otherwise, return FALSE.


isArray

public boolean isArray()
Return TRUE if the type is an array; otherwise, return FALSE.


isStruct

public boolean isStruct()
Return TRUE if the type is an struct; otherwise, return FALSE.


getArrayDimension

public int getArrayDimension()
If this type is an array, then return the dimension. A zero array dimension indicates an array with no type, no dimension and no ordering specified.


getArrayOrder

public int getArrayOrder()
Return the storage order, if this is an array; otherwise, return zero.


isGenericArray

public boolean isGenericArray()
Return true iff this type is a generic array type.


getArrayType

public Type getArrayType()
If this is an array, return the array type. A null array type means that this array is a generic array reference with no dimension, no type and not ordering specified.


isNumericArray

public boolean isNumericArray()
Return TRUE if the type is a numeric array; otherwise, return FALSE.


getArrayTypeName

public java.lang.String getArrayTypeName()
Returns the array type name or the null string if not applicable.


addArrayIndex

public void addArrayIndex(java.lang.String s)
This adds an index variable on the end of the index vector. It converts it into an AssertionExpression.


addArrayIndex

public void addArrayIndex(AssertionExpression s)
This adds an index variable on the end of the index vector.


getArrayIndices

public java.util.Collection getArrayIndices()
This returns the set of indices needed for this rarray. (A set of Strings corresponding to argument names of type int or long). If this Type is not an rarray this function returns null.

Returns:
this returned list is a list of String objects.

getArrayIndexExprs

public java.util.List getArrayIndexExprs()
Return the list of rarray expressions.


isRarray

public boolean isRarray()
Returns true if this Type is an rarray, false otherwise.


hasArrayOrderSpec

public boolean hasArrayOrderSpec()
Return true if and only if the type is an array with an ordering specification. For example, array<int,2,column-major> would return true; array<int, 2> would return false. For non-array types, this always returns false.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getSymbolID

public SymbolID getSymbolID()
Return the symbol identifier if this is a symbol type; otherwise, return null.


getTypeString

public java.lang.String getTypeString()
Return a string representation of the type for printing out the types in a method signature.


getIndexString

public java.lang.String getIndexString()
Return a string representation of the list of index variables. This string is the names of the index variables (in order) seperated by commas.


equals

public boolean equals(java.lang.Object object)
Return TRUE if the specified object is considered to be the same as this object; otherwise, return FALSE.

Overrides:
equals in class java.lang.Object

freeze

public void freeze()
Overrides:
freeze in class ASTNode