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

procNode Class Reference

Procedure definition. More...

#include <ast.h>

Inheritance diagram for procNode::

defNode Node List of all members.

Parser methods

void define (blockNode *body)
procNode * define_and (blockNode *body)
procNode * current ()

Public Methods

 procNode (declNode *decl, blockNode *body, const Coord coord=Coord::Unknown)
 Create a new procedure. More...

 procNode (bool old_style, declNode *decl)
 Create a procedure during parsing. More...

virtual ~procNode ()
 Destroy a procNode. 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 (output_context &ct, Node *par)
 Generate C code. More...

Accessors
Methods to get and set fields in the class.

declNode * decl () const
 Return the declaration for this procNode. More...

declNode * get_decl ()
 Return the declaration for this procNode, and set it to be empty. More...

void decl (declNode *decl)
 Set the declaration for this procNode to the given value. More...

blockNode * body () const
 Return this procNode's body. More...

blockNode * get_body ()
 Return the body for this procNode, and set it to be empty. More...

void body (blockNode *body)
 Set this procNode's body to the given value. More...

FlowVal * at_entry () const
 Return this Node's at_entry dataflow analysis value. More...

void at_entry (FlowVal *ae)
 Set this procNode's entry flow value. More...

FlowVal * at_exit () const
 Return this Node's at_exit dataflow analysis value. More...

void at_exit (FlowVal *ae)
 Set this procNode's exit flow value. More...

Control-flow Graph
These methods return the entry and exit basic blocks when a procedure is in control-flow graph form. Currently, the convention is that the first basic block is the entry and the last basic block is the exit; however, the user should not depend on this fact.

The control-flow graph is built using the cfg_changer.

See also:
cfg_changer


basicblockNode * entry () const
 Entry basic block. More...

basicblockNode * exit () const
 Exit basic block. More...

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 Node * change (Changer &the_changer, bool redispatch=false)
 Dispatch a Changer. More...


Private Attributes

TREE declNode * _decl
 Procedure declaration. More...

TREE blockNode * _body
 Procedure body. More...

Dataflow analysis
FlowVal * _at_entry
FlowVal * _at_exit

Static Private Attributes

procNode * _current = (procNode *)0
 Current procedure during parsing. More...


Detailed Description

Procedure definition.

This class represents a procedure (or function) definition. The definition consists of a declarations (which gives the name and interface of the procedure) and the procedure body.

The NodeType is Proc.


Constructor & Destructor Documentation

procNode::procNode (  declNode *    decl,
blockNode *    body,
const Coord    coord = Coord::Unknown
) 
 

Create a new procedure.

Parameters:
decl  the procedure declaration (always type funcNode )
body  the code of the procedure body
coord  the location of the construct in the source file.

procNode::procNode (  bool    old_style,
declNode *    decl_in
) 
 

Create a procedure during parsing.

procNode::~procNode (    )  [virtual]
 

Destroy a procNode.

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


Member Function Documentation

void procNode::at_entry (  FlowVal *    ae )  [inline]
 

Set this procNode's entry flow value.

FlowVal* procNode::at_entry (    )  const [inline]
 

Return this Node's at_entry dataflow analysis value.

void procNode::at_exit (  FlowVal *    ae )  [inline]
 

Set this procNode's exit flow value.

FlowVal* procNode::at_exit (    )  const [inline]
 

Return this Node's at_exit dataflow analysis value.

typeNode * procNode::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.

void procNode::body (  blockNode *    body )  [inline]
 

Set this procNode's body to the given value.

To set this procNode's body to be empty, use a value of NULL.

blockNode* procNode::body (    )  const [inline]
 

Return this procNode's body.

Node * procNode::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.

virtual Node* procNode::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.

procNode* procNode::current (    )  [inline, static]
 

void procNode::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.

void procNode::decl (  declNode *    decl )  [inline]
 

Set the declaration for this procNode to the given value.

To set this procNode's declaration to be empty, use a value of NULL.

declNode* procNode::decl (    )  const [inline]
 

Return the declaration for this procNode.

The declaration of the procedure consists of the name, plus the type, which specifies the function interface. The declaration's type is guaranteed to be a funcNode.

void procNode::define (  blockNode *    the_body ) 
 

procNode * procNode::define_and (  blockNode *    the_body ) 
 

basicblockNode * procNode::entry (    )  const
 

Entry basic block.

Returns:
the entry basic block

basicblockNode * procNode::exit (    )  const
 

Exit basic block.

Returns:
the exit basic block

blockNode* procNode::get_body (    )  [inline]
 

Return the body for this procNode, and set it to be empty.

declNode* procNode::get_decl (    )  [inline]
 

Return the declaration for this procNode, and set it to be empty.

The declaration of the procedure consists of the name, plus the type, which specifies the function interface. The declaration's type is guaranteed to be a funcNode.

void procNode::output (  output_context &    ct,
Node *    parent
)  [virtual]
 

Generate C code.

Each subclass overrides this method to define how to produce the output C code. To use this method, pass an output_context and a null parent.

Parameters:
ct  the output context which describes the formatting.
par  the parent node (or null, if at the top of a subtree).

Reimplemented from Node.

void procNode::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.

void procNode::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.


Member Data Documentation

FlowVal* procNode::_at_entry [private]
 

FlowVal* procNode::_at_exit [private]
 

TREE blockNode* procNode::_body [private]
 

Procedure body.

The procedure body is represented as a statement block

procNode * procNode::_current = (procNode *)0 [static, private]
 

Current procedure during parsing.

TREE declNode* procNode::_decl [private]
 

Procedure declaration.

The declaration of the procedure consists of the name, plus the type, which specifies the function interface. The type is always a funcNode. If _decl is NULL, then the procedure's declaration is empty.


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