ROSE 0.11.145.147

Abstract syntax tree traversals.
Enumerations  
enum class  Order { PRE = 0x01 , POST = 0x02 } 
Order that visitor is called for node w.r.t. More...  
Functions  
template<class T , class Functor >  
void  forward (SgNode *ast, Functor functor) 
Traverse an AST in a forward direction.  
template<class T , class Functor >  
void  forwardPre (SgNode *ast, Functor functor) 
Traverse an AST in a forward direction with previsit only.  
template<class T , class Functor >  
void  forwardPost (SgNode *ast, Functor functor) 
Traverse an AST in a forward direction with postvisit only.  
template<class T , class Functor >  
void  reverse (SgNode *ast, Functor functor) 
Traverse an AST in the reverse direction.  
template<class T , class Functor >  
void  reversePre (SgNode *ast, Functor functor) 
Traverse an AST in the reverse with previsit only.  
template<class T , class Functor >  
void  reversePost (SgNode *ast, Functor functor) 
Traverse an AST in the reverse with postvisit only.  
template<class T , class Functor >  
T *  findParentSatisying (SgNode *ast, Functor functor) 
Reverse traversal that finds the first node satisfying the predicate.  
template<class T >  
T *  findParentTyped (SgNode *ast) 
Find the closest parent of specified type.  
template<class T >  
std::vector< T * >  findDescendantsTyped (SgNode *ast) 
Find all descendants of specified type.  

strong 
Order that visitor is called for node w.r.t.
children.
Enumerator  

PRE  Visitor is called before visiting the node's children. 
POST  Visitor is called after visiting the node's children. 
Definition at line 19 of file AST/Traversal.h.
void Rose::AST::Traversal::forward  (  SgNode *  ast, 
Functor  functor  
) 
Traverse an AST in a forward direction.
This function traverses the specified ast
by following the child edges of the tree. It calls specified functor at each node along the way that can be dynamically cast to a T
pointer, and again when backtracking. In other words, when called for node n
, this traversal invokes the functor with the arguments n
and Order::PRE, then it recursively visits each child of n
, then it invokes the visitor a second time with arguments n
and Order::POST. The node argument of the functor is of type T*
.
Example: Here's an example comparing the original AstPrePostProcessing
to this newer function:
Here's the corresponding code for the newer style traversals:
Definition at line 183 of file AST/Traversal.h.
void Rose::AST::Traversal::forwardPre  (  SgNode *  ast, 
Functor  functor  
) 
Traverse an AST in a forward direction with previsit only.
This function is similar to the plain forward traversal but instead of calling the functor both before and after visiting a node's children, this traversal calls the functor only before visiting the children. The functor is called with one argument: a nonnull pointer to the node being visited, and this argument is of type T*
.
Definition at line 193 of file AST/Traversal.h.
void Rose::AST::Traversal::forwardPost  (  SgNode *  ast, 
Functor  functor  
) 
Traverse an AST in a forward direction with postvisit only.
This function is similar to the plain forward traversal but instead of calling the functor both before and after visiting a node's children, this traversal calls the functor only after visiting the children. The functor is called with one argument: a nonnull pointer to the node being visited, and this argument is of type T*
.
Definition at line 203 of file AST/Traversal.h.
void Rose::AST::Traversal::reverse  (  SgNode *  ast, 
Functor  functor  
) 
Traverse an AST in the reverse direction.
Traverses the specified AST following the childtoparent edges. The functor is called for each node before and after its parent is visited. The functor is called with two arguments, the node pointer and an indication of when the functor is being called. The second argument being Order::PRE before the node's parent is visited, and Order::POST after the parent is visited.
Definition at line 214 of file AST/Traversal.h.
void Rose::AST::Traversal::reversePre  (  SgNode *  ast, 
Functor  functor  
) 
Traverse an AST in the reverse with previsit only.
This function is similar to the plain reverse traversal, but only calls the functor before visiting the node's parents. The functor takes only one argument: a pointer to the node being visited.
Definition at line 223 of file AST/Traversal.h.
void Rose::AST::Traversal::reversePost  (  SgNode *  ast, 
Functor  functor  
) 
Traverse an AST in the reverse with postvisit only.
This function is similar to the plain reverse traversal, but only calls the functor after visiting the node's parents. The functor takes only one argument: a pointer to the node being visited.
Definition at line 232 of file AST/Traversal.h.
T * Rose::AST::Traversal::findParentSatisying  (  SgNode *  ast, 
Functor  functor  
) 
Reverse traversal that finds the first node satisfying the predicate.
This is a reverse traversal starting at the specified node and following childtoparent edges to find the first node having dynamic type T
and for which the userspecified predicate returns true. The predicate takes one argument: a pointer to a node. The return value might be the same node as the argument. If the argument is null or if no satisfying node is found, then this function returns null.
Definition at line 244 of file AST/Traversal.h.
T * Rose::AST::Traversal::findParentTyped  (  SgNode *  ast  ) 
Find the closest parent of specified type.
Traverses the specified AST and returns a pointer to the closest parent of the specified type. The return value might be the argument itself. If the argument is null or if no such node type can be found, then this function returns null.
Definition at line 256 of file AST/Traversal.h.
std::vector< T * > Rose::AST::Traversal::findDescendantsTyped  (  SgNode *  ast  ) 
Find all descendants of specified type.
Traverses the specified AST in depthfirst preorder and builds a vector that points to all the nodes of the tree that are of the specified type. All returned pointers are nonnull. The specified root of the AST might be one of the pointers returned.
Definition at line 269 of file AST/Traversal.h.