ReachDefsStandard.hpp

Go to the documentation of this file.
00001 
00016 #ifndef ReachDefsStandard_hpp
00017 #define ReachDefsStandard_hpp
00018 
00019 #include <cassert>
00020 #include <iostream>
00021 #include <map>
00022 #include <set>
00023 #include <vector>
00024 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00025 #include <OpenAnalysis/IRInterface/IRHandles.hpp>
00026 #include <OpenAnalysis/ReachDefs/Interface.hpp>
00027 #include <OpenAnalysis/OABase/Annotation.hpp>
00028 #include <OpenAnalysis/Utils/GenOutputTool.hpp>
00029 
00030 namespace OA {
00031   namespace ReachDefs {
00032 
00033 
00034 
00035 class ReachDefsStandard : public virtual ReachDefs::Interface,
00036                           public virtual Annotation 
00037 {
00038   public:
00039     ReachDefsStandard(ProcHandle p) 
00040       {
00041           mExitReachDefs = new std::set<StmtHandle>; 
00042       }
00043     ~ReachDefsStandard() {}
00044 
00047     OA_ptr<Interface::ReachDefsIterator> getReachDefsIterator(StmtHandle s); 
00048 
00051     OA_ptr<Interface::ReachDefsIterator> getExitReachDefsIterator(); 
00052 
00053     //*****************************************************************
00054     // Construction methods 
00055     //*****************************************************************
00056 
00058     void insertReachDef(StmtHandle s, StmtHandle reachDef)
00059     { if (mReachDefs[s].ptrEqual(NULL)) {
00060         mReachDefs[s] = new std::set<StmtHandle>;
00061       }
00062       mReachDefs[s]->insert(reachDef); 
00063     }
00064 
00066     void insertExitReachDef(StmtHandle reachDef)
00067     { 
00068       mExitReachDefs->insert(reachDef); 
00069     }
00070 
00071 
00072     //*****************************************************************
00073     // Output
00074     //*****************************************************************
00075 
00077     void output(IRHandlesIRInterface& pIR);
00078 
00082     void dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir);
00083 
00084   protected:
00085     // data members
00086     std::map<StmtHandle,OA_ptr<std::set<StmtHandle> > >  mReachDefs;
00087     OA_ptr<std::set<StmtHandle> > mExitReachDefs;
00088 
00089   public:
00090 
00095     class ReachDefsStandardReachDefsIterator 
00096                                 : public IRHandleSetIterator<StmtHandle>,
00097                                   public Interface::ReachDefsIterator
00098     {
00099       public:
00100         ReachDefsStandardReachDefsIterator(OA_ptr<std::set<StmtHandle> > pSet) 
00101             : IRHandleSetIterator<StmtHandle>(pSet) {}
00102         ~ReachDefsStandardReachDefsIterator() {}
00103 
00104         void operator++() { IRHandleSetIterator<StmtHandle>::operator++(); }
00105         bool isValid() const 
00106           { return IRHandleSetIterator<StmtHandle>::isValid(); }
00107         StmtHandle current() const 
00108           { return IRHandleSetIterator<StmtHandle>::current(); }
00109         void reset() { IRHandleSetIterator<StmtHandle>::current(); }
00110     };
00111  
00112 };
00113 
00114   } // end of ReachDefs namespace
00115 } // end of OA namespace
00116 
00117 #endif
00118