4#ifndef ASTCOMBINEDPROCESSING_C 
    5#define ASTCOMBINEDPROCESSING_C 
    9#include "AstCombinedProcessing.h" 
   16template <
class I, 
class S>
 
   23template <
class I, 
class S>
 
   26            const typename SgCombinedTreeTraversal<I, S>::TraversalPtrList &t)
 
   31template <
class I, 
class S>
 
   36    traversals.push_back(t);
 
 
   39template <
class I, 
class S>
 
   40typename SgCombinedTreeTraversal<I, S>::TraversalPtrList &
 
   47template <
class I, 
class S>
 
   49    ::InheritedAttributeTypeList *
 
   53        ::InheritedAttributeTypeList *inheritedValues)
 
   55    InheritedAttributeTypeList *result
 
   56        = 
new InheritedAttributeTypeList();
 
   59    result->reserve(numberOfTraversals);
 
   63    typename TraversalPtrList::iterator t = tBegin;
 
   64    typename InheritedAttributeTypeList::iterator i
 
   65        = inheritedValues->begin();
 
   66    typename InheritedAttributeTypeList::const_iterator iEnd
 
   67        = inheritedValues->end();
 
   69    while (t != tEnd && i != iEnd)
 
   70        result->push_back((*t++)->evaluateInheritedAttribute(astNode, *i++));
 
   71    ROSE_ASSERT(t == tEnd && i == iEnd);
 
   72    ROSE_ASSERT(result->size() == numberOfTraversals);
 
   79template <
class I, 
class S>
 
   81    ::SynthesizedAttributeTypeList *
 
   85        ::InheritedAttributeTypeList *inheritedValues,
 
   87        ::SynthesizedAttributesList synthesizedAttributes)
 
   95    typename SynthesizedAttributesList::size_type M
 
   96        = synthesizedAttributes.size();
 
   99    typename TraversalType::SynthesizedAttributesList
 
  100        attributesForTraversal(M);
 
  102    SynthesizedAttributeTypeList *result
 
  103        = 
new SynthesizedAttributeTypeList();
 
  104    result->reserve(numberOfTraversals);
 
  106    typename TraversalPtrList::size_type i;
 
  107    typename SynthesizedAttributesList::size_type j;
 
  109    for (i = 0; i < numberOfTraversals; i++)
 
  111        for (j = 0; j < M; j++)
 
  112            attributesForTraversal[j] = (*synthesizedAttributes[j])[i];
 
  115                traversals[i]->evaluateSynthesizedAttribute(
 
  117                    (*inheritedValues)[i],
 
  118                    attributesForTraversal));
 
  123    for (j = 0; j < M; j++)
 
  124        delete synthesizedAttributes[j];
 
  129    delete inheritedValues;
 
  134template <
class I, 
class S>
 
  136    ::SynthesizedAttributeTypeList *
 
  139        ::InheritedAttributeTypeList *inheritedValues)
 
  142    SynthesizedAttributeTypeList *result
 
  143        = 
new SynthesizedAttributeTypeList(numberOfTraversals);
 
  146    typename TraversalPtrList::size_type i;
 
  147    for (i = 0; i < numberOfTraversals; i++)
 
  149            = traversals[i]->defaultSynthesizedAttribute((*inheritedValues)[i]);
 
  151    typename TraversalPtrList::iterator i = traversals.begin();
 
  152    typename SynthesizedAttributeTypeList::iterator j
 
  154    typename InheritedAttributeTypPtrList::iterator k
 
  155        = inheritedValues->begin();
 
  157        *j++ = (*i++)->defaultSynthesizedAttribute(*k++);
 
  163template <
class I, 
class S>
 
  172    tBegin = traversals.begin();
 
  173    tEnd = traversals.end();
 
  174    numberOfTraversals = traversals.size();
 
  177    typename TraversalPtrList::iterator t;
 
  178    for (t = tBegin; t != tEnd; ++t)
 
  179        (*t)->atTraversalStart();
 
  182template <
class I, 
class S>
 
  188    typename TraversalPtrList::iterator t;
 
  189    for (t = tBegin; t != tEnd; ++t)
 
  190        (*t)->atTraversalEnd();
 
  195template <
class I, 
class S>
 
  202template <
class I, 
class S>
 
  205        const typename AstCombinedTopDownBottomUpProcessing<I, S>::TraversalPtrList &t)
 
  210template <
class I, 
class S>
 
  215    traversals.push_back(t);
 
 
  218template <
class I, 
class S>
 
  219typename AstCombinedTopDownBottomUpProcessing<I, S>::TraversalPtrList &
 
  226template <
class I, 
class S>
 
  228    ::InheritedAttributeTypeList *
 
  232        ::InheritedAttributeTypeList *inheritedValues)
 
  234    InheritedAttributeTypeList *result
 
  235        = 
new InheritedAttributeTypeList();
 
  238    result->reserve(numberOfTraversals);
 
  242    typename TraversalPtrList::iterator t = tBegin;
 
  243    typename InheritedAttributeTypeList::iterator i
 
  244        = inheritedValues->begin();
 
  245    typename InheritedAttributeTypeList::const_iterator iEnd
 
  246        = inheritedValues->end();
 
  248    while (t != tEnd && i != iEnd)
 
  249        result->push_back((*t++)->evaluateInheritedAttribute(astNode, *i++));
 
  250    ROSE_ASSERT(t == tEnd && i == iEnd);
 
  251    ROSE_ASSERT(result->size() == numberOfTraversals);
 
 
  258template <
class I, 
class S>
 
  260    ::SynthesizedAttributeTypeList *
 
  264        ::InheritedAttributeTypeList *inheritedValues,
 
  266        ::SynthesizedAttributesList synthesizedAttributes)
 
  274    typename SynthesizedAttributesList::size_type M
 
  275        = synthesizedAttributes.size();
 
  279        attributesForTraversal(M);
 
  281    SynthesizedAttributeTypeList *result
 
  282        = 
new SynthesizedAttributeTypeList();
 
  283    result->reserve(numberOfTraversals);
 
  285    typename TraversalPtrList::size_type i;
 
  286    typename SynthesizedAttributesList::size_type j;
 
  288    for (i = 0; i < numberOfTraversals; i++)
 
  290        for (j = 0; j < M; j++)
 
  291            attributesForTraversal[j] = (*synthesizedAttributes[j])[i];
 
  294                traversals[i]->evaluateSynthesizedAttribute(
 
  296                    (*inheritedValues)[i],
 
  297                    attributesForTraversal));
 
  302    for (j = 0; j < M; j++)
 
  303        delete synthesizedAttributes[j];
 
  308    delete inheritedValues;
 
 
  313template <
class I, 
class S>
 
  315    ::SynthesizedAttributeTypeList *
 
  318        ::InheritedAttributeTypeList *inheritedValues)
 
  321    SynthesizedAttributeTypeList *result
 
  322        = 
new SynthesizedAttributeTypeList(numberOfTraversals);
 
  324    typename TraversalPtrList::size_type i;
 
  325    for (i = 0; i < numberOfTraversals; i++)
 
  327            = traversals[i]->defaultSynthesizedAttribute((*inheritedValues)[i]);
 
  332template <
class I, 
class S>
 
  341    tBegin = traversals.begin();
 
  342    tEnd = traversals.end();
 
  343    numberOfTraversals = traversals.size();
 
  346    typename TraversalPtrList::iterator t;
 
  347    for (t = tBegin; t != tEnd; ++t)
 
  348        (*t)->atTraversalStart();
 
 
  351template <
class I, 
class S>
 
  357    typename TraversalPtrList::iterator t;
 
  358    for (t = tBegin; t != tEnd; ++t)
 
  359        (*t)->atTraversalEnd();
 
  375        const typename AstCombinedTopDownProcessing<I>::TraversalPtrList &t)
 
  385    traversals.push_back(t);
 
 
  389typename AstCombinedTopDownProcessing<I>::TraversalPtrList &
 
  398    ::InheritedAttributeTypeList *
 
  402        ::InheritedAttributeTypeList *inheritedValues)
 
  404    InheritedAttributeTypeList *result
 
  405        = 
new InheritedAttributeTypeList();
 
  408    result->reserve(numberOfTraversals);
 
  412    typename TraversalPtrList::iterator t = tBegin;
 
  413    typename InheritedAttributeTypeList::iterator i
 
  414        = inheritedValues->begin();
 
  415    typename InheritedAttributeTypeList::const_iterator iEnd
 
  416        = inheritedValues->end();
 
  418    while (t != tEnd && i != iEnd)
 
  419        result->push_back((*t++)->evaluateInheritedAttribute(astNode, *i++));
 
  420    ROSE_ASSERT(t == tEnd && i == iEnd);
 
  421    ROSE_ASSERT(result->size() == numberOfTraversals);
 
 
  437    tBegin = traversals.begin();
 
  438    tEnd = traversals.end();
 
  439    numberOfTraversals = traversals.size();
 
  442    typename TraversalPtrList::iterator t;
 
  443    for (t = tBegin; t != tEnd; ++t)
 
  444        (*t)->atTraversalStart();
 
 
  453    typename TraversalPtrList::iterator t;
 
  454    for (t = tBegin; t != tEnd; ++t)
 
  455        (*t)->atTraversalEnd();
 
  462        InheritedAttributeTypeList *inheritedValues)
 
  464    typename TraversalPtrList::iterator t = tBegin;
 
  465    typename InheritedAttributeTypeList::iterator i
 
  466        = inheritedValues->begin();
 
  467    typename InheritedAttributeTypeList::const_iterator iEnd
 
  468        = inheritedValues->end();
 
  471    while (t != tEnd && i != iEnd)
 
  472        (*t++)->destroyInheritedValue(node, *i++);
 
  473    ROSE_ASSERT(t == tEnd && i == iEnd);
 
  478    delete inheritedValues;
 
  493        const typename AstCombinedBottomUpProcessing<S>::TraversalPtrList &t)
 
  503    traversals.push_back(t);
 
 
  507typename AstCombinedBottomUpProcessing<S>::TraversalPtrList &
 
  516    ::SynthesizedAttributeTypeList *
 
  520        ::SynthesizedAttributesList synthesizedAttributes)
 
  528    typename SynthesizedAttributesList::size_type M
 
  529        = synthesizedAttributes.size();
 
  532    typename TraversalType::SynthesizedAttributesList
 
  533        attributesForTraversal(M, NULL);
 
  535    SynthesizedAttributeTypeList *result
 
  536        = 
new SynthesizedAttributeTypeList(numberOfTraversals);
 
  538    typename TraversalPtrList::size_type i;
 
  539    typename SynthesizedAttributesList::size_type j;
 
  541    for (i = 0; i < numberOfTraversals; i++)
 
  543        for (j = 0; j < M; j++)
 
  544            attributesForTraversal[j] = (*synthesizedAttributes[j])[i];
 
  547            = traversals[i]->evaluateSynthesizedAttribute(
 
  549                    attributesForTraversal);
 
  551    ROSE_ASSERT(result->size() == numberOfTraversals);
 
  555    for (j = 0; j < M; j++)
 
  556        delete synthesizedAttributes[j];
 
  563    ::SynthesizedAttributeTypeList *
 
  568    SynthesizedAttributeTypeList *result
 
  569        = 
new SynthesizedAttributeTypeList(numberOfTraversals);
 
  571    typename TraversalPtrList::size_type i;
 
  572    for (i = 0; i < numberOfTraversals; i++)
 
  573        (*result)[i] = traversals[i]->defaultSynthesizedAttribute();
 
 
  587    tBegin = traversals.begin();
 
  588    tEnd = traversals.end();
 
  589    numberOfTraversals = traversals.size();
 
  592    typename TraversalPtrList::iterator t;
 
  593    for (t = tBegin; t != tEnd; ++t)
 
  594        (*t)->atTraversalStart();
 
 
  603    typename TraversalPtrList::iterator t;
 
  604    for (t = tBegin; t != tEnd; ++t)
 
  605        (*t)->atTraversalEnd();
 
Attribute Evaluator for synthesized attributes.
 
void addTraversal(TraversalPtr)
simple function for adding a traversal to the internal list
 
virtual SynthesizedAttributeTypeList * defaultSynthesizedAttribute()
Allows to provide a default value for a synthesized attribute of primitive type (e....
 
virtual void atTraversalStart()
Function called at the start of the traversal, before any node is visited; override if necessary,...
 
AstCombinedBottomUpProcessing()
default constructor
 
TraversalPtrList & get_traversalPtrListRef()
function for obtaining a reference to the internal list of traversals, you can use this for any conta...
 
TraversalPtrList & get_traversalPtrListRef()
function for obtaining a reference to the internal list of traversals, you can use this for any conta...
 
virtual InheritedAttributeTypeList * evaluateInheritedAttribute(SgNode *astNode, InheritedAttributeTypeList *inheritedValues)
pure virtual function which must be implemented to compute the inherited attribute at a node
 
void addTraversal(TraversalPtr)
simple function for adding a traversal to the internal list
 
virtual void atTraversalStart()
Function called at the start of the traversal, before any node is visited; override if necessary,...
 
virtual SynthesizedAttributeTypeList * evaluateSynthesizedAttribute(SgNode *astNode, InheritedAttributeTypeList *inheritedValues, SynthesizedAttributesList synthesizedAttributes)
pure virtual function which must be implemented to compute the synthesized attribute at a node.
 
AstCombinedTopDownBottomUpProcessing()
default constructor
 
virtual InheritedAttributeTypeList * evaluateInheritedAttribute(SgNode *astNode, InheritedAttributeTypeList *inheritedValues)
pure virtual function which must be implemented to compute the inherited attribute at a node
 
virtual void atTraversalStart()
Function called at the start of the traversal, before any node is visited; override if necessary,...
 
TraversalPtrList & get_traversalPtrListRef()
function for obtaining a reference to the internal list of traversals, zou can use this for any conta...
 
AstCombinedTopDownProcessing()
default constructor
 
void addTraversal(TraversalPtr)
simple function for adding a traversal to the internal list
 
Attribute Evaluator for inherited and synthesized attributes.
 
Attribute Evaluator for inherited attributes.
 
TraversalPtrList & get_traversalPtrListRef()
function for obtaining a reference to the internal list of traversals, you can use this for any conta...
 
SgCombinedTreeTraversal()
default constructor
 
void addTraversal(TraversalPtr)
simple function for adding a traversal to the internal list
 
This class represents the base class for all IR nodes within Sage III.
 
This class is temporary. Do not use.