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

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

public final class InitialValue
extends Node
implements IExpParent, ITypeParent

An initial value of a local or global variable, along with an optional type coercion to make it compatible with the variable declaration.

Version:
CVS $Revision: 1.2 $ $Date: 2005/02/06 09:15:30 $
Author:
Matt Hoosier
See Also:
Serialized Form

Field Summary
protected  ASTType coercedType
          Holds the optional coerced type.
protected  IInitialValueParent parent
          Holds parent of this value
protected  Exp value
          The constant or literal expression.
 
Fields inherited from class edu.ksu.cis.projects.bogor.ast.Node
ILLEGAL_LOCAL_ID_CHAR
 
Constructor Summary
InitialValue(Exp value)
          Node for initial value of a variable, left as its natural type.
InitialValue(Exp value, ASTType coercedType)
          Node for initial value of a variable, casted to a particular type.
 
Method Summary
 InitialValue clone()
          Clones this object (deep clone); including location info.
 ASTType getOptionalCoercedType()
          Gets the type to which this value is cast.
 IInitialValueParent getParent()
          Gets the parent of this node.
 Exp getValue()
          Gets the initial value.
 void setCoercedType(ASTType newType)
          Sets the type to which the initial value is cast.
 void setParent(IInitialValueParent newParent)
          Make newParent the parent of this node.
 void setValue(Exp newValue)
          Sets the initial value.
 String toString()
           
 void visit(ASTVisitor visitor)
           
 
Methods inherited from class edu.ksu.cis.projects.bogor.ast.Node
dispose, getLocationInfo, getProperty, putProperty, setLocationInfo
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected Exp value
The constant or literal expression. Non-null.


coercedType

protected ASTType coercedType
Holds the optional coerced type.


parent

protected IInitialValueParent parent
Holds parent of this value

Constructor Detail

InitialValue

public InitialValue(Exp value)
Node for initial value of a variable, left as its natural type.

Parameters:
value - The value initially assigned to the global or local which owns this node. Must be non-null.

InitialValue

public InitialValue(Exp value,
                    ASTType coercedType)
Node for initial value of a variable, casted to a particular type.

Parameters:
value - The value initially assigned to the global or local which owns this node. Must be non-null.
coercedType - The type to which this initial value is casted. Must be non-null.
Method Detail

setValue

public void setValue(Exp newValue)
Sets the initial value. This InitialValue is made the parent of newValue.

Parameters:
newValue - The new value. Must be non-null.

getValue

public Exp getValue()
Gets the initial value.


setCoercedType

public void setCoercedType(ASTType newType)
Sets the type to which the initial value is cast. This InitialValue is made the parent of newType.

Parameters:
newType - The new casted type. Must be non-null.

getOptionalCoercedType

public ASTType getOptionalCoercedType()
Gets the type to which this value is cast.

Returns:
The coerced type, or null if none is specified.

setParent

public void setParent(IInitialValueParent newParent)
Make newParent the parent of this node.

Parameters:
newParent - The new syntax tree node which owns this InitialValue. Must be non-null.

getParent

public IInitialValueParent getParent()
Gets the parent of this node.


clone

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

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

visit

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

toString

public String toString()
Specified by:
toString in class Node