#include <ast.h>
Inheritance diagram for blockNode::
Public Methods | |
blockNode (decl_list *decls, stmt_list *stmts, const Coord left_coord=Coord::Unknown, const Coord right_brace=Coord::Unknown) | |
Create a new block. More... | |
virtual | ~blockNode () |
Destroy a blockNode. More... | |
typeNode * | base_type (bool TdefIndir) const |
Return the base data type of a node. More... | |
virtual void | dataflow (FlowVal *v, FlowProblem &fp) |
Run the dataflow analyzer. More... | |
virtual Node * | clone () const |
Clone the input node. More... | |
virtual void | output_stmt (output_context &ct, Node *par) |
Output a statement. More... | |
Accessors | |
Methods to get and set fields in the class. | |
decl_list & | decls () |
const decl_list & | decls () const |
stmt_list & | stmts () |
const stmt_list & | stmts () const |
Coord | right_brace () const |
void | right_brace (const Coord right_brace) |
AST Traversal | |
virtual void | visit (Visitor *the_visitor) |
Dispatch a Visitor. More... | |
virtual void | walk (Walker &the_walker) |
Dispatch a Walker. More... | |
virtual Node * | change (Changer &the_changer, bool redispatch=false) |
Dispatch a Changer. More... | |
Static Public Methods | |
blockNode * | toBlock (stmtNode *stmt, Coord coord) |
Convert to block. More... | |
Private Attributes | |
TREE decl_list | _decls |
the local declarations. More... | |
TREE stmt_list | _stmts |
the statements. More... | |
Coord | _right_brace |
the location of the right curly brace. More... |
This class represents a curly-brace delimited compound statement or statement block. It generally introduces a new scope, allowing new declarations as well as code. It is used as the top-level container for procedure bodies, branch bodies, loop bodies, etc. The general form is:
{ <declarations> <statements> }
The NodeType is Block.
|
Create a new block. The new block has the given list of declarations and statements. In both bases, the actual declarations and statements are removed from the lists, and the lists are deleted. Null may be passed for either argument.
|
|
Destroy a blockNode.
|
|
Return the base data type of a node. This method differs from the Node::type() method in two respects. First, it follows some of the simple type inferences. For example, calling it on an idNode will return the type of its declaration. Second, the boolean argument indicates whether or not to follow typedef links.
Reimplemented from Node. |
|
Dispatch a Changer. This abstract method works much the walker, but allows the tree to be changed.
Reimplemented from Node. Reimplemented in basicblockNode. |
|
Clone the input node. This is not a "deep" clone, so be careful. For a deep clone, use the clone_changer class.
Reimplemented from Node. Reimplemented in basicblockNode. |
|
Run the dataflow analyzer. Each subclass overrides this method to define it's semantics for dataflow analysis. It alters the input flow value to reflect the effect of the node within the given flow problem, calling dataflow() on it's subtrees as necessary. See the dataflow analysis documentation for more information.
Reimplemented from Node. |
|
|
|
|
|
Output a statement.
Reimplemented from stmtNode. |
|
|
|
|
|
|
|
|
|
Convert to block. This method is used primarily by the parser to make sure that all branch bodies and loop bodies are represented by blockNodes, even if they aren't in the source code. For example:
if (cond) x = x + 1; Even though the body of the branch is just a single statement, we build a block containing that one statement:
if (cond) { x = x + 1; } This simplifies many other kinds of processing. For example, it makes it easy to add statements to the branch body. The method looks at the type of the input statement. If it is already a compound statement, it is return unchanged. Otherwise, it creates a compound statement, puts the statement in it, and then returns the compound statement.
|
|
Dispatch a Visitor. This abstract method is the entry point for the visitor design pattern. Each node subclass defines a visit() method that calls the appropriate at_ method in the visitor. For more information see the Visitor documentation.
Reimplemented from Node. Reimplemented in basicblockNode. |
|
Dispatch a Walker. This abstract method works much like the visitor, but instead walks the entire underlying subtree calling the appropriate at_ method at each node. For more information see the Walker documentation.
Reimplemented from Node. Reimplemented in basicblockNode. |
|
the local declarations. This list contains any declarations made in the scope of the block. |
|
the location of the right curly brace.
|
|
the statements. This list contains the statements contained in the block. |