tip.node
Class AFuncDecl

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

public final class AFuncDecl
extends PDecl

AFuncDecl represents the func alternative of the decl production in the AST.


Constructor Summary
AFuncDecl()
          Creates a new AFuncDecl node with no children.
AFuncDecl(TIdentifier _name_, List<? extends ALocalDecl> _formals_, ABody _body_)
          Creates a new AFuncDecl node with the given nodes as children.
AFuncDecl(TIdentifier _name_, List<? extends ALocalDecl> _formals_, ABody _body_, int _num_locals_, int _num_args_, int _index_)
          Creates a new AFuncDecl node with the given nodes as children.
 
Method Summary
 void apply(Analysis caller)
          Calls the Analysis.caseAFuncDecl(AFuncDecl) of the Analysis caller.
<A> A
apply(Answer<A> caller)
          Returns the answer for caller by applying this AFuncDecl node to the Answer visitor.
<Q> void
apply(Question<Q> caller, Q question)
          Applies this AFuncDecl node to the Question visitor caller.
<Q,A> A
apply(QuestionAnswer<Q,A> caller, Q question)
          Returns the answer for caller by applying this AFuncDecl node with the question to the QuestionAnswer visitor.
 void checkOptionalInvariant()
           
 AFuncDecl clone()
          Returns a deep clone of this AFuncDecl node.
 AFuncDecl clone(Map<Node,Node> oldToNewMap)
          Creates a deep clone of this AFuncDecl node while putting all old node-new node relations in the map oldToNewMap.
 ABody getBody()
          Returns the ABody node which is the body child of this AFuncDecl node.
<T extends NodeInterface>
void
getChildren(Collection<T> collection, NodeFilter<T> filter)
          Adds all children of this AFuncDecl node that are accepted by the NodeFilter filter to collection.
<T extends NodeInterface>
void
getDescendants(Collection<T> collection, NodeFilter<T> filter)
          Adds all descendants of this AFuncDecl node (including the node itself) that are accepted by the NodeFilter filter to collection.
 LinkedList<ALocalDecl> getFormals()
          Returns the possibly empty list of ALocalDecl nodes that are the formals children of this AFuncDecl node.
 int getIndex()
          Returns the index field of this AFuncDecl node.
 TIdentifier getName()
          Returns the TIdentifier node which is the name child of this AFuncDecl node.
 int getNumArgs()
          Returns the num_args field of this AFuncDecl node.
 int getNumLocals()
          Returns the num_locals field of this AFuncDecl node.
 EDecl kindPDecl()
          Returns the EDecl corresponding to the type of this PDecl node.
 void setBody(ABody value)
          Sets the body child of this AFuncDecl node.
 void setFormals(List<? extends ALocalDecl> value)
          Sets the formals children of this AFuncDecl node.
 void setIndex(int value)
          Sets the index field of this AFuncDecl node.
 void setName(TIdentifier value)
          Sets the name child of this AFuncDecl node.
 void setNumArgs(int value)
          Sets the num_args field of this AFuncDecl node.
 void setNumLocals(int value)
          Sets the num_locals field of this AFuncDecl node.
 String toString()
          Returns a textual representation of this AFuncDecl node.
 
Methods inherited from class tip.node.PDecl
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

AFuncDecl

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


AFuncDecl

public AFuncDecl(TIdentifier _name_,
                 List<? extends ALocalDecl> _formals_,
                 ABody _body_)
Creates a new AFuncDecl node with the given nodes as children. The basic child nodes are removed from their previous parents.

Parameters:
_name_ - the TIdentifier node for the Name child of this AFuncDecl node
_formals_ - the list of ALocalDecl nodes for the Formals children of this AFuncDecl node
_body_ - the ABody node for the Body child of this AFuncDecl node

AFuncDecl

public AFuncDecl(TIdentifier _name_,
                 List<? extends ALocalDecl> _formals_,
                 ABody _body_,
                 int _num_locals_,
                 int _num_args_,
                 int _index_)
Creates a new AFuncDecl node with the given nodes as children. The basic child nodes are removed from their previous parents.

Parameters:
_name_ - the TIdentifier node for the Name child of this AFuncDecl node
_formals_ - the list of ALocalDecl nodes for the Formals children of this AFuncDecl node
_body_ - the ABody node for the Body child of this AFuncDecl node
_num_locals_ - the NumLocals child of this AFuncDecl node
_num_args_ - the NumArgs child of this AFuncDecl node
_index_ - the Index child of this AFuncDecl node
Method Detail

clone

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

Specified by:
clone in interface NodeInterface
Specified by:
clone in class PDecl
Returns:
a deep clone of this AFuncDecl node

clone

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

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

toString

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

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

kindPDecl

public EDecl kindPDecl()
Returns the EDecl corresponding to the type of this PDecl node.

Specified by:
kindPDecl in class PDecl
Returns:
the EDecl for this node

getName

public TIdentifier getName()
Returns the TIdentifier node which is the name child of this AFuncDecl node.

Specified by:
getName in class PDecl
Returns:
the TIdentifier node which is the name child of this AFuncDecl node

setName

public void setName(TIdentifier value)
Sets the name child of this AFuncDecl node.

Specified by:
setName in class PDecl
Parameters:
value - the new name child of this AFuncDecl node

getFormals

public LinkedList<ALocalDecl> getFormals()
Returns the possibly empty list of ALocalDecl nodes that are the formals children of this AFuncDecl node.

Returns:
the possibly empty list of ALocalDecl nodes that are the formals children of this AFuncDecl node

setFormals

public void setFormals(List<? extends ALocalDecl> value)
Sets the formals children of this AFuncDecl node.

Parameters:
value - the new formals children of this AFuncDecl node

getBody

public ABody getBody()
Returns the ABody node which is the body child of this AFuncDecl node.

Returns:
the ABody node which is the body child of this AFuncDecl node

setBody

public void setBody(ABody value)
Sets the body child of this AFuncDecl node.

Parameters:
value - the new body child of this AFuncDecl node

getNumLocals

public int getNumLocals()
Returns the num_locals field of this AFuncDecl node.

Returns:
the num_locals field of this AFuncDecl node

setNumLocals

public void setNumLocals(int value)
Sets the num_locals field of this AFuncDecl node.

Parameters:
value - the new num_locals field of this AFuncDecl node

getNumArgs

public int getNumArgs()
Returns the num_args field of this AFuncDecl node.

Returns:
the num_args field of this AFuncDecl node

setNumArgs

public void setNumArgs(int value)
Sets the num_args field of this AFuncDecl node.

Parameters:
value - the new num_args field of this AFuncDecl node

getIndex

public int getIndex()
Returns the index field of this AFuncDecl node.

Specified by:
getIndex in class PDecl
Returns:
the index field of this AFuncDecl node

setIndex

public void setIndex(int value)
Sets the index field of this AFuncDecl node.

Specified by:
setIndex in class PDecl
Parameters:
value - the new index field of this AFuncDecl node

getDescendants

public <T extends NodeInterface> void getDescendants(Collection<T> collection,
                                                     NodeFilter<T> filter)
Adds all descendants of this AFuncDecl 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 AFuncDecl 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.caseAFuncDecl(AFuncDecl) of the Analysis caller.

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

apply

public <A> A apply(Answer<A> caller)
Returns the answer for caller by applying this AFuncDecl 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 AFuncDecl 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 AFuncDecl 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