00001 #pragma once 00002 #include "rose.h" 00003 #include "staticSingleAssignment.h" 00004 00005 namespace ssa_private 00006 { 00007 00009 class ChildUses 00010 { 00011 private: 00013 SgVarRefExp* currentVar; 00014 00016 std::vector<SgNode*> uses; 00017 00018 public: 00019 00021 ChildUses() : currentVar(NULL) 00022 { 00023 } 00024 00025 ChildUses(SgNode* useNode, SgVarRefExp* var) 00026 { 00027 uses.push_back(useNode); 00028 currentVar = var; 00029 } 00030 00035 ChildUses(const std::vector<SgNode*>& useTree, SgVarRefExp* var = NULL) 00036 { 00037 if (useTree.size() > 0) 00038 uses.assign(useTree.begin(), useTree.end()); 00039 currentVar = var; 00040 } 00041 00046 std::vector<SgNode*>& getUses() 00047 { 00048 return uses; 00049 } 00050 00055 void setUses(const std::vector<SgNode*>& newUses) 00056 { 00057 uses.assign(newUses.begin(), newUses.end()); 00058 } 00059 00060 SgVarRefExp* getCurrentVar() const 00061 { 00062 return currentVar; 00063 } 00064 }; 00065 00069 class DefsAndUsesTraversal : public AstBottomUpProcessing<ChildUses> 00070 { 00071 StaticSingleAssignment* ssa; 00072 00075 const bool treatPointersAsStructs; 00076 00077 public: 00078 00081 DefsAndUsesTraversal(StaticSingleAssignment* ssa, bool treatPointersAsStructs = true) : ssa(ssa), 00082 treatPointersAsStructs(treatPointersAsStructs) 00083 { 00084 } 00085 00094 virtual ChildUses evaluateSynthesizedAttribute(SgNode* node, SynthesizedAttributesList attrs); 00095 00096 private: 00097 00099 void addUsesToNode(SgNode* node, std::vector<SgNode*> uses); 00100 00102 void addDefForVarAtNode(SgVarRefExp* currentVar, SgNode* defNode); 00103 }; 00104 00105 } //namespace ssa_private
1.4.7