tip.node
Class AProgram

java.lang.Object
  extended by tip.node.Node
      extended by tip.node.PProgram
          extended by tip.node.AProgram
All Implemented Interfaces:
Cloneable, NodeInterface

public final class AProgram
extends PProgram

AProgram represents the alternative of the program production in the AST.


Constructor Summary
AProgram()
          Creates a new AProgram node with no children.
AProgram(List<? extends AFuncDecl> _functions_)
          Creates a new AProgram node with the given nodes as children.
AProgram(List<? extends AFuncDecl> _functions_, int[] _code_, Map<String,AFuncDecl> _function_env_)
          Creates a new AProgram node with the given nodes as children.
 
Method Summary
 void apply(Analysis caller)
          Calls the Analysis.caseAProgram(AProgram) of the Analysis caller.
<A> A
apply(Answer<A> caller)
          Returns the answer for caller by applying this AProgram node to the Answer visitor.
<Q> void
apply(Question<Q> caller, Q question)
          Applies this AProgram node to the Question visitor caller.
<Q,A> A
apply(QuestionAnswer<Q,A> caller, Q question)
          Returns the answer for caller by applying this AProgram node with the question to the QuestionAnswer visitor.
 void checkOptionalInvariant()
           
 AProgram clone()
          Returns a deep clone of this AProgram node.
 AProgram clone(Map<Node,Node> oldToNewMap)
          Creates a deep clone of this AProgram node while putting all old node-new node relations in the map oldToNewMap.
<T extends NodeInterface>
void
getChildren(Collection<T> collection, NodeFilter<T> filter)
          Adds all children of this AProgram node that are accepted by the NodeFilter filter to collection.
 int[] getCode()
          Returns the code field of this AProgram node.
<T extends NodeInterface>
void
getDescendants(Collection<T> collection, NodeFilter<T> filter)
          Adds all descendants of this AProgram node (including the node itself) that are accepted by the NodeFilter filter to collection.
 Map<String,AFuncDecl> getFunctionEnv()
          Returns the function_env field of this AProgram node.
 LinkedList<AFuncDecl> getFunctions()
          Returns the possibly empty list of AFuncDecl nodes that are the functions children of this AProgram node.
 void setCode(int[] value)
          Sets the code field of this AProgram node.
 void setFunctionEnv(Map<String,AFuncDecl> value)
          Sets the function_env field of this AProgram node.
 void setFunctions(List<? extends AFuncDecl> value)
          Sets the functions children of this AProgram node.
 String toString()
          Returns a textual representation of this AProgram node.
 
Methods inherited from class tip.node.PProgram
kindNode
 
Methods inherited from class tip.node.Node
getAncestor, getAncestor, getAncestor, getChildren, getChildren, getDescendants, getDescendants, getDescendants, isOptionalInvariant, parent, replaceBy, setOptionalInvariant
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AProgram

public AProgram()
Creates a new AProgram node with no children.


AProgram

public AProgram(List<? extends AFuncDecl> _functions_)
Creates a new AProgram node with the given nodes as children. The basic child nodes are removed from their previous parents.

Parameters:
_functions_ - the list of AFuncDecl nodes for the Functions children of this AProgram node

AProgram

public AProgram(List<? extends AFuncDecl> _functions_,
                int[] _code_,
                Map<String,AFuncDecl> _function_env_)
Creates a new AProgram node with the given nodes as children. The basic child nodes are removed from their previous parents.

Parameters:
_functions_ - the list of AFuncDecl nodes for the Functions children of this AProgram node
_code_ - the Code child of this AProgram node
_function_env_ - the FunctionEnv child of this AProgram node
Method Detail

clone

public AProgram clone()
Returns a deep clone of this AProgram node.

Specified by:
clone in interface NodeInterface
Specified by:
clone in class PProgram
Returns:
a deep clone of this AProgram node

clone

public AProgram clone(Map<Node,Node> oldToNewMap)
Creates a deep clone of this AProgram node while putting all old node-new node relations in the map oldToNewMap.

Specified by:
clone in interface NodeInterface
Specified by:
clone in class PProgram
Parameters:
oldToNewMap - the map filled with the old node-new node relation
Returns:
a deep clone of this AProgram node

toString

public String toString()
Returns a textual representation of this AProgram node.

Overrides:
toString in class Object
Returns:
a textual representation of this AProgram node

getFunctions

public LinkedList<AFuncDecl> getFunctions()
Returns the possibly empty list of AFuncDecl nodes that are the functions children of this AProgram node.

Specified by:
getFunctions in class PProgram
Returns:
the possibly empty list of AFuncDecl nodes that are the functions children of this AProgram node

setFunctions

public void setFunctions(List<? extends AFuncDecl> value)
Sets the functions children of this AProgram node.

Specified by:
setFunctions in class PProgram
Parameters:
value - the new functions children of this AProgram node

getCode

public int[] getCode()
Returns the code field of this AProgram node.

Specified by:
getCode in class PProgram
Returns:
the code field of this AProgram node

setCode

public void setCode(int[] value)
Sets the code field of this AProgram node.

Specified by:
setCode in class PProgram
Parameters:
value - the new code field of this AProgram node

getFunctionEnv

public Map<String,AFuncDecl> getFunctionEnv()
Returns the function_env field of this AProgram node.

Specified by:
getFunctionEnv in class PProgram
Returns:
the function_env field of this AProgram node

setFunctionEnv

public void setFunctionEnv(Map<String,AFuncDecl> value)
Sets the function_env field of this AProgram node.

Specified by:
setFunctionEnv in class PProgram
Parameters:
value - the new function_env field of this AProgram node

getDescendants

public <T extends NodeInterface> void getDescendants(Collection<T> collection,
                                                     NodeFilter<T> filter)
Adds all descendants of this AProgram node (including the node itself) that are accepted by the NodeFilter filter to collection.

Specified by:
getDescendants in interface NodeInterface
Specified by:
getDescendants in class Node
Parameters:
collection - the collection to which the descendants are added
filter - the NodeFilter used

getChildren

public <T extends NodeInterface> void getChildren(Collection<T> collection,
                                                  NodeFilter<T> filter)
Adds all children of this AProgram node that are accepted by the NodeFilter filter to collection.

Specified by:
getChildren in interface NodeInterface
Specified by:
getChildren in class Node
Parameters:
collection - the collection to which the children are added
filter - the NodeFilter used

checkOptionalInvariant

public void checkOptionalInvariant()
Specified by:
checkOptionalInvariant in interface NodeInterface
Specified by:
checkOptionalInvariant in class Node

apply

public void apply(Analysis caller)
Calls the Analysis.caseAProgram(AProgram) of the Analysis caller.

Specified by:
apply in interface NodeInterface
Specified by:
apply in class Node
Parameters:
sw - the Analysis to which this AProgram node is applied

apply

public <A> A apply(Answer<A> caller)
Returns the answer for caller by applying this AProgram node to the Answer visitor.

Specified by:
apply in interface NodeInterface
Specified by:
apply in class Node
Parameters:
caller - the Answer to which this node is applied
Returns:
the answer as returned from caller

apply

public <Q> void apply(Question<Q> caller,
                      Q question)
Applies this AProgram node to the Question visitor caller.

Specified by:
apply in interface NodeInterface
Specified by:
apply in class Node
Parameters:
caller - the Question to which this node is applied
question - the question provided to caller

apply

public <Q,A> A apply(QuestionAnswer<Q,A> caller,
                     Q question)
Returns the answer for caller by applying this AProgram node with the question to the QuestionAnswer visitor.

Specified by:
apply in interface NodeInterface
Specified by:
apply in class Node
Parameters:
caller - the QuestionAnswer to which this node is applied
question - the question provided to caller
Returns:
the answer as returned from caller