AstBottomUpProcessing< SynthesizedAttributeType > Class Template Reference
[AST Processing]

#include <AstProcessing.h>

Inheritance diagram for AstBottomUpProcessing< SynthesizedAttributeType >:

Inheritance graph
[legend]
Collaboration diagram for AstBottomUpProcessing< SynthesizedAttributeType >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class SynthesizedAttributeType>
class AstBottomUpProcessing< SynthesizedAttributeType >

Attribute Evaluator for synthesized attributes.

This class allows to compute synthesized attributes on the AST. It requires a synthesized attribute type as a template parameter and the implementation of the function evaluateSynthesizedAttribute. This function is invoked in post-order while the AST is traversed. It can be used for passing information up the AST and for computing a synthesized attribute at each node based on the results of its children in the AST.

Initialization of synthesized attributes is necessary for values which represent results of non-existent nodes (= null pointers in the AST) or skipped nodes (e.g. traverseWithingFile skips all nodes which do not represent the same file as from where the evaluation of attributes started).

  1. Class as synthesized attribute type. The default constructor is sufficient to initialize the object representing an attribute value.
  2. Primitive type as synthesized attribute type (e.g. int, bool, etc.). The method defaultSynthesizedAttribute must be implemented to initialize the synthesized attribute. This function is automatically called during attribute evaluation whenever necessary.

For internal use only.

This class is derived from the SgTreeTraversal class.


Public Types

typedef SgTreeTraversal< DummyAttribute,
SynthesizedAttributeType
>::SynthesizedAttributesList 
SynthesizedAttributesList
typedef SynthesizedAttributesList SubTreeSynthesizedAttributes

Public Member Functions

SynthesizedAttributeType traverse (SgNode *node)
 evaluates attributes on the entire AST
SynthesizedAttributeType traverseWithinFile (SgNode *node)
 evaluates attributes only at nodes which represent the same file as where the evaluation was started
void traverseInputFiles (SgProject *projectNode)
 evaluates attributes only at nodes which represent files which were specified on the command line (=input files).

Protected Member Functions

virtual SynthesizedAttributeType evaluateSynthesizedAttribute (SgNode *, SynthesizedAttributesList)=0
 pure virtual function which must be implemented to compute the synthesized attribute at a node.
virtual SynthesizedAttributeType defaultSynthesizedAttribute ()
 Allows to provide a default value for a synthesized attribute of primitive type (e.g.
virtual void atTraversalStart ()
 Function called at the start of the traversal, before any node is visited; override if necessary, the default implementation is a no-op.
virtual void atTraversalEnd ()

Private Member Functions

virtual DummyAttribute evaluateInheritedAttribute (SgNode *astNode, DummyAttribute inheritedValue)
virtual SynthesizedAttributeType evaluateSynthesizedAttribute (SgNode *astNode, DummyAttribute inheritedValue, SynthesizedAttributesList l)
virtual SynthesizedAttributeType defaultSynthesizedAttribute (DummyAttribute inheritedValue)

Friends

class AstCombinedBottomUpProcessing< SynthesizedAttributeType >
class DistributedMemoryAnalysisPostTraversal< SynthesizedAttributeType >


Member Typedef Documentation

template<class SynthesizedAttributeType>
typedef SgTreeTraversal<DummyAttribute, SynthesizedAttributeType>::SynthesizedAttributesList AstBottomUpProcessing< SynthesizedAttributeType >::SynthesizedAttributesList

Reimplemented from SgTreeTraversal< InheritedAttributeType, SynthesizedAttributeType >.

Reimplemented in AstCombinedBottomUpProcessing< SynthesizedAttributeType >, AstSharedMemoryParallelizableBottomUpProcessing< SynthesizedAttributeType >, AstCombinedBottomUpProcessing< S >, and AstSharedMemoryParallelizableBottomUpProcessing< S >.

template<class SynthesizedAttributeType>
typedef SynthesizedAttributesList AstBottomUpProcessing< SynthesizedAttributeType >::SubTreeSynthesizedAttributes


Member Function Documentation

template<class SynthesizedAttributeType>
SynthesizedAttributeType AstBottomUpProcessing< SynthesizedAttributeType >::traverse ( SgNode node  ) 

evaluates attributes on the entire AST

template<class SynthesizedAttributeType>
SynthesizedAttributeType AstBottomUpProcessing< SynthesizedAttributeType >::traverseWithinFile ( SgNode node  ) 

evaluates attributes only at nodes which represent the same file as where the evaluation was started

template<class SynthesizedAttributeType>
void AstBottomUpProcessing< SynthesizedAttributeType >::traverseInputFiles ( SgProject projectNode  ) 

evaluates attributes only at nodes which represent files which were specified on the command line (=input files).

template<class SynthesizedAttributeType>
virtual SynthesizedAttributeType AstBottomUpProcessing< SynthesizedAttributeType >::evaluateSynthesizedAttribute ( SgNode ,
SynthesizedAttributesList   
) [protected, pure virtual]

pure virtual function which must be implemented to compute the synthesized attribute at a node.

The list of synthesized attributes consists of the synthesized attributes computed at the children node of the current node. The inherited attribute value is computed by the function evaluateInheritedAttribute at the same node and simply passed to this function. Use the typedef SynthesizedAttributeList as type for the synthesized attributes list.

template<class SynthesizedAttributeType>
SynthesizedAttributeType AstBottomUpProcessing< SynthesizedAttributeType >::defaultSynthesizedAttribute (  )  [protected, virtual]

Allows to provide a default value for a synthesized attribute of primitive type (e.g.

int, bool, etc.). If a class is used as type for a synthesized attribute the default constructor of this class is sufficient and this function does not have be implemented.

Reimplemented in AstCombinedBottomUpProcessing< SynthesizedAttributeType >, and AstCombinedBottomUpProcessing< S >.

template<class SynthesizedAttributeType>
void AstBottomUpProcessing< SynthesizedAttributeType >::atTraversalStart (  )  [protected, virtual]

Function called at the start of the traversal, before any node is visited; override if necessary, the default implementation is a no-op.

Reimplemented from SgTreeTraversal< InheritedAttributeType, SynthesizedAttributeType >.

Reimplemented in AstCombinedBottomUpProcessing< SynthesizedAttributeType >, and AstCombinedBottomUpProcessing< S >.

template<class SynthesizedAttributeType>
void AstBottomUpProcessing< SynthesizedAttributeType >::atTraversalEnd (  )  [protected, virtual]

Reimplemented from SgTreeTraversal< InheritedAttributeType, SynthesizedAttributeType >.

Reimplemented in AstCombinedBottomUpProcessing< SynthesizedAttributeType >, AstSharedMemoryParallelizableBottomUpProcessing< SynthesizedAttributeType >, AstCombinedBottomUpProcessing< S >, and AstSharedMemoryParallelizableBottomUpProcessing< S >.

template<class SynthesizedAttributeType>
DummyAttribute AstBottomUpProcessing< SynthesizedAttributeType >::evaluateInheritedAttribute ( SgNode astNode,
DummyAttribute  inheritedValue 
) [private, virtual]

template<class SynthesizedAttributeType>
SynthesizedAttributeType AstBottomUpProcessing< SynthesizedAttributeType >::evaluateSynthesizedAttribute ( SgNode astNode,
DummyAttribute  inheritedValue,
SynthesizedAttributesList  l 
) [private, virtual]

template<class SynthesizedAttributeType>
SynthesizedAttributeType AstBottomUpProcessing< SynthesizedAttributeType >::defaultSynthesizedAttribute ( DummyAttribute  inheritedValue  )  [private, virtual]


Friends And Related Function Documentation

template<class SynthesizedAttributeType>
friend class AstCombinedBottomUpProcessing< SynthesizedAttributeType > [friend]

template<class SynthesizedAttributeType>
friend class DistributedMemoryAnalysisPostTraversal< SynthesizedAttributeType > [friend]


The documentation for this class was generated from the following file:
Generated on Tue Jan 31 05:33:24 2012 for ROSE by  doxygen 1.4.7