ExprTreeVisitor.hpp

Go to the documentation of this file.
00001 
00015 #ifndef ExprTreeVisitor_H
00016 #define ExprTreeVisitor_H
00017 
00018 #include <OpenAnalysis/ExprTree/ExprTree.hpp>
00019 
00020 namespace OA {
00021 
00022 //--------------------------------------------------------------------
00039 class ExprTreeVisitor {
00040 protected:
00041   ExprTreeVisitor() {}
00042 public:
00043   virtual ~ExprTreeVisitor() {}
00044 
00046   virtual void visitExprTreeBefore(ExprTree&) = 0;
00047 
00049   virtual void visitExprTreeAfter(ExprTree&) = 0;
00050 
00051   //---------------------------------------
00052   // method for each ExprTree::Node subclass
00053   //---------------------------------------
00054 
00055   // default base class so that visitors can handle unknown
00056   // node sub-classes in a generic fashion
00057   virtual void visitNode(ExprTree::Node&) = 0;
00058 
00059   virtual void visitOpNode(ExprTree::OpNode& n) { visitNode(n); }
00060   virtual void visitCallNode(ExprTree::CallNode& n) { visitNode(n); } 
00061   virtual void visitMemRefNode(ExprTree::MemRefNode& n)  { visitNode(n); }
00062   virtual void visitConstSymNode(ExprTree::ConstSymNode& n)  { visitNode(n); }
00063   virtual void visitConstValNode(ExprTree::ConstValNode& n)  { visitNode(n); }
00064 
00065 };
00066 
00067 
00068 } // end of OA namespace
00069 
00070 #endif