#include <visitor.h>
Inheritance diagram for Visitor::
Public Methods | |
Visitor () | |
Create a new instance of a Visitor. More... | |
"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_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_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);
|
Create a new instance of a Visitor.
|
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
|
|
Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor. |
|
Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor. |
|
Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
|
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
|
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor. |
|
|
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
|
|
|
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
|
|
|
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
|
|
Reimplemented in print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
|
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
|
|
Reimplemented in semcheck_expr_visitor, tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |
|
Reimplemented in tree_visitor, and print_tree_visitor. |