AstSimpleProcessing.h

Go to the documentation of this file.
00001 // Original Author (AstProcessing classes): Markus Schordan
00002 // Rewritten by: Gergo Barany
00003 // $Id: AstSimpleProcessing.h,v 1.3 2008/01/08 02:56:39 dquinlan Exp $
00004 
00005 // See comments in AstProcessing.h for list of changes during the rewrite
00006 
00007 #ifndef ASTPROCESSINGSIMPLE_H
00008 #define ASTPROCESSINGSIMPLE_H
00009 
00010 #include "AstProcessing.h"
00011 
00012 // GB (7/6/2007): Added AstPrePostProcessing as a pre- and postorder
00013 // traversal without attributes -- I feel this will be useful for many
00014 // applications. (At least, I constantly find myself wanting to write
00015 // traversals that simply push nodes onto a stack in the preorder visit and
00016 // pop the stack in the postorder visit. With the existing traversal classes I
00017 // had to use a TopDownBottomUpProcessing and ignore the attributes.)
00018 class AstCombinedPrePostProcessing;
00019 
00020 class AstPrePostProcessing
00021     : public SgTreeTraversal<DummyAttribute, DummyAttribute>
00022 {
00023 public:
00025     void traverse(SgNode *node);
00026 
00028     void traverseWithinFile(SgNode *node);
00029 
00031     void traverseInputFiles(SgProject *projectNode);
00032 
00033     friend class AstCombinedPrePostProcessing;
00034 
00035 protected:
00037     virtual void preOrderVisit(SgNode *astNode) = 0;
00038 
00040     virtual void postOrderVisit(SgNode *astNode) = 0;
00041 
00043     virtual void atTraversalStart();
00044     virtual void atTraversalEnd();
00045 
00046 private:
00047     DummyAttribute evaluateInheritedAttribute(SgNode *astNode, DummyAttribute inheritedValue);
00048     DummyAttribute evaluateSynthesizedAttribute(SgNode* astNode, DummyAttribute inheritedValue,
00049             SynthesizedAttributesList l);
00050     DummyAttribute defaultSynthesizedAttribute(DummyAttribute inheritedValue);
00051 };
00052 
00053 
00054 // Logically, AstSimpleProcessing could be derived from
00055 // AstPrePostProcessing, but that results in a (barely) measurable
00056 // performance hit.
00057 class AstCombinedSimpleProcessing;
00058 
00059 class AstSimpleProcessing
00060     : public SgTreeTraversal<DummyAttribute, DummyAttribute>
00061 {
00062 public:
00063     typedef t_traverseOrder Order;
00064 
00066     void traverse(SgNode* node, Order treeTraversalOrder);
00067 
00069     void traverseWithinFile(SgNode* node, Order treeTraversalOrder);
00070 
00072     void traverseInputFiles(SgProject* projectNode, Order treeTraversalOrder);
00073 
00074     friend class AstCombinedSimpleProcessing;
00075 
00076 protected:
00078     virtual void visit(SgNode* astNode) = 0;
00079 
00085     virtual void atTraversalStart();
00086     virtual void atTraversalEnd();
00087 
00088 private:
00089     DummyAttribute evaluateInheritedAttribute(SgNode *astNode, DummyAttribute inheritedValue);
00090     DummyAttribute evaluateSynthesizedAttribute(SgNode* astNode, DummyAttribute inheritedValue,
00091             SynthesizedAttributesList l);
00092     DummyAttribute defaultSynthesizedAttribute(DummyAttribute inheritedValue);
00093 };
00094 
00095 
00097 class SgSimpleProcessing : public AstSimpleProcessing {};
00098 
00099 #endif

Generated on Tue Jan 31 05:31:20 2012 for ROSE by  doxygen 1.4.7