ROSE  0.11.96.11
AstCombinedProcessing.h
1 // Author: Gergo Barany
2 // $Id: AstCombinedProcessing.h,v 1.1 2008/01/08 02:56:38 dquinlan Exp $
3 
4 // Classes for combining traversals. These allow you to evaluate the effects
5 // of multiple traversals (that do not modify the AST structure) in a single
6 // traversal. Each of the AstCombined*Processing classes is a subtype of the
7 // appropriate Ast*Processing class and contains a list of pointers to such
8 // traversals. Note that there are some restrictions on the types of
9 // traversals that can be grouped together: attributes must all be of the same
10 // pointer type (which may be a pointer to some common superclass).
11 
12 // Do not assume that the traversals' visit functions are executed in any
13 // particular order. Do not introduce any other type of dependency between
14 // your traversals. In particular, do not modify the AST.
15 
16 #ifndef ASTCOMBINEDPROCESSING_H
17 #define ASTCOMBINEDPROCESSING_H
18 
19 #include "AstProcessing.h"
20 
21 template <class InheritedAttributeType, class SynthesizedAttributeType>
23  : public SgTreeTraversal< std::vector<InheritedAttributeType> *, std::vector<SynthesizedAttributeType> *>
24 {
25 public:
27  typedef TraversalType *TraversalPtr;
28  typedef std::vector<TraversalPtr> TraversalPtrList;
29  typedef std::vector<InheritedAttributeType> InheritedAttributeTypeList;
30  typedef std::vector<SynthesizedAttributeType> SynthesizedAttributeTypeList;
31  typedef SgTreeTraversal<std::vector<InheritedAttributeType> *, std::vector<SynthesizedAttributeType> *> Superclass;
33 
37  SgCombinedTreeTraversal(const TraversalPtrList &);
38 
44  TraversalPtrList &get_traversalPtrListRef();
45 
46 protected:
47  virtual InheritedAttributeTypeList *evaluateInheritedAttribute(
48  SgNode *astNode,
49  InheritedAttributeTypeList *inheritedValues);
50  virtual SynthesizedAttributeTypeList *evaluateSynthesizedAttribute(
51  SgNode *astNode,
52  InheritedAttributeTypeList *inheritedValues,
53  SynthesizedAttributesList synthesizedAttributes);
54  virtual SynthesizedAttributeTypeList *defaultSynthesizedAttribute(InheritedAttributeTypeList *);
55  virtual void atTraversalStart();
56  virtual void atTraversalEnd();
57 
58  TraversalPtrList traversals;
59 
60 private:
61  typename TraversalPtrList::iterator tBegin, tEnd;
62  typename TraversalPtrList::size_type numberOfTraversals;
63 };
64 
65 template <class InheritedAttributeType, class SynthesizedAttributeType>
67  : public AstTopDownBottomUpProcessing<std::vector<InheritedAttributeType> *, std::vector<SynthesizedAttributeType> *>
68 {
69 public:
71  typedef TraversalType *TraversalPtr;
72  typedef std::vector<TraversalPtr> TraversalPtrList;
73  typedef std::vector<InheritedAttributeType> InheritedAttributeTypeList;
74  typedef std::vector<SynthesizedAttributeType> SynthesizedAttributeTypeList;
75  typedef AstTopDownBottomUpProcessing<std::vector<InheritedAttributeType> *, std::vector<SynthesizedAttributeType> *> Superclass;
76  typedef typename Superclass::SynthesizedAttributesList SynthesizedAttributesList;
77 
81  AstCombinedTopDownBottomUpProcessing(const TraversalPtrList &);
82 
88  TraversalPtrList &get_traversalPtrListRef();
89 
90 protected:
91  virtual InheritedAttributeTypeList *evaluateInheritedAttribute(
92  SgNode *astNode,
93  InheritedAttributeTypeList *inheritedValues);
94  virtual SynthesizedAttributeTypeList *evaluateSynthesizedAttribute(
95  SgNode *astNode,
96  InheritedAttributeTypeList *inheritedValues,
97  SynthesizedAttributesList synthesizedAttributes);
98  virtual SynthesizedAttributeTypeList *defaultSynthesizedAttribute(InheritedAttributeTypeList *);
99  virtual void atTraversalStart();
100  virtual void atTraversalEnd();
101 
102  TraversalPtrList traversals;
103 
104 private:
105  typename TraversalPtrList::iterator tBegin, tEnd;
106  typename TraversalPtrList::size_type numberOfTraversals;
107 };
108 
109 template <class InheritedAttributeType>
111  : public AstTopDownProcessing<std::vector<InheritedAttributeType> *>
112 {
113 public:
115  typedef TraversalType *TraversalPtr;
116  typedef std::vector<TraversalPtr> TraversalPtrList;
117  typedef std::vector<InheritedAttributeType> InheritedAttributeTypeList;
118 
122  AstCombinedTopDownProcessing(const TraversalPtrList &);
123 
129  TraversalPtrList &get_traversalPtrListRef();
130 
131 protected:
132  virtual InheritedAttributeTypeList *evaluateInheritedAttribute(
133  SgNode *astNode,
134  InheritedAttributeTypeList *inheritedValues);
135  virtual void atTraversalStart();
136  virtual void atTraversalEnd();
137  virtual void destroyInheritedValue(SgNode*, InheritedAttributeTypeList *);
138 
139  TraversalPtrList traversals;
140 
141 private:
142  typename TraversalPtrList::iterator tBegin, tEnd;
143  typename TraversalPtrList::size_type numberOfTraversals;
144 };
145 
146 template <class SynthesizedAttributeType>
148  : public AstBottomUpProcessing<std::vector<SynthesizedAttributeType> *>
149 {
150 public:
152  typedef TraversalType *TraversalPtr;
153  typedef std::vector<TraversalPtr> TraversalPtrList;
154  typedef std::vector<SynthesizedAttributeType> SynthesizedAttributeTypeList;
156  typedef typename Superclass::SynthesizedAttributesList SynthesizedAttributesList;
157 
161  AstCombinedBottomUpProcessing(const TraversalPtrList &);
162 
168  TraversalPtrList &get_traversalPtrListRef();
169 
170 protected:
171  virtual SynthesizedAttributeTypeList *evaluateSynthesizedAttribute(
172  SgNode *astNode,
173  SynthesizedAttributesList synthesizedAttributes);
174  virtual SynthesizedAttributeTypeList *defaultSynthesizedAttribute();
175  virtual void atTraversalStart();
176  virtual void atTraversalEnd();
177 
178  TraversalPtrList traversals;
179 
180 private:
181  typename TraversalPtrList::iterator tBegin, tEnd;
182  typename TraversalPtrList::size_type numberOfTraversals;
183 };
184 
185 #include "AstCombinedProcessingImpl.h"
186 
187 #include "AstCombinedSimpleProcessing.h"
188 
189 #endif
AstTopDownBottomUpProcessing
Attribute Evaluator for inherited and synthesized attributes.
Definition: AstProcessing.h:184
AstCombinedTopDownProcessing::evaluateInheritedAttribute
virtual InheritedAttributeTypeList * evaluateInheritedAttribute(SgNode *astNode, InheritedAttributeTypeList *inheritedValues)
pure virtual function which must be implemented to compute the inherited attribute at a node
Definition: AstCombinedProcessingImpl.h:400
AstCombinedTopDownProcessing::get_traversalPtrListRef
TraversalPtrList & get_traversalPtrListRef()
function for obtaining a reference to the internal list of traversals, zou can use this for any conta...
Definition: AstCombinedProcessingImpl.h:391
AstCombinedBottomUpProcessing::get_traversalPtrListRef
TraversalPtrList & get_traversalPtrListRef()
function for obtaining a reference to the internal list of traversals, you can use this for any conta...
Definition: AstCombinedProcessingImpl.h:509
AstCombinedTopDownProcessing::addTraversal
void addTraversal(TraversalPtr)
simple function for adding a traversal to the internal list
Definition: AstCombinedProcessingImpl.h:383
AstCombinedTopDownBottomUpProcessing::evaluateInheritedAttribute
virtual InheritedAttributeTypeList * evaluateInheritedAttribute(SgNode *astNode, InheritedAttributeTypeList *inheritedValues)
pure virtual function which must be implemented to compute the inherited attribute at a node
Definition: AstCombinedProcessingImpl.h:230
SgTreeTraversal
This class is temporary. Do not use.
Definition: AstProcessing.h:97
AstCombinedBottomUpProcessing::defaultSynthesizedAttribute
virtual SynthesizedAttributeTypeList * defaultSynthesizedAttribute()
Allows to provide a default value for a synthesized attribute of primitive type (e....
Definition: AstCombinedProcessingImpl.h:565
AstCombinedBottomUpProcessing::addTraversal
void addTraversal(TraversalPtr)
simple function for adding a traversal to the internal list
Definition: AstCombinedProcessingImpl.h:501
AstBottomUpProcessing
Attribute Evaluator for synthesized attributes.
Definition: AstProcessing.h:289
AstCombinedTopDownBottomUpProcessing::atTraversalStart
virtual void atTraversalStart()
Function called at the start of the traversal, before any node is visited; override if necessary,...
Definition: AstCombinedProcessingImpl.h:335
AstCombinedTopDownProcessing::atTraversalStart
virtual void atTraversalStart()
Function called at the start of the traversal, before any node is visited; override if necessary,...
Definition: AstCombinedProcessingImpl.h:431
SgCombinedTreeTraversal::addTraversal
void addTraversal(TraversalPtr)
simple function for adding a traversal to the internal list
Definition: AstCombinedProcessingImpl.h:34
AstCombinedTopDownBottomUpProcessing
Definition: AstCombinedProcessing.h:66
AstCombinedTopDownBottomUpProcessing::get_traversalPtrListRef
TraversalPtrList & get_traversalPtrListRef()
function for obtaining a reference to the internal list of traversals, you can use this for any conta...
Definition: AstCombinedProcessingImpl.h:221
AstCombinedBottomUpProcessing::atTraversalStart
virtual void atTraversalStart()
Function called at the start of the traversal, before any node is visited; override if necessary,...
Definition: AstCombinedProcessingImpl.h:581
AstCombinedTopDownBottomUpProcessing::AstCombinedTopDownBottomUpProcessing
AstCombinedTopDownBottomUpProcessing()
default constructor
Definition: AstCombinedProcessingImpl.h:197
AstCombinedTopDownProcessing::AstCombinedTopDownProcessing
AstCombinedTopDownProcessing()
default constructor
Definition: AstCombinedProcessingImpl.h:367
AstCombinedTopDownProcessing
Definition: AstCombinedProcessing.h:110
SgCombinedTreeTraversal
Definition: AstCombinedProcessing.h:22
AstCombinedTopDownBottomUpProcessing::addTraversal
void addTraversal(TraversalPtr)
simple function for adding a traversal to the internal list
Definition: AstCombinedProcessingImpl.h:213
SgNode
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:6739
SgCombinedTreeTraversal::get_traversalPtrListRef
TraversalPtrList & get_traversalPtrListRef()
function for obtaining a reference to the internal list of traversals, you can use this for any conta...
Definition: AstCombinedProcessingImpl.h:42
AstCombinedBottomUpProcessing::AstCombinedBottomUpProcessing
AstCombinedBottomUpProcessing()
default constructor
Definition: AstCombinedProcessingImpl.h:485
StackFrameVector
Definition: StackFrameVector.h:43
AstCombinedBottomUpProcessing
Definition: AstCombinedProcessing.h:147
SgCombinedTreeTraversal::SgCombinedTreeTraversal
SgCombinedTreeTraversal()
default constructor
Definition: AstCombinedProcessingImpl.h:18
AstTopDownProcessing
Attribute Evaluator for inherited attributes.
Definition: AstProcessing.h:237