Skip to content

AstTopDownBottomUpProcessing

Attribute evaluator for inherited and synthesized attributes.

Synopsis

Declared in <src/midend/astProcessing/AstProcessing.h>

template<
    class InheritedAttributeType,
    class SynthesizedAttributeType>
class AstTopDownBottomUpProcessing
    : public SgTreeTraversal<InheritedAttributeType, SynthesizedAttributeType>

Description

In general, this class combines the classes TopDownProcessing and BottomUpProcessing and also allows to use the inherited attribute of a node in the computation of the synthesized attribute at the same node.

This class allows computation of inherited and synthesized attributes on the AST. It requires an inherited attribute type and a synthesized attribute type as template parameters and the implementation of the functions evaluateInheritedAttribute and evaluateSynthesizedAttribute. The function evaluateInheritedAttribute is invoked in pre-order, the function evaluateSynthesizedAttribute is invoked in post-order while the AST is traversed. The function evaluateSynthesizedAttribute gets an additional parameter: the inheritedAttribute value which is computed at the respective node. It can be used to make the computation of the synthesized attribute at a node dependent on the value of the inherited attribute of the same node.

Internal: This class is derived from the SgTreeTraversal class.

Base Classes

Name Description
SgTreeTraversal<InheritedAttributeType, SynthesizedAttributeType>

Type Aliases

Name
SubTreeSynthesizedAttributes
SynthesizedAttributesList

Member Functions

Name Description
traverse
SynthesizedAttributeType traverse( SgNode* node, InheritedAttributeType inheritedValue);
evaluates attributes on the entire AST
traverseWithinFile
SynthesizedAttributeType traverseWithinFile( SgNode* node, InheritedAttributeType inheritedValue);
evaluates attributes only at nodes which represent the same file as where the evaluation was started

Protected Member Functions

Name Description
atTraversalEnd
virtual void atTraversalEnd(); [virtual]
atTraversalStart
virtual void atTraversalStart(); [virtual]
Function called at the start of the traversal, before any node is visited; override if necessary, the default implementation is a no-op.
evaluateInheritedAttribute
virtual InheritedAttributeType evaluateInheritedAttribute( SgNode* astNode, InheritedAttributeType inheritedValue) = 0; [virtual]
pure virtual function which must be implemented to compute the inherited attribute at a node
evaluateSynthesizedAttribute
virtual SynthesizedAttributeType evaluateSynthesizedAttribute( SgNode*, InheritedAttributeType, SynthesizedAttributesList) = 0; [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 evaluateInheritedAttribute at the same node and simply passed to this function. Use the typedef SynthesizedAttributeList as type for the synthesized attributes list.

Friends

Name Description
AstCombinedTopDownBottomUpProcessing

Derived Classes

Name Description
AstCombinedTopDownBottomUpProcessing
AstReverseBranchInhSynProcessing
AstReversePrefixInhSynProcessing
CreateSlice
FunctionEvaluationOrderTraversal Traverses a given AST and finds all function calls in the order in which they're evaluated Also, for each function we find where to put declarations of temporary variables so that they're accessible at the function call
NameQualificationTraversal
PrePostTraversal
SgTopDownBottomUpProcessing

Created with MrDocs