Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

blockNode Class Reference

Compund statement or block. More...

#include <ast.h>

Inheritance diagram for blockNode::

stmtNode Node basicblockNode List of all members.

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...

typeNodebase_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 Nodeclone () 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_listdecls ()
const decl_listdecls () const
stmt_liststmts ()
const stmt_liststmts () const
Coord right_brace () const
void right_brace (const Coord right_brace)
AST Traversal
Methods to uniformly traverse the AST. See the documentation in the Node class.

virtual void visit (Visitor *the_visitor)
 Dispatch a Visitor. More...

virtual void walk (Walker &the_walker)
 Dispatch a Walker. More...

virtual Nodechange (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...


Detailed Description

Compund statement or block.

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.


Constructor & Destructor Documentation

blockNode::blockNode decl_list   decls,
stmt_list   stmts,
const Coord    left_coord = Coord::Unknown,
const Coord    right_brace = Coord::Unknown
 

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.

Parameters:
decls  the list of declarations
stmts  the list of statements
coord  the location of the left curly brace in the source file.
coord  the location of the right curly brace in the source file.

blockNode::~blockNode   [virtual]
 

Destroy a blockNode.

Warning:
Do not use the destructors to delete AST nodes. Instead, rely on the node garbage collector.


Member Function Documentation

typeNode * blockNode::base_type bool    TdefIndir const [virtual]
 

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.

Parameters:
TdefIndir  pass true to follow typedefs to their definitions.

Reimplemented from Node.

Node * blockNode::change Changer   the_changer,
bool    redispatch = false
[virtual]
 

Dispatch a Changer.

This abstract method works much the walker, but allows the tree to be changed.

Parameters:
the_changer  the specific Changer object to use.
redispatch  pass true to revisit parts of the tree that have changed.

Reimplemented from Node.

Reimplemented in basicblockNode.

virtual Node* blockNode::clone   const [inline, virtual]
 

Clone the input node.

This is not a "deep" clone, so be careful. For a deep clone, use the clone_changer class.

Returns:
a shallow copy of the node (no subtrees are copied).

Reimplemented from Node.

Reimplemented in basicblockNode.

void blockNode::dataflow FlowVal   v,
FlowProblem   fp
[virtual]
 

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.

Parameters:
v  the flow value to pass through the node.
fp  the flow problem (specifying the transfer functions).

Reimplemented from Node.

const decl_list& blockNode::decls   const [inline]
 

decl_list& blockNode::decls   [inline]
 

void blockNode::output_stmt output_context   ct,
Node   parent
[virtual]
 

Output a statement.

Reimplemented from stmtNode.

void blockNode::right_brace const Coord    right_brace [inline]
 

Coord blockNode::right_brace   const [inline]
 

const stmt_list& blockNode::stmts   const [inline]
 

stmt_list& blockNode::stmts   [inline]
 

blockNode * blockNode::toBlock stmtNode   stmt,
Coord    coord
[static]
 

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.

Parameters:
stmt  the statement to covert, if necessary
coord  the location of the construct in the source file.
Returns:
the statement as a blockNode

void blockNode::visit Visitor   the_visitor [virtual]
 

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.

Parameters:
the_visitor  the specific Visitor object to use.

Reimplemented from Node.

Reimplemented in basicblockNode.

void blockNode::walk Walker   the_walker [virtual]
 

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.

Parameters:
the_walker  the specific Walker object to use.

Reimplemented from Node.

Reimplemented in basicblockNode.


Member Data Documentation

TREE decl_list blockNode::_decls [private]
 

the local declarations.

This list contains any declarations made in the scope of the block.

Coord blockNode::_right_brace [private]
 

the location of the right curly brace.

TREE stmt_list blockNode::_stmts [private]
 

the statements.

This list contains the statements contained in the block.


The documentation for this class was generated from the following files:
Generated on Thu Jan 10 12:06:24 2002 for C-Breeze by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001