|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Visitor Class ReferenceA functional class to peform a function on a Node, depending on its class.
More...
|
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) |
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);
Definition at line 93 of file visitor.h.
|
Create a new instance of a Visitor.
|
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 142 of file visitor.h. References at_type(). Referenced by arrayNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 253 of file visitor.h. References at_stmt(). Referenced by attribNode::visit(). |
|
Definition at line 202 of file visitor.h. References at_block(). Referenced by basicblockNode::visit(). |
|
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(). |
|
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(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 247 of file visitor.h. References at_jump(). Referenced by breakNode::visit(). |
|
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(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 214 of file visitor.h. References at_target(). Referenced by caseNode::visit(). |
|
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(). |
|
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(). |
|
Definition at line 259 of file visitor.h. References at_goto(). Referenced by conditiongotoNode::visit(). |
|
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(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 244 of file visitor.h. References at_jump(). Referenced by continueNode::visit(). |
|
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(). |
|
Definition at line 118 of file visitor.h. References at_node(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 232 of file visitor.h. References at_loop(). Referenced by doNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 157 of file visitor.h. References at_sue(). Referenced by enumNode::visit(). |
|
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(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 205 of file visitor.h. References at_stmt(). Referenced by exprstmtNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 235 of file visitor.h. References at_loop(). Referenced by forNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 145 of file visitor.h. References at_type(). Referenced by funcNode::visit(). |
|
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(). |
|
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(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 220 of file visitor.h. References at_selection(). Referenced by ifNode::visit(). |
|
Definition at line 166 of file visitor.h. References at_expr(). Referenced by at_const(), and at_id(). |
|
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(). |
|
Definition at line 238 of file visitor.h. References at_stmt(). Referenced by at_break(), at_continue(), at_goto(), and at_return(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 211 of file visitor.h. References at_target(). Referenced by labelNode::visit(). |
|
Definition at line 226 of file visitor.h. References at_stmt(). Referenced by at_do(), at_for(), and at_while(). |
|
Definition at line 111 of file visitor.h. Referenced by at_def(), at_expr(), at_stmt(), at_text(), at_type(), and at_unit(). |
|
Definition at line 256 of file visitor.h. References at_expr(). Referenced by operandNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 133 of file visitor.h. References at_type(). Referenced by primNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 127 of file visitor.h. References at_def(). Referenced by procNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 139 of file visitor.h. References at_type(). Referenced by ptrNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 250 of file visitor.h. References at_jump(). Referenced by returnNode::visit(). |
|
Definition at line 217 of file visitor.h. References at_stmt(). Referenced by at_if(), and at_switch(). |
|
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(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 151 of file visitor.h. References at_sue(). Referenced by structNode::visit(). |
|
Definition at line 124 of file visitor.h. References at_decl(). Referenced by subdeclNode::visit(). |
|
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(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 160 of file visitor.h. References at_type(). Referenced by suespecNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 223 of file visitor.h. References at_selection(). Referenced by switchNode::visit(). |
|
Definition at line 208 of file visitor.h. References at_stmt(). Referenced by at_case(), and at_label(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 136 of file visitor.h. References at_type(). Referenced by tdefNode::visit(). |
|
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(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 265 of file visitor.h. References at_node(). Referenced by textNode::visit(). |
|
Definition at line 262 of file visitor.h. References at_stmt(). Referenced by threeAddrNode::visit(). |
|
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(). |
|
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(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 154 of file visitor.h. References at_sue(). Referenced by unionNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 115 of file visitor.h. References at_node(). Referenced by unitNode::visit(). |
|
Reimplemented in tree_visitor, and print_tree_visitor. Definition at line 229 of file visitor.h. References at_loop(). Referenced by whileNode::visit(). |
Generated on August 27, 2003
Back to the C-Breeze home page