edu.ksu.cis.projects.bogor.ast
Class NewArrayExp

java.lang.Object
  extended by edu.ksu.cis.projects.bogor.ast.Node
      extended by edu.ksu.cis.projects.bogor.ast.Exp
          extended by edu.ksu.cis.projects.bogor.ast.NewArrayExp
All Implemented Interfaces:
IExpParent, ITypeParent, Disposable, Serializable, Cloneable

public final class NewArrayExp
extends Exp
implements ITypeParent

New array exp AST.

Version:
CVS $Revision: 1.7 $ $Date: 2005/05/01 20:03:26 $
Author:
Robby
See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.ksu.cis.projects.bogor.ast.Exp
TYPE
 
Fields inherited from class edu.ksu.cis.projects.bogor.ast.Node
ILLEGAL_LOCAL_ID_CHAR
 
Constructor Summary
NewArrayExp(ASTType type, List<? extends Exp> lengths, int rank)
          Default constructor.
 
Method Summary
 NewArrayExp clone()
          Clones this object (deep clone); including location info.
 void dispose()
          Disposes type and lengths.
 Exp getLength(int index)
          Gets a length at a specified index.
 int getLengthCount()
          Gets the number of lengths.
 int getRank()
          Gets the rank.
 ASTType getType()
          Gets the type.
 void setLengths(List<? extends Exp> newLengths)
          Sets the lengths.
 void setRank(int newRank)
          Sets the rank.
 void setType(ASTType newType)
          Sets the type.
 String toString()
          Returns the string representation of this object.
 void visit(ASTVisitor visitor)
           
 
Methods inherited from class edu.ksu.cis.projects.bogor.ast.Exp
getParent, setParent
 
Methods inherited from class edu.ksu.cis.projects.bogor.ast.Node
getLocationInfo, getProperty, putProperty, setLocationInfo
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NewArrayExp

public NewArrayExp(ASTType type,
                   List<? extends Exp> lengths,
                   int rank)
Default constructor. Sets this object as the type's and each length's parent.

Parameters:
type - The type. Must be non-null. Must not be instance of ASTArrayType.
lengths - The lengths. Must be non-null. Each element must be instance of Exp. The number of elements must be greater than zero.
rank - The rank. Must be greater than zero. At least equal to the number of lengths.
Method Detail

getLength

public Exp getLength(int index)
Gets a length at a specified index.

Parameters:
index - The index of the length. Must be between 0 and getLengthCount() - 1, inclusive.
Returns:
The length at the specified index. Non-null.

getLengthCount

public int getLengthCount()
Gets the number of lengths.

Returns:
The number of lengths.

setLengths

public void setLengths(List<? extends Exp> newLengths)
Sets the lengths. Sets this object as each length's parent.

Parameters:
newLengths - The new lengths. Must be non-null. Each element must be instance of Exp. The number of elements must be greater than zero.

setRank

public void setRank(int newRank)
Sets the rank.

Parameters:
newRank - The new rank. Must be greater than zero.

getRank

public int getRank()
Gets the rank.

Returns:
The rank. Greater than zero.

setType

public void setType(ASTType newType)
Sets the type. Sets this object as the type's parent.

Parameters:
newType - The new type. Must be non-null. Must not be instance of ASTArrayType.

getType

public ASTType getType()
Gets the type.

Returns:
The type. Non-null. Not instanceof ASTArrayType.

clone

public NewArrayExp clone()
Clones this object (deep clone); including location info.

Specified by:
clone in class Exp
Returns:
The clone of this object. Non-null.

dispose

public void dispose()
Disposes type and lengths. Once called, avoid using this object.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class Exp

toString

public String toString()
Returns the string representation of this object.

Specified by:
toString in class Node
Returns:
"new type( [length] )+( [] )* ".

visit

public void visit(ASTVisitor visitor)
Specified by:
visit in class Node