ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AstCombinedProcessing.h
Go to the documentation of this file.
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:
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 
38 
45 
46 protected:
48  SgNode *astNode,
49  InheritedAttributeTypeList *inheritedValues);
51  SgNode *astNode,
52  InheritedAttributeTypeList *inheritedValues,
55  virtual void atTraversalStart();
56  virtual void atTraversalEnd();
57 
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:
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;
77 
82 
89 
90 protected:
92  SgNode *astNode,
93  InheritedAttributeTypeList *inheritedValues);
95  SgNode *astNode,
96  InheritedAttributeTypeList *inheritedValues,
99  virtual void atTraversalStart();
100  virtual void atTraversalEnd();
101 
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:
116  typedef std::vector<TraversalPtr> TraversalPtrList;
117  typedef std::vector<InheritedAttributeType> InheritedAttributeTypeList;
118 
123 
130 
131 protected:
133  SgNode *astNode,
134  InheritedAttributeTypeList *inheritedValues);
135  virtual void atTraversalStart();
136  virtual void atTraversalEnd();
138 
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:
153  typedef std::vector<TraversalPtr> TraversalPtrList;
154  typedef std::vector<SynthesizedAttributeType> SynthesizedAttributeTypeList;
157 
162 
169 
170 protected:
172  SgNode *astNode,
175  virtual void atTraversalStart();
176  virtual void atTraversalEnd();
177 
179 
180 private:
181  typename TraversalPtrList::iterator tBegin, tEnd;
182  typename TraversalPtrList::size_type numberOfTraversals;
183 };
184 
186 
188 
189 #endif