00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef ASTCOMBINEDPROCESSING_H
00017 #define ASTCOMBINEDPROCESSING_H
00018
00019 #include "AstProcessing.h"
00020
00021 template <class InheritedAttributeType, class SynthesizedAttributeType>
00022 class SgCombinedTreeTraversal
00023 : public SgTreeTraversal< std::vector<InheritedAttributeType> *, std::vector<SynthesizedAttributeType> *>
00024 {
00025 public:
00026 typedef SgTreeTraversal<InheritedAttributeType, SynthesizedAttributeType> TraversalType;
00027 typedef TraversalType *TraversalPtr;
00028 typedef std::vector<TraversalPtr> TraversalPtrList;
00029 typedef std::vector<InheritedAttributeType> InheritedAttributeTypeList;
00030 typedef std::vector<SynthesizedAttributeType> SynthesizedAttributeTypeList;
00031 typedef SgTreeTraversal<std::vector<InheritedAttributeType> *, std::vector<SynthesizedAttributeType> *> Superclass;
00032 typedef typename Superclass::SynthesizedAttributesList SynthesizedAttributesList;
00033
00035 SgCombinedTreeTraversal();
00037 SgCombinedTreeTraversal(const TraversalPtrList &);
00038
00040 void addTraversal(TraversalPtr);
00044 TraversalPtrList &get_traversalPtrListRef();
00045
00046 protected:
00047 virtual InheritedAttributeTypeList *evaluateInheritedAttribute(
00048 SgNode *astNode,
00049 InheritedAttributeTypeList *inheritedValues);
00050 virtual SynthesizedAttributeTypeList *evaluateSynthesizedAttribute(
00051 SgNode *astNode,
00052 InheritedAttributeTypeList *inheritedValues,
00053 SynthesizedAttributesList synthesizedAttributes);
00054 virtual SynthesizedAttributeTypeList *defaultSynthesizedAttribute(InheritedAttributeTypeList *);
00055 virtual void atTraversalStart();
00056 virtual void atTraversalEnd();
00057
00058 TraversalPtrList traversals;
00059
00060 private:
00061 typename TraversalPtrList::iterator tBegin, tEnd;
00062 typename TraversalPtrList::size_type numberOfTraversals;
00063 };
00064
00065 template <class InheritedAttributeType, class SynthesizedAttributeType>
00066 class AstCombinedTopDownBottomUpProcessing
00067 : public AstTopDownBottomUpProcessing<std::vector<InheritedAttributeType> *, std::vector<SynthesizedAttributeType> *>
00068 {
00069 public:
00070 typedef AstTopDownBottomUpProcessing<InheritedAttributeType, SynthesizedAttributeType> TraversalType;
00071 typedef TraversalType *TraversalPtr;
00072 typedef std::vector<TraversalPtr> TraversalPtrList;
00073 typedef std::vector<InheritedAttributeType> InheritedAttributeTypeList;
00074 typedef std::vector<SynthesizedAttributeType> SynthesizedAttributeTypeList;
00075 typedef AstTopDownBottomUpProcessing<std::vector<InheritedAttributeType> *, std::vector<SynthesizedAttributeType> *> Superclass;
00076 typedef typename Superclass::SynthesizedAttributesList SynthesizedAttributesList;
00077
00079 AstCombinedTopDownBottomUpProcessing();
00081 AstCombinedTopDownBottomUpProcessing(const TraversalPtrList &);
00082
00084 void addTraversal(TraversalPtr);
00088 TraversalPtrList &get_traversalPtrListRef();
00089
00090 protected:
00091 virtual InheritedAttributeTypeList *evaluateInheritedAttribute(
00092 SgNode *astNode,
00093 InheritedAttributeTypeList *inheritedValues);
00094 virtual SynthesizedAttributeTypeList *evaluateSynthesizedAttribute(
00095 SgNode *astNode,
00096 InheritedAttributeTypeList *inheritedValues,
00097 SynthesizedAttributesList synthesizedAttributes);
00098 virtual SynthesizedAttributeTypeList *defaultSynthesizedAttribute(InheritedAttributeTypeList *);
00099 virtual void atTraversalStart();
00100 virtual void atTraversalEnd();
00101
00102 TraversalPtrList traversals;
00103
00104 private:
00105 typename TraversalPtrList::iterator tBegin, tEnd;
00106 typename TraversalPtrList::size_type numberOfTraversals;
00107 };
00108
00109 template <class InheritedAttributeType>
00110 class AstCombinedTopDownProcessing
00111 : public AstTopDownProcessing<std::vector<InheritedAttributeType> *>
00112 {
00113 public:
00114 typedef AstTopDownProcessing<InheritedAttributeType> TraversalType;
00115 typedef TraversalType *TraversalPtr;
00116 typedef std::vector<TraversalPtr> TraversalPtrList;
00117 typedef std::vector<InheritedAttributeType> InheritedAttributeTypeList;
00118
00120 AstCombinedTopDownProcessing();
00122 AstCombinedTopDownProcessing(const TraversalPtrList &);
00123
00125 void addTraversal(TraversalPtr);
00129 TraversalPtrList &get_traversalPtrListRef();
00130
00131 protected:
00132 virtual InheritedAttributeTypeList *evaluateInheritedAttribute(
00133 SgNode *astNode,
00134 InheritedAttributeTypeList *inheritedValues);
00135 virtual void atTraversalStart();
00136 virtual void atTraversalEnd();
00137 virtual void destroyInheritedValue(SgNode*, InheritedAttributeTypeList *);
00138
00139 TraversalPtrList traversals;
00140
00141 private:
00142 typename TraversalPtrList::iterator tBegin, tEnd;
00143 typename TraversalPtrList::size_type numberOfTraversals;
00144 };
00145
00146 template <class SynthesizedAttributeType>
00147 class AstCombinedBottomUpProcessing
00148 : public AstBottomUpProcessing<std::vector<SynthesizedAttributeType> *>
00149 {
00150 public:
00151 typedef AstBottomUpProcessing<SynthesizedAttributeType> TraversalType;
00152 typedef TraversalType *TraversalPtr;
00153 typedef std::vector<TraversalPtr> TraversalPtrList;
00154 typedef std::vector<SynthesizedAttributeType> SynthesizedAttributeTypeList;
00155 typedef AstBottomUpProcessing<SynthesizedAttributeTypeList *> Superclass;
00156 typedef typename Superclass::SynthesizedAttributesList SynthesizedAttributesList;
00157
00159 AstCombinedBottomUpProcessing();
00161 AstCombinedBottomUpProcessing(const TraversalPtrList &);
00162
00164 void addTraversal(TraversalPtr);
00168 TraversalPtrList &get_traversalPtrListRef();
00169
00170 protected:
00171 virtual SynthesizedAttributeTypeList *evaluateSynthesizedAttribute(
00172 SgNode *astNode,
00173 SynthesizedAttributesList synthesizedAttributes);
00174 virtual SynthesizedAttributeTypeList *defaultSynthesizedAttribute();
00175 virtual void atTraversalStart();
00176 virtual void atTraversalEnd();
00177
00178 TraversalPtrList traversals;
00179
00180 private:
00181 typename TraversalPtrList::iterator tBegin, tEnd;
00182 typename TraversalPtrList::size_type numberOfTraversals;
00183 };
00184
00185 #include "AstCombinedProcessingImpl.h"
00186
00187 #include "AstCombinedSimpleProcessing.h"
00188
00189 #endif