C-Breeze
C Compiler Infrastructure

[ Project home page]
Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Visitor Class Reference
[AST Traversal functional classes.]

A functional class to peform a function on a Node, depending on its class. More...

#include <visitor.h>

Inheritance diagram for Visitor:

semcheck_expr_visitor tree_visitor print_tree_visitor List of all members.

Public Member Functions

 Visitor ()
 Create a new instance of a Visitor.

"at_" methods
These methods define the functions that should be performed when different classes of Nodes are visited. The most specific "at_" method that matches a given Node's class will be called.

virtual void at_node (Node *the_node)
virtual void at_unit (unitNode *the_unit)
virtual void at_def (defNode *the_def)
virtual void at_decl (declNode *the_decl)
virtual void at_subdecl (subdeclNode *the_subdecl)
virtual void at_proc (procNode *the_proc)
virtual void at_type (typeNode *the_type)
virtual void at_prim (primNode *the_prim)
virtual void at_tdef (tdefNode *the_tdef)
virtual void at_ptr (ptrNode *the_ptr)
virtual void at_array (arrayNode *the_array)
virtual void at_func (funcNode *the_func)
virtual void at_sue (sueNode *the_sue)
virtual void at_struct (structNode *the_struct)
virtual void at_union (unionNode *the_union)
virtual void at_enum (enumNode *the_enum)
virtual void at_suespec (suespecNode *the_suespec)
virtual void at_expr (exprNode *the_expr)
virtual void at_index (indexNode *the_index)
virtual void at_const (constNode *the_const)
virtual void at_id (idNode *the_id)
virtual void at_binary (binaryNode *the_binary)
virtual void at_unary (unaryNode *the_unary)
virtual void at_cast (castNode *the_cast)
virtual void at_comma (commaNode *the_comma)
virtual void at_ternary (ternaryNode *the_ternary)
virtual void at_call (callNode *the_call)
virtual void at_initializer (initializerNode *the_initializer)
virtual void at_stmt (stmtNode *the_stmt)
virtual void at_block (blockNode *the_block)
virtual void at_basicblock (basicblockNode *the_basicblock)
virtual void at_exprstmt (exprstmtNode *the_exprstmt)
virtual void at_target (targetNode *the_target)
virtual void at_label (labelNode *the_label)
virtual void at_case (caseNode *the_case)
virtual void at_selection (selectionNode *the_selection)
virtual void at_if (ifNode *the_if)
virtual void at_switch (switchNode *the_switch)
virtual void at_loop (loopNode *the_loop)
virtual void at_while (whileNode *the_while)
virtual void at_do (doNode *the_do)
virtual void at_for (forNode *the_for)
virtual void at_jump (jumpNode *the_jump)
virtual void at_goto (gotoNode *the_goto)
virtual void at_continue (continueNode *the_continue)
virtual void at_break (breakNode *the_break)
virtual void at_return (returnNode *the_return)
virtual void at_attrib (attribNode *the_attrib)
virtual void at_operand (operandNode *the_oper)
virtual void at_conditiongoto (conditiongotoNode *the_condgoto)
virtual void at_threeAddr (threeAddrNode *the_3addr)
virtual void at_text (textNode *the_text)

Detailed Description

A functional class to peform a function on a Node, depending on its class.

Corresponding to each class in the Node hierarchy, Visitor defines an "at_" method. To specify the function that should be performed for Nodes of a particular class, create a subclass of Visitor that overrides the "at_" method corresponding to that class. By default, the "at_" methods perform no action. Thus, a Visitor subclass only needs to override the "at_" methods corresponding to Node types that are relevant to that visitor.

When a Node is visited, the most specific "at_" method that has been defined for that Node will be called with the Node. For example, if a Visitor subclass overrides "at_decl()", but not "at_subdecl()," then the "at_decl()" method wil be called for any declNodes or subDeclnodes that are visited. However, if a Visitor subclass overrides both "at_decl()" and "at_subdecl," then the "at_decl()" method will be called for any declNodes that are visited, and the "at_subdecl()" method will be called for any subdeclNodes that are visited. If you wish for both "at_subdecl()" and "at_decl()" to be called for subdeclNodes, then you should explicitly call the "at_decl()" method from "at_subdecl()."

A visitor may modify any fields of the Nodes it visits, including fields that contain sub-Nodes.

To use a visitor "my_visitor" to visit "my_node," use the code:

  my_node->visit(my_visitor);
  

Visitors only visit the Node they are given, and not any of its sub-Nodes. If you wish to visit the entire AST rooted at a Node, use a Walker or a Changer. You may also recurse to select sub-Nodes using code like the following within an "at_" method:

  sub_node->visit(*this);
  

See also:
Walker

Changer

Node::visit

Definition at line 93 of file visitor.h.


Constructor & Destructor Documentation

Visitor::Visitor   [inline]
 

Create a new instance of a Visitor.

Definition at line 101 of file visitor.h.


Member Function Documentation

virtual void Visitor::at_array arrayNode   the_array [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 142 of file visitor.h.

References at_type().

Referenced by arrayNode::visit().

virtual void Visitor::at_attrib attribNode   the_attrib [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 253 of file visitor.h.

References at_stmt().

Referenced by attribNode::visit().

virtual void Visitor::at_basicblock basicblockNode   the_basicblock [inline, virtual]
 

Definition at line 202 of file visitor.h.

References at_block().

Referenced by basicblockNode::visit().

virtual void Visitor::at_binary binaryNode   the_binary [inline, virtual]
 

Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor.

Definition at line 175 of file visitor.h.

References at_expr().

Referenced by binaryNode::visit().

virtual void Visitor::at_block blockNode   the_block [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 199 of file visitor.h.

References at_stmt().

Referenced by at_basicblock(), and blockNode::visit().

virtual void Visitor::at_break breakNode   the_break [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 247 of file visitor.h.

References at_jump().

Referenced by breakNode::visit().

virtual void Visitor::at_call callNode   the_call [inline, virtual]
 

Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor.

Definition at line 190 of file visitor.h.

References at_expr().

Referenced by callNode::visit().

virtual void Visitor::at_case caseNode   the_case [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 214 of file visitor.h.

References at_target().

Referenced by caseNode::visit().

virtual void Visitor::at_cast castNode   the_cast [inline, virtual]
 

Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor.

Definition at line 181 of file visitor.h.

References at_expr().

Referenced by castNode::visit().

virtual void Visitor::at_comma commaNode   the_comma [inline, virtual]
 

Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor.

Definition at line 184 of file visitor.h.

References at_expr().

Referenced by commaNode::visit().

virtual void Visitor::at_conditiongoto conditiongotoNode   the_condgoto [inline, virtual]
 

Definition at line 259 of file visitor.h.

References at_goto().

Referenced by conditiongotoNode::visit().

virtual void Visitor::at_const constNode   the_const [inline, virtual]
 

Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor.

Definition at line 169 of file visitor.h.

References at_index().

Referenced by constNode::visit().

virtual void Visitor::at_continue continueNode   the_continue [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 244 of file visitor.h.

References at_jump().

Referenced by continueNode::visit().

virtual void Visitor::at_decl declNode   the_decl [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 121 of file visitor.h.

References at_def().

Referenced by at_subdecl(), and declNode::visit().

virtual void Visitor::at_def defNode   the_def [inline, virtual]
 

Definition at line 118 of file visitor.h.

References at_node().

Referenced by at_decl(), and at_proc().

virtual void Visitor::at_do doNode   the_do [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 232 of file visitor.h.

References at_loop().

Referenced by doNode::visit().

virtual void Visitor::at_enum enumNode   the_enum [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 157 of file visitor.h.

References at_sue().

Referenced by enumNode::visit().

virtual void Visitor::at_expr exprNode   the_expr [inline, virtual]
 

Definition at line 163 of file visitor.h.

References at_node().

Referenced by at_binary(), at_call(), at_cast(), at_comma(), at_index(), at_initializer(), at_operand(), at_ternary(), at_unary(), and metaexprNode::visit().

virtual void Visitor::at_exprstmt exprstmtNode   the_exprstmt [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 205 of file visitor.h.

References at_stmt().

Referenced by exprstmtNode::visit().

virtual void Visitor::at_for forNode   the_for [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 235 of file visitor.h.

References at_loop().

Referenced by forNode::visit().

virtual void Visitor::at_func funcNode   the_func [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 145 of file visitor.h.

References at_type().

Referenced by funcNode::visit().

virtual void Visitor::at_goto gotoNode   the_goto [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 241 of file visitor.h.

References at_jump().

Referenced by at_conditiongoto(), and gotoNode::visit().

virtual void Visitor::at_id idNode   the_id [inline, virtual]
 

Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor.

Definition at line 172 of file visitor.h.

References at_index().

Referenced by idNode::visit().

virtual void Visitor::at_if ifNode   the_if [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 220 of file visitor.h.

References at_selection().

Referenced by ifNode::visit().

virtual void Visitor::at_index indexNode   the_index [inline, virtual]
 

Definition at line 166 of file visitor.h.

References at_expr().

Referenced by at_const(), and at_id().

virtual void Visitor::at_initializer initializerNode   the_initializer [inline, virtual]
 

Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor.

Definition at line 193 of file visitor.h.

References at_expr().

Referenced by initializerNode::visit().

virtual void Visitor::at_jump jumpNode   the_jump [inline, virtual]
 

Definition at line 238 of file visitor.h.

References at_stmt().

Referenced by at_break(), at_continue(), at_goto(), and at_return().

virtual void Visitor::at_label labelNode   the_label [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 211 of file visitor.h.

References at_target().

Referenced by labelNode::visit().

virtual void Visitor::at_loop loopNode   the_loop [inline, virtual]
 

Definition at line 226 of file visitor.h.

References at_stmt().

Referenced by at_do(), at_for(), and at_while().

virtual void Visitor::at_node Node   the_node [inline, virtual]
 

Definition at line 111 of file visitor.h.

Referenced by at_def(), at_expr(), at_stmt(), at_text(), at_type(), and at_unit().

virtual void Visitor::at_operand operandNode   the_oper [inline, virtual]
 

Definition at line 256 of file visitor.h.

References at_expr().

Referenced by operandNode::visit().

virtual void Visitor::at_prim primNode   the_prim [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 133 of file visitor.h.

References at_type().

Referenced by primNode::visit().

virtual void Visitor::at_proc procNode   the_proc [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 127 of file visitor.h.

References at_def().

Referenced by procNode::visit().

virtual void Visitor::at_ptr ptrNode   the_ptr [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 139 of file visitor.h.

References at_type().

Referenced by ptrNode::visit().

virtual void Visitor::at_return returnNode   the_return [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 250 of file visitor.h.

References at_jump().

Referenced by returnNode::visit().

virtual void Visitor::at_selection selectionNode   the_selection [inline, virtual]
 

Definition at line 217 of file visitor.h.

References at_stmt().

Referenced by at_if(), and at_switch().

virtual void Visitor::at_stmt stmtNode   the_stmt [inline, virtual]
 

Definition at line 196 of file visitor.h.

References at_node().

Referenced by at_attrib(), at_block(), at_exprstmt(), at_jump(), at_loop(), at_selection(), at_target(), at_threeAddr(), and metastmtNode::visit().

virtual void Visitor::at_struct structNode   the_struct [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 151 of file visitor.h.

References at_sue().

Referenced by structNode::visit().

virtual void Visitor::at_subdecl subdeclNode   the_subdecl [inline, virtual]
 

Definition at line 124 of file visitor.h.

References at_decl().

Referenced by subdeclNode::visit().

virtual void Visitor::at_sue sueNode   the_sue [inline, virtual]
 

Reimplemented in print_tree_visitor.

Definition at line 148 of file visitor.h.

References at_type().

Referenced by at_enum(), at_struct(), and at_union().

virtual void Visitor::at_suespec suespecNode   the_suespec [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 160 of file visitor.h.

References at_type().

Referenced by suespecNode::visit().

virtual void Visitor::at_switch switchNode   the_switch [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 223 of file visitor.h.

References at_selection().

Referenced by switchNode::visit().

virtual void Visitor::at_target targetNode   the_target [inline, virtual]
 

Definition at line 208 of file visitor.h.

References at_stmt().

Referenced by at_case(), and at_label().

virtual void Visitor::at_tdef tdefNode   the_tdef [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 136 of file visitor.h.

References at_type().

Referenced by tdefNode::visit().

virtual void Visitor::at_ternary ternaryNode   the_ternary [inline, virtual]
 

Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor.

Definition at line 187 of file visitor.h.

References at_expr().

Referenced by ternaryNode::visit().

virtual void Visitor::at_text textNode   the_text [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 265 of file visitor.h.

References at_node().

Referenced by textNode::visit().

virtual void Visitor::at_threeAddr threeAddrNode   the_3addr [inline, virtual]
 

Definition at line 262 of file visitor.h.

References at_stmt().

Referenced by threeAddrNode::visit().

virtual void Visitor::at_type typeNode   the_type [inline, virtual]
 

Definition at line 130 of file visitor.h.

References at_node().

Referenced by at_array(), at_func(), at_prim(), at_ptr(), at_sue(), at_suespec(), and at_tdef().

virtual void Visitor::at_unary unaryNode   the_unary [inline, virtual]
 

Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor.

Definition at line 178 of file visitor.h.

References at_expr().

Referenced by unaryNode::visit().

virtual void Visitor::at_union unionNode   the_union [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 154 of file visitor.h.

References at_sue().

Referenced by unionNode::visit().

virtual void Visitor::at_unit unitNode   the_unit [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 115 of file visitor.h.

References at_node().

Referenced by unitNode::visit().

virtual void Visitor::at_while whileNode   the_while [inline, virtual]
 

Reimplemented in tree_visitor, and print_tree_visitor.

Definition at line 229 of file visitor.h.

References at_loop().

Referenced by whileNode::visit().


The documentation for this class was generated from the following file:

Generated on August 27, 2003
Back to the C-Breeze home page