cetus.hir
Class ArraySpecifier

java.lang.Object
  extended by cetus.hir.Specifier
      extended by cetus.hir.ArraySpecifier
All Implemented Interfaces:
Printable

public class ArraySpecifier
extends Specifier

Represents an array specifier, for example the bracketed parts of int array[20][30];


Field Summary
static ArraySpecifier UNBOUNDED
          The unbounded specifier []
 
Fields inherited from class cetus.hir.Specifier
ABSTRACT, AUTO, BOOL, BOOLEAN, BYTE, CBOOL, CCOMPLEX, CHAR, CIMAGINARY, CONST, DOUBLE, EXPLICIT, EXTERN, FINAL, FLOAT, FRIEND, INLINE, INT, LONG, MUTABLE, NATIVE, PRIVATE, PROTECTED, PUBLIC, REFERENCE, REGISTER, RESTRICT, SHORT, SIGNED, STATIC, STRICTFP, SYNCHRONIZED, THREADSAFE, TRANSIENT, TYPEDEF, UNSIGNED, value, VIRTUAL, VOID, VOLATILE, WCHAR_T
 
Constructor Summary
ArraySpecifier()
           
ArraySpecifier(Expression expr)
           
ArraySpecifier(java.util.List dimensions)
           
 
Method Summary
 Expression getDimension(int n)
          Gets the nth dimension of this array specifier.
 int getNumDimensions()
          Returns the number of index expressions used in this array specifier.
 void print(java.io.OutputStream stream)
          Print the code for the IR represented by the object.
 void setDimension(int n, Expression expr)
          Sets the nth dimension of this array specifier.
 void setDimensions(java.util.List dimensions)
          Set the list of dimension expressions.
 java.lang.String toString()
           
 
Methods inherited from class cetus.hir.Specifier
fromString, isCType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNBOUNDED

public static final ArraySpecifier UNBOUNDED
The unbounded specifier []

Constructor Detail

ArraySpecifier

public ArraySpecifier()

ArraySpecifier

public ArraySpecifier(Expression expr)

ArraySpecifier

public ArraySpecifier(java.util.List dimensions)
Method Detail

getDimension

public Expression getDimension(int n)
Gets the nth dimension of this array specifier.

Parameters:
n - The position of the dimension.
Returns:
the nth dimension, which may be null. A null dimension occurs for example with int array[][8].
Throws:
java.lang.IndexOutOfBoundsException - if there is no expression at that position.

getNumDimensions

public int getNumDimensions()
Returns the number of index expressions used in this array specifier.

Returns:
the number of index expressions.

print

public void print(java.io.OutputStream stream)
Description copied from interface: Printable
Print the code for the IR represented by the object. Always calls object_print_method(this, stream). If the object's print method is null, nothing is printed; this provides an easy mechanism to temporarily hide something.

Specified by:
print in interface Printable
Overrides:
print in class Specifier
Parameters:
stream - The stream on which to print the data.

toString

public java.lang.String toString()
Overrides:
toString in class Specifier

setDimension

public void setDimension(int n,
                         Expression expr)
Sets the nth dimension of this array specifier.

Parameters:
n - The position of the dimension.
expr - The expression defining the size of the dimension.
Throws:
java.lang.IndexOutOfBoundsException - if there is no dimension at that position.

setDimensions

public void setDimensions(java.util.List dimensions)
Set the list of dimension expressions.

Parameters:
dimensions - A list of expressions.