ROSE 0.11.145.192
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
20class ROSE_DLL_API AstPrePostProcessing
21 : public SgTreeTraversal<DummyAttribute, DummyAttribute>
22{
23public:
25 void traverse(SgNode *node);
26
29
31 void traverseInputFiles(SgProject *projectNode);
32
34
35protected:
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
46private:
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
59class ROSE_DLL_API AstSimpleProcessing
60 : public SgTreeTraversal<DummyAttribute, DummyAttribute>
61{
62public:
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
76protected:
78 virtual void visit(SgNode* astNode) = 0;
79
85 virtual void atTraversalStart();
86 virtual void atTraversalEnd();
87
88private:
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
void traverse(SgNode *node)
traverse the entire AST
void traverseInputFiles(SgProject *projectNode)
traverse only nodes which represent files which were specified on the command line (=input files).
virtual void postOrderVisit(SgNode *astNode)=0
this method is called at every traversed node after its children were traversed
virtual void preOrderVisit(SgNode *astNode)=0
this method is called at every traversed node before its children are traversed
virtual void atTraversalStart()
functions called when the traversal starts and ends, respectively
void traverseWithinFile(SgNode *node)
traverse only nodes which represent the same file as where the traversal was started
Class for traversing the AST.
void traverseInputFiles(SgProject *projectNode, Order treeTraversalOrder)
traverse only nodes which represent files which were specified on the command line (=input files).
virtual void atTraversalStart()
GB (06/04/2007): A new virtual function called at the start of the traversal, before any node is actu...
virtual void visit(SgNode *astNode)=0
this method is called at every traversed node.
void traverseWithinFile(SgNode *node, Order treeTraversalOrder)
traverse only nodes which represent the same file as where the traversal was started
void traverse(SgNode *node, Order treeTraversalOrder)
traverse the entire AST. Order defines preorder (preorder) or postorder (postorder) traversal....
This class represents the base class for all IR nodes within Sage III.
This class represents a source project, with a list of SgFile objects and global information about th...
This class is temporary. Do not use.