tip.node
Interface NodeInterface

All Known Subinterfaces:
ITarget, ITyped
All Known Implementing Classes:
ABinopExp, ABlock, ABlockStm, ABody, ADeclStm, ADerefExp, ADivideBinop, AEqBinop, AFuncDecl, AFunctionCallExp, AFunctionPtrCallExp, AGtBinop, AIfThenElseStm, AIfThenStm, AInputExp, AIntConstExp, ALocalDecl, AMallocExp, AMinusBinop, ANullExp, AOutputStm, APlusBinop, APointerExp, AProgram, AReturnStm, ATimesBinop, AVarExp, AWhileStm, EOF, Node, PBinop, PBlock, PBody, PDecl, PExp, PProgram, PStm, Start, TAnd, TAssign, TComma, TCommentBlock, TCommentSingle, TDiv, TElse, TEq, TGt, TIdentifier, TIf, TInput, TIntegerConst, TLBrace, TLPar, TMalloc, TMinus, TNull, Token, TOutput, TPlus, TRBrace, TReturn, TRPar, TSemicolon, TStar, TVar, TWhile, TWhiteSpace, AAssignPtrStm, AAssignVarStm

public interface NodeInterface


Method Summary
 void apply(Analysis caller)
          Applies the Analysis visitor to this node.
<A> A
apply(Answer<A> caller)
          Returns the answer for caller by applying this node to the Answer visitor.
<Q> void
apply(Question<Q> caller, Q question)
          Applies this node to the Question visitor caller.
<Q,A> A
apply(QuestionAnswer<Q,A> caller, Q question)
          Returns the answer for answer by applying this node with the question to the QuestionAnswer visitor.
 void checkOptionalInvariant()
           
 Node clone()
           
 Node clone(Map<Node,Node> oldToNewMap)
           
<T extends NodeInterface>
T
getAncestor(Class<T> classType)
          Returns the nearest ancestor of this node (including itself) which is a subclass of classType.
<T extends NodeInterface>
T
getAncestor(Class<T> classType, Class<? extends NodeInterface> guardClass)
          Returns the nearest ancestor of this node (including itself) which is a subclass of classType.
<T extends NodeInterface>
T
getAncestor(NodeFilter<T> filter)
          Returns the nearest ancestor of this node (including itself) which is accepted by the NodeFilter filter.
<T extends NodeInterface>
List<T>
getChildren(Class<T> classType)
          Returns the collection of children to this node which are subtypes of classType.
<T extends NodeInterface>
void
getChildren(Collection<T> collection, NodeFilter<T> filter)
          Adds all children of this NodeInterface node that are accepted by the NodeFilter filter to collection.
<T extends NodeInterface>
List<T>
getChildren(NodeFilter<T> filter)
          Returns the collection of children to this node which are accepted by the NodeFilter filter.
<T extends NodeInterface>
Collection<T>
getDescendants(Class<T> classType)
          Returns the collection of descendants to this node (including itself) which are subtypes of classType.
<T extends NodeInterface>
Collection<T>
getDescendants(Class<T> classType, Class<? extends NodeInterface> guardClass)
          Returns the collection of descendants to this node (including itself) which are subtypes of classType.
<T extends NodeInterface>
void
getDescendants(Collection<T> collection, NodeFilter<T> filter)
          Adds all descendants of this NodeInterface node (including the node itself) that are accepted by the NodeFilter filter to collection.
<T extends NodeInterface>
Collection<T>
getDescendants(NodeFilter<T> filter)
          Returns the collection of descendants to this node (including the node itself) which are accepted by the NodeFilter filter.
 boolean isOptionalInvariant()
           
 Node parent()
          Returns the parent node of this node.
 void replaceBy(Node node)
          Replaces this node by node in the AST.
 void setOptionalInvariant(boolean value)
           
 

Method Detail

clone

Node clone()

clone

Node clone(Map<Node,Node> oldToNewMap)

parent

Node parent()
Returns the parent node of this node.

Returns:
the parent node of this node

replaceBy

void replaceBy(Node node)
Replaces this node by node in the AST. If this node has no parent node, this results in a NullPointerException. The replacing node is removed from its previous parent.

Parameters:
node - the node replacing this node in the AST

getAncestor

<T extends NodeInterface> T getAncestor(NodeFilter<T> filter)
Returns the nearest ancestor of this node (including itself) which is accepted by the NodeFilter filter. Traversal is stopped if the node is guarded by the NodeFilter filter.

Parameters:
filter - the NodeFilter used
Returns:
the nearest ancestor of this node

getAncestor

<T extends NodeInterface> T getAncestor(Class<T> classType)
Returns the nearest ancestor of this node (including itself) which is a subclass of classType.

Parameters:
classType - the superclass used
Returns:
the nearest ancestor of this node

getAncestor

<T extends NodeInterface> T getAncestor(Class<T> classType,
                                        Class<? extends NodeInterface> guardClass)
Returns the nearest ancestor of this node (including itself) which is a subclass of classType. Traversal is stopped if a subclass of guardClass is found.

Parameters:
classType - the superclass used for filtering
guardClass - the superclass used for guarding
Returns:
the nearest ancestor of this node

getDescendants

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

Parameters:
collection - the collection to which the descendants are added
filter - the NodeFilter used

getDescendants

<T extends NodeInterface> Collection<T> getDescendants(NodeFilter<T> filter)
Returns the collection of descendants to this node (including the node itself) which are accepted by the NodeFilter filter. Descandants of nodes which are guarded by the NodeFilter filter are not included.

Parameters:
filter - the NodeFilter used
Returns:
a collection of the accepted descendants

getDescendants

<T extends NodeInterface> Collection<T> getDescendants(Class<T> classType)
Returns the collection of descendants to this node (including itself) which are subtypes of classType.

Parameters:
classType - the supertype for all collected descendants
Returns:
a collection of the accepted nodes

getDescendants

<T extends NodeInterface> Collection<T> getDescendants(Class<T> classType,
                                                       Class<? extends NodeInterface> guardClass)
Returns the collection of descendants to this node (including itself) which are subtypes of classType. Descendants of subtypes of guardClass are not included.

Parameters:
classType - the supertype for all collected descendants
Returns:
a collection of the accepted nodes

getChildren

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

Parameters:
collection - the collection to which the children are added
filter - the NodeFilter used

getChildren

<T extends NodeInterface> List<T> getChildren(NodeFilter<T> filter)
Returns the collection of children to this node which are accepted by the NodeFilter filter.

Parameters:
filter - the NodeFilter used
Returns:
a collection of the accepted children

getChildren

<T extends NodeInterface> List<T> getChildren(Class<T> classType)
Returns the collection of children to this node which are subtypes of classType.

Parameters:
classType - the supertype for all collected children
Returns:
a collection of the accepted nodes

apply

void apply(Analysis caller)
Applies the Analysis visitor to this node.

Parameters:
caller - the Analysis to which this node is applied

apply

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

Parameters:
caller - the Answer to which this node is applied
Returns:
the answer as returned from caller

apply

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

Parameters:
caller - the Question to which this node is applied
question - the question provided to caller

apply

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

Parameters:
caller - the QuestionAnswer to which this node is applied
question - the question provided to answer
Returns:
the answer as returned from answer

isOptionalInvariant

boolean isOptionalInvariant()

setOptionalInvariant

void setOptionalInvariant(boolean value)

checkOptionalInvariant

void checkOptionalInvariant()