Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages
TreeChecker Class Reference#include <tree_checker.h>
Inheritance diagram for TreeChecker:
List of all members.
|
Public Types |
enum | Order { Preorder,
Postorder,
Both
} |
| The order in which AST Nodes should be visited. More...
|
enum | Depth { Subtree,
NodeOnly
} |
| Which Nodes in the AST tree should be visited. More...
|
Public Member Functions |
| TreeChecker () |
| TreeChecker (bool verbose, bool warning) |
virtual | ~TreeChecker () |
virtual void | at_node (Node *, Order) |
virtual void | at_unit (unitNode *, Order) |
virtual void | at_proc (procNode *, Order) |
virtual void | at_decl (declNode *, Order) |
virtual void | at_label (labelNode *, Order) |
virtual void | at_case (caseNode *, Order) |
virtual void | at_goto (gotoNode *, Order) |
virtual void | at_conditiongoto (conditiongotoNode *, Order) |
virtual void | at_break (breakNode *, Order) |
virtual void | at_continue (continueNode *, Order) |
virtual void | at_return (returnNode *, Order) |
virtual void | at_if (ifNode *, Order) |
virtual void | at_switch (switchNode *, Order) |
virtual void | at_for (forNode *, Order) |
virtual void | at_loop (loopNode *, Order) |
virtual void | at_call (callNode *, Order) |
virtual void | at_id (idNode *, Order) |
virtual void | at_const (constNode *, Order) |
virtual void | at_unary (unaryNode *, Order) |
virtual void | at_binary (binaryNode *, Order) |
virtual void | at_ternary (ternaryNode *, Order) |
virtual void | at_threeAddr (threeAddrNode *, Order) |
virtual void | at_operand (operandNode *, Order) |
virtual void | at_cast (castNode *, Order) |
virtual void | at_comma (commaNode *, Order) |
virtual void | at_initializer (initializerNode *, Order) |
virtual void | at_type (typeNode *, Order) |
virtual void | at_func (funcNode *, Order) |
virtual void | at_tdef (tdefNode *, Order) |
virtual void | at_array (arrayNode *, Order) |
|
Methods to get and set fields in the class.
|
Order | order () const |
| Return the order in which Nodes of an AST should be visited.
|
Depth | depth () const |
| Return which Nodes of an AST should be visited.
|
|
These methods define the functions that should be performed when different classes of Nodes are encountered in the AST. The most specific "at_" method that matches a given Node's class will be called.
|
virtual void | at_def (defNode *the_def, Order ord) |
virtual void | at_subdecl (subdeclNode *the_subdecl, Order ord) |
virtual void | at_prim (primNode *the_prim, Order ord) |
virtual void | at_ptr (ptrNode *the_ptr, Order ord) |
virtual void | at_sue (sueNode *the_sue, Order ord) |
virtual void | at_struct (structNode *the_struct, Order ord) |
virtual void | at_union (unionNode *the_union, Order ord) |
virtual void | at_enum (enumNode *the_enum, Order ord) |
virtual void | at_suespec (suespecNode *the_suespec, Order ord) |
virtual void | at_expr (exprNode *the_expr, Order ord) |
virtual void | at_index (indexNode *the_index, Order ord) |
virtual void | at_stmt (stmtNode *the_stmt, Order ord) |
virtual void | at_block (blockNode *the_block, Order ord) |
virtual void | at_basicblock (basicblockNode *the_basicblock, Order ord) |
virtual void | at_exprstmt (exprstmtNode *the_exprstmt, Order ord) |
virtual void | at_target (targetNode *the_target, Order ord) |
virtual void | at_selection (selectionNode *the_selection, Order ord) |
virtual void | at_while (whileNode *the_while, Order ord) |
virtual void | at_do (doNode *the_do, Order ord) |
virtual void | at_jump (jumpNode *the_jump, Order ord) |
virtual void | at_attrib (attribNode *the_attrib, Order ord) |
virtual void | at_text (textNode *the_text, Order ord) |
Static Public Member Functions |
void | check () |
void | check (unitNode *) |
Private Member Functions |
void | setPreDismantled (const char *, Node *) |
void | setPostDismantled (const char *, Node *) |
void | checkTree (Node *n, const char *type) |
void | checkField (Node *node, Node *field, const char *type, const char *fieldName, bool isError=true) |
void | checkString (Node *node, string &field, const char *type, const char *fieldName, bool isError=true) |
void | checkConstant (Node *node, constant &field, const char *type, const char *fieldName, bool isError=true) |
template<class T> void | checkOperator (Node *node, Operator *field, const char *type, const char *fieldName, T check, string desc, bool isError=true) |
template<class T> void | checkFieldInList (Node *node, T field, const char *type, const char *fieldName, list< T > &collection, bool isError=true) |
template<class T> void | checkList (Node *node, list< T > &field, const char *type, const char *fieldName, bool isError=true) |
template<class T> void | checkFieldInList (Node *node, list< T > &field, const char *type, const char *fieldName, int count, list< T > &collection, const char *itemName, bool isError=true) |
Private Attributes |
map< Node *, int > | _visitedNodes |
goto_list | _gotos |
label_list | _labels |
proc_list | _procs |
proc_list | _dupProcs |
switch_list | _switches |
decl_list | _decls |
map< labelNode *, int > | _gotoCount |
map< string, int > | _formals |
int | _typeDepth |
int | _arrayDepth |
bool | _verbose |
bool | _warning |
bool | _preDismantled |
bool | _postDismantled |
int | _errorCount |
Member Enumeration Documentation
enum Walker::Depth [inherited]
|
|
|
Which Nodes in the AST tree should be visited.
- Enumeration values:
-
Subtree |
The entire AST should be traversed. |
NodeOnly |
Only the root Node should be visited. |
Definition at line 155 of file walker.h. |
enum Walker::Order [inherited]
|
|
|
The order in which AST Nodes should be visited.
- Enumeration values:
-
Preorder |
Nodes should be visited before their children. |
Postorder |
Nodes should be visited after their children. |
Both |
Nodes should be visited both before and after their children. |
Definition at line 147 of file walker.h.
Referenced by whileNode::walk(), unitNode::walk(), unionNode::walk(), unaryNode::walk(), threeAddrNode::walk(), textNode::walk(), ternaryNode::walk(), tdefNode::walk(), switchNode::walk(), suespecNode::walk(), subdeclNode::walk(), structNode::walk(), returnNode::walk(), ptrNode::walk(), procNode::walk(), primNode::walk(), operandNode::walk(), metastmtNode::walk(), metaexprNode::walk(), labelNode::walk(), initializerNode::walk(), ifNode::walk(), idNode::walk(), gotoNode::walk(), funcNode::walk(), forNode::walk(), exprstmtNode::walk(), enumNode::walk(), doNode::walk(), declNode::walk(), continueNode::walk(), constNode::walk(), conditiongotoNode::walk(), commaNode::walk(), castNode::walk(), caseNode::walk(), callNode::walk(), breakNode::walk(), blockNode::walk(), binaryNode::walk(), basicblockNode::walk(), attribNode::walk(), and arrayNode::walk(). |
Constructor & Destructor Documentation
TreeChecker::TreeChecker |
( |
|
) |
|
|
TreeChecker::TreeChecker |
( |
bool |
verbose, |
|
|
bool |
warning |
|
) |
|
|
TreeChecker::~TreeChecker |
( |
|
) |
[virtual] |
|
Member Function Documentation
virtual void Walker::at_attrib |
( |
attribNode * |
the_attrib, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_basicblock |
( |
basicblockNode * |
the_basicblock, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_block |
( |
blockNode * |
the_block, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
|
Reimplemented from Walker.
Definition at line 543 of file tree_checker.cc.
References _errorCount, _formals, _typeDepth, _verbose, _warning, callNode::args(), checkField(), checkList(), checkTree(), Id, idNode::name(), callNode::name(), Walker::Preorder, callNode::proc(), setPreDismantled(), and Node::typ(). |
|
Reimplemented from Walker.
Definition at line 361 of file tree_checker.cc.
References _switches, checkConstant(), checkField(), checkFieldInList(), checkTree(), caseNode::container(), exprNode::eval(), caseNode::expr(), Walker::Preorder, setPreDismantled(), targetNode::stmt(), and exprNode::value(). |
virtual void Walker::at_def |
( |
defNode * |
the_def, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_do |
( |
doNode * |
the_do, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_enum |
( |
enumNode * |
the_enum, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_expr |
( |
exprNode * |
the_expr, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
|
Reimplemented in NodeLocator, and remove_stale_type_walker.
Definition at line 275 of file walker.h.
References Walker::at_node().
Referenced by Walker::at_binary(), Walker::at_call(), Walker::at_cast(), Walker::at_comma(), Walker::at_index(), Walker::at_initializer(), Walker::at_operand(), Walker::at_ternary(), Walker::at_unary(), and metaexprNode::walk(). |
virtual void Walker::at_exprstmt |
( |
exprstmtNode * |
the_exprstmt, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_index |
( |
indexNode * |
the_index, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_jump |
( |
jumpNode * |
the_jump, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
|
Reimplemented from Walker.
Definition at line 377 of file tree_checker.cc.
References _gotoCount, _gotos, _verbose, _warning, checkField(), checkFieldInList(), checkString(), checkTree(), exprstmtNode::expr(), Expr, labelNode::name(), Walker::Preorder, labelNode::references(), setPreDismantled(), targetNode::stmt(), stmt_list, blockNode::stmts(), and Node::typ(). |
void TreeChecker::at_node |
( |
Node * |
, |
|
|
Order |
|
|
) |
[virtual] |
|
virtual void Walker::at_prim |
( |
primNode * |
the_prim, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
|
Reimplemented from Walker.
Definition at line 302 of file tree_checker.cc.
References _decls, _dupProcs, _errorCount, _gotoCount, _gotos, _labels, _postDismantled, _preDismantled, _switches, procNode::decl(), ProcWalker::decls(), ProcWalker::gotoCount(), ProcWalker::gotos(), ProcWalker::labels(), declNode::name(), Walker::Preorder, proc_list_p, ProcWalker::switches(), and procNode::walk(). |
virtual void Walker::at_ptr |
( |
ptrNode * |
the_ptr, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
|
Reimplemented from Walker.
Definition at line 476 of file tree_checker.cc.
References _procs, _verbose, _warning, checkField(), checkFieldInList(), checkTree(), returnNode::expr(), Id, Walker::Preorder, returnNode::proc(), setPreDismantled(), and Node::typ(). |
virtual void Walker::at_selection |
( |
selectionNode * |
the_selection, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_stmt |
( |
stmtNode * |
the_stmt, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
|
Reimplemented in NodeLocator, W, init_flowproblem_walker, and LivenessWalker.
Definition at line 308 of file walker.h.
References Walker::at_node().
Referenced by Walker::at_attrib(), Walker::at_block(), Walker::at_exprstmt(), Walker::at_jump(), Walker::at_loop(), Walker::at_selection(), Walker::at_target(), Walker::at_threeAddr(), and metastmtNode::walk(). |
virtual void Walker::at_struct |
( |
structNode * |
the_struct, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_subdecl |
( |
subdeclNode * |
the_subdecl, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_sue |
( |
sueNode * |
the_sue, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_suespec |
( |
suespecNode * |
the_suespec, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_target |
( |
targetNode * |
the_target, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_text |
( |
textNode * |
the_text, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
|
Reimplemented from Walker.
Definition at line 656 of file tree_checker.cc.
References threeAddrNode::arg_list(), checkField(), checkList(), checkTree(), Operator::FUNC_CALL, Operator::id(), Operator::is_dismantled_binary(), threeAddrNode::lhs(), threeAddrNode::op(), Walker::Preorder, threeAddrNode::rhs1(), threeAddrNode::rhs2(), setPostDismantled(), Operator::SIZEOF, and threeAddrNode::sizeof_type(). |
|
Reimplemented from Walker.
Definition at line 608 of file tree_checker.cc.
References _typeDepth, checkField(), checkOperator(), checkTree(), UnaryOperator::desc(), unaryNode::expr(), Operator::id(), unaryNode::op(), Walker::Preorder, setPreDismantled(), Operator::SIZEOF, and unaryNode::sizeof_type(). |
virtual void Walker::at_union |
( |
unionNode * |
the_union, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
virtual void Walker::at_while |
( |
whileNode * |
the_while, |
|
|
Order |
ord |
|
) |
[inline, virtual, inherited] |
|
void TreeChecker::check |
( |
unitNode * |
|
) |
[static] |
|
void TreeChecker::check |
( |
|
) |
[static] |
|
void TreeChecker::checkConstant |
( |
Node * |
node, |
|
|
constant & |
field, |
|
|
const char * |
type, |
|
|
const char * |
fieldName, |
|
|
bool |
isError = true |
|
) |
[private] |
|
void TreeChecker::checkField |
( |
Node * |
node, |
|
|
Node * |
field, |
|
|
const char * |
type, |
|
|
const char * |
fieldName, |
|
|
bool |
isError = true |
|
) |
[private] |
|
|
Definition at line 66 of file tree_checker.cc.
References _errorCount.
Referenced by at_array(), at_binary(), at_break(), at_call(), at_case(), at_cast(), at_conditiongoto(), at_continue(), at_decl(), at_for(), at_func(), at_if(), at_label(), at_loop(), at_operand(), at_return(), at_switch(), at_tdef(), at_ternary(), at_threeAddr(), and at_unary(). |
template<class T> |
void TreeChecker::checkFieldInList |
( |
Node * |
node, |
|
|
list< T > & |
field, |
|
|
const char * |
type, |
|
|
const char * |
fieldName, |
|
|
int |
count, |
|
|
list< T > & |
collection, |
|
|
const char * |
itemName, |
|
|
bool |
isError = true |
|
) |
[private] |
|
template<class T> |
void TreeChecker::checkFieldInList |
( |
Node * |
node, |
|
|
T |
field, |
|
|
const char * |
type, |
|
|
const char * |
fieldName, |
|
|
list< T > & |
collection, |
|
|
bool |
isError = true |
|
) |
[private] |
|
template<class T> |
void TreeChecker::checkList |
( |
Node * |
node, |
|
|
list< T > & |
field, |
|
|
const char * |
type, |
|
|
const char * |
fieldName, |
|
|
bool |
isError = true |
|
) |
[private] |
|
template<class T> |
void TreeChecker::checkOperator |
( |
Node * |
node, |
|
|
Operator * |
field, |
|
|
const char * |
type, |
|
|
const char * |
fieldName, |
|
|
T |
check, |
|
|
string |
desc, |
|
|
bool |
isError = true |
|
) |
[private] |
|
void TreeChecker::checkString |
( |
Node * |
node, |
|
|
string & |
field, |
|
|
const char * |
type, |
|
|
const char * |
fieldName, |
|
|
bool |
isError = true |
|
) |
[private] |
|
void TreeChecker::checkTree |
( |
Node * |
n, |
|
|
const char * |
type |
|
) |
[private] |
|
|
Definition at line 55 of file tree_checker.cc.
References _errorCount, _visitedNodes, and print_walker::print().
Referenced by at_array(), at_binary(), at_break(), at_call(), at_case(), at_cast(), at_comma(), at_conditiongoto(), at_const(), at_continue(), at_decl(), at_for(), at_func(), at_goto(), at_id(), at_if(), at_initializer(), at_label(), at_loop(), at_node(), at_operand(), at_return(), at_switch(), at_tdef(), at_ternary(), at_threeAddr(), and at_unary(). |
Depth Walker::depth |
( |
|
) |
const [inline, inherited] |
|
|
Return which Nodes of an AST should be visited.
A value of SubTree specifies that the entire AST should be traversed. A value of NodeOnly specifies that only the root Node in the AST should be visited.
Definition at line 211 of file walker.h.
Referenced by whileNode::walk(), unitNode::walk(), unionNode::walk(), unaryNode::walk(), threeAddrNode::walk(), ternaryNode::walk(), switchNode::walk(), suespecNode::walk(), subdeclNode::walk(), structNode::walk(), returnNode::walk(), ptrNode::walk(), procNode::walk(), operandNode::walk(), metastmtNode::walk(), metaexprNode::walk(), labelNode::walk(), initializerNode::walk(), ifNode::walk(), idNode::walk(), funcNode::walk(), forNode::walk(), exprstmtNode::walk(), enumNode::walk(), doNode::walk(), declNode::walk(), constNode::walk(), conditiongotoNode::walk(), commaNode::walk(), castNode::walk(), caseNode::walk(), callNode::walk(), blockNode::walk(), binaryNode::walk(), basicblockNode::walk(), attribNode::walk(), arrayNode::walk(), and Walker::Walker(). |
Order Walker::order |
( |
|
) |
const [inline, inherited] |
|
|
Return the order in which Nodes of an AST should be visited.
Nodes can be visited before their children (Preorder), after their children (Postorder), or both (Both).
Definition at line 203 of file walker.h.
Referenced by df_number_walker::at_node(), whileNode::walk(), unitNode::walk(), unionNode::walk(), unaryNode::walk(), threeAddrNode::walk(), textNode::walk(), ternaryNode::walk(), tdefNode::walk(), switchNode::walk(), suespecNode::walk(), subdeclNode::walk(), structNode::walk(), returnNode::walk(), ptrNode::walk(), procNode::walk(), primNode::walk(), operandNode::walk(), metastmtNode::walk(), metaexprNode::walk(), labelNode::walk(), initializerNode::walk(), ifNode::walk(), idNode::walk(), gotoNode::walk(), funcNode::walk(), forNode::walk(), exprstmtNode::walk(), enumNode::walk(), doNode::walk(), declNode::walk(), continueNode::walk(), constNode::walk(), conditiongotoNode::walk(), commaNode::walk(), castNode::walk(), caseNode::walk(), callNode::walk(), breakNode::walk(), blockNode::walk(), binaryNode::walk(), basicblockNode::walk(), attribNode::walk(), and arrayNode::walk(). |
void TreeChecker::setPostDismantled |
( |
const char * |
, |
|
|
Node * |
|
|
) |
[private] |
|
void TreeChecker::setPreDismantled |
( |
const char * |
, |
|
|
Node * |
|
|
) |
[private] |
|
|
Definition at line 41 of file tree_checker.cc.
References _preDismantled.
Referenced by at_binary(), at_break(), at_call(), at_case(), at_cast(), at_comma(), at_continue(), at_decl(), at_for(), at_if(), at_initializer(), at_label(), at_loop(), at_return(), at_switch(), at_ternary(), and at_unary(). |
Member Data Documentation
int TreeChecker::_arrayDepth [private]
|
|
int TreeChecker::_errorCount [private]
|
|
map<string, int > TreeChecker::_formals [private]
|
|
map<labelNode *, int> TreeChecker::_gotoCount [private]
|
|
bool TreeChecker::_postDismantled [private]
|
|
bool TreeChecker::_preDismantled [private]
|
|
int TreeChecker::_typeDepth [private]
|
|
bool TreeChecker::_verbose [private]
|
|
map<Node *, int> TreeChecker::_visitedNodes [private]
|
|
bool TreeChecker::_warning [private]
|
|
The documentation for this class was generated from the following files:
|