ROSE  0.11.145.0
AstSimpleProcessing.h
1 // Original Author (AstProcessing classes): Markus Schordan
2 // Rewritten by: Gergo Barany
3 // $Id: AstSimpleProcessing.h,v 1.3 2008/01/08 02:56:39 dquinlan Exp $
4 
5 // See comments in AstProcessing.h for list of changes during the rewrite
6 
7 #ifndef ASTPROCESSINGSIMPLE_H
8 #define ASTPROCESSINGSIMPLE_H
9 
10 #include "AstProcessing.h"
11 
12 // GB (7/6/2007): Added AstPrePostProcessing as a pre- and postorder
13 // traversal without attributes -- I feel this will be useful for many
14 // applications. (At least, I constantly find myself wanting to write
15 // traversals that simply push nodes onto a stack in the preorder visit and
16 // pop the stack in the postorder visit. With the existing traversal classes I
17 // had to use a TopDownBottomUpProcessing and ignore the attributes.)
19 
20 class ROSE_DLL_API AstPrePostProcessing
21  : public SgTreeTraversal<DummyAttribute, DummyAttribute>
22 {
23 public:
25  void traverse(SgNode *node);
26 
28  void traverseWithinFile(SgNode *node);
29 
31  void traverseInputFiles(SgProject *projectNode);
32 
33  friend class AstCombinedPrePostProcessing;
34 
35 protected:
37  virtual void preOrderVisit(SgNode *astNode) = 0;
38 
40  virtual void postOrderVisit(SgNode *astNode) = 0;
41 
43  virtual void atTraversalStart();
44  virtual void atTraversalEnd();
45 
46 private:
47  DummyAttribute evaluateInheritedAttribute(SgNode *astNode, DummyAttribute inheritedValue);
48  DummyAttribute evaluateSynthesizedAttribute(SgNode* astNode, DummyAttribute inheritedValue,
50  DummyAttribute defaultSynthesizedAttribute(DummyAttribute inheritedValue);
51 };
52 
53 
54 // Logically, AstSimpleProcessing could be derived from
55 // AstPrePostProcessing, but that results in a (barely) measurable
56 // performance hit.
58 
59 class ROSE_DLL_API AstSimpleProcessing
60  : public SgTreeTraversal<DummyAttribute, DummyAttribute>
61 {
62 public:
63  typedef t_traverseOrder Order;
64 
66  void traverse(SgNode* node, Order treeTraversalOrder);
67 
69  void traverseWithinFile(SgNode* node, Order treeTraversalOrder);
70 
72  void traverseInputFiles(SgProject* projectNode, Order treeTraversalOrder);
73 
74  friend class AstCombinedSimpleProcessing;
75 
76 protected:
78  virtual void visit(SgNode* astNode) = 0;
79 
85  virtual void atTraversalStart();
86  virtual void atTraversalEnd();
87 
88 private:
89  DummyAttribute evaluateInheritedAttribute(SgNode *astNode, DummyAttribute inheritedValue);
90  DummyAttribute evaluateSynthesizedAttribute(SgNode* astNode, DummyAttribute inheritedValue,
92  DummyAttribute defaultSynthesizedAttribute(DummyAttribute inheritedValue);
93 };
94 
95 
98 
99 #endif
virtual void postOrderVisit(SgNode *astNode)
this method is called at every traversed node after its children were traversed
This class is temporary. Do not use.
Definition: AstProcessing.h:97
Class for traversing the AST.
virtual void visit(SgNode *astNode)
this method is called at every traversed node.
virtual void preOrderVisit(SgNode *astNode)
these methods are called at every traversed node.
virtual void atTraversalStart()
functions called when the traversal starts and ends, respectively
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:9846
virtual void atTraversalStart()
GB (06/04/2007): A new virtual function called at the start of the traversal, before any node is actu...
This class represents a source project, with a list of SgFile objects and global information about th...