gov.llnl.babel.symbols

Class 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 int
STRING
static int
STRUCT
static int
SYMBOL
static int
UNSPECIFIED
static int
VOID
static String[]
s_names

Fields inherited from class gov.llnl.babel.symbols.ASTNode

d_frozen

Constructor Summary

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, Vector indices, Context context)
Create a new array provided the array type, dimension, and order.
Type(Type type, int dim, int order, Context context)
Create a new array.
Type(int type)
Create a new primitive type (boolean, char, dcomplex, double, fcomplex, float, int, long, opaque, and string).

Method Summary

void
addArrayIndex(String s)
This adds an index variable on the end of the index vector.
void
addArrayIndex(AssertionExpression s)
This adds an index variable on the end of the index vector.
boolean
equals(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.
List
getArrayIndexExprs()
Return the list of rarray expressions.
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.
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.
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.
String
getTypeName()
Return the name of the type.
static String
getTypeName(int type)
Return the name of the type given the specified type value or, if not recognized, simply a null string.
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, freeze, protectCollection, protectList, protectMap, protectSet

Field Details

ARRAY

public static final int ARRAY
Field Value:
17

BOOLEAN

public static final int BOOLEAN
Field Value:
1

CHAR

public static final int CHAR
Field Value:
2

CLASS

public static final int CLASS
Field Value:
13

COLUMN_MAJOR

public static final int COLUMN_MAJOR
Field Value:
1

DCOMPLEX

public static final int DCOMPLEX
Field Value:
3

DOUBLE

public static final int DOUBLE
Field Value:
4

ENUM

public static final int ENUM
Field Value:
11

FCOMPLEX

public static final int FCOMPLEX
Field Value:
5

FLOAT

public static final int FLOAT
Field Value:
6

INT

public static final int INT
Field Value:
7

INTERFACE

public static final int INTERFACE
Field Value:
14

LONG

public static final int LONG
Field Value:
8

MAX_TYPE_IND

public static final int MAX_TYPE_IND
Field Value:
14

MIN_TYPE_IND

public static final int MIN_TYPE_IND
Field Value:
0

OPAQUE

public static final int OPAQUE
Field Value:
9

PACKAGE

public static final int PACKAGE
Field Value:
15

ROW_MAJOR

public static final int ROW_MAJOR
Field Value:
2

STRING

public static final int STRING
Field Value:
10

STRUCT

public static final int STRUCT
Field Value:
12

SYMBOL

public static final int SYMBOL
Field Value:
16

UNSPECIFIED

public static final int UNSPECIFIED
Field Value:
0

VOID

public static final int VOID
Field Value:
0

s_names

public static final String[] s_names

Constructor Details

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(SymbolID id,
            int type,
            Type arr_type,
            int dim,
            int order,
            Context context)
Explicit constructor.

Type

public Type(Type type,
            int dim,
            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(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(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.

Method Details

addArrayIndex

public void addArrayIndex(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.

equals

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

freeze

public void freeze()
Overrides:
freeze in interface ASTNode

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.

getArrayIndexExprs

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

getArrayIndices

public 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.

getArrayOrder

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

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.

getArrayTypeName

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

getBasicType

public int getBasicType()

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.

getIndexString

public 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.

getSymbolID

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

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

getTypeName

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

getTypeName

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

getTypeString

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

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

isArray

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

isGenericArray

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

isNumericArray

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

isPrimitive

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

isRarray

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

isString

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

isStruct

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

isSymbol

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