uniqueNameTraversal.h

Go to the documentation of this file.
00001 #pragma once
00002 #include <rose.h>
00003 #include <vector>
00004 
00005 namespace ssa_private
00006 {
00007 
00011 class VarUniqueName : public AstAttribute
00012 {
00013 private:
00014 
00018     std::vector<SgInitializedName*> key;
00019 
00020     bool usesThis;
00021 
00022 public:
00023 
00026     VarUniqueName() : key(), usesThis(false)
00027     {
00028     }
00029 
00036     VarUniqueName(SgInitializedName* thisNode) : usesThis(false)
00037     {
00038         key.push_back(thisNode);
00039     }
00040 
00049     VarUniqueName(const std::vector<SgInitializedName*>& prefix, SgInitializedName* thisNode) : usesThis(false)
00050     {
00051         key.assign(prefix.begin(), prefix.end());
00052         key.push_back(thisNode);
00053     }
00054 
00059     VarUniqueName(const VarUniqueName& other) : AstAttribute(other), usesThis(false)
00060     {
00061         key.assign(other.key.begin(), other.key.end());
00062     }
00063 
00064     VarUniqueName* copy()
00065     {
00066         VarUniqueName* newName = new VarUniqueName(*this);
00067         return newName;
00068     }
00069 
00074     const std::vector<SgInitializedName*>& getKey()
00075     {
00076         return key;
00077     }
00078 
00083     void setKey(const std::vector<SgInitializedName*>& newKey)
00084     {
00085         key.assign(newKey.begin(), newKey.end());
00086     }
00087 
00088     bool getUsesThis()
00089     {
00090         return usesThis;
00091     }
00092 
00093     void setUsesThis(bool uses)
00094     {
00095         usesThis = uses;
00096     }
00097 
00102     std::string getNameString()
00103     {
00104         std::string name = "";
00105         std::vector<SgInitializedName*>::iterator iter;
00106         if (usesThis)
00107             name += "this->";
00108         for (iter = key.begin(); iter != key.end(); ++iter)
00109         {
00110             if (iter != key.begin())
00111             {
00112                 name += ":";
00113             }
00114             name += (*iter)->get_name().getString();
00115         }
00116 
00117         return name;
00118     }
00119 };
00120 
00122 class VariableReferenceSet
00123 {
00127     SgNode* currentVar;
00128 
00129 public:
00130 
00132 
00133     VariableReferenceSet() : currentVar(NULL)
00134     {
00135     }
00136 
00137     VariableReferenceSet(SgNode* var)
00138     {
00139         currentVar = var;
00140     }
00141 
00142     SgNode* getCurrentVar()
00143     {
00144         return currentVar;
00145     }
00146 };
00147 
00149 class UniqueNameTraversal : public AstBottomUpProcessing<VariableReferenceSet>
00150 {
00152     std::vector<SgInitializedName*> allInitNames;
00153 
00156     SgInitializedName* resolveTemporaryInitNames(SgInitializedName* name);
00157 
00160     const bool treatPointersAsStructs;
00161 
00164     const bool propagateNamesThroughComma;
00165 
00166 public:
00167 
00169     static std::string varKeyTag;
00170 
00172     typedef std::vector<SgInitializedName*> VarName;
00173 
00176 
00177     UniqueNameTraversal(const std::vector<SgInitializedName*>& allNames,
00178             bool treatPointersAsStructs = true, bool propagateNamesThroughComma = true) : allInitNames(allNames),
00179     treatPointersAsStructs(treatPointersAsStructs), propagateNamesThroughComma(propagateNamesThroughComma)
00180     {
00181     }
00182 
00191     virtual VariableReferenceSet evaluateSynthesizedAttribute(SgNode* node, SynthesizedAttributesList attrs);
00192 };
00193 
00194 } //namespace ssa_private

Generated on Sat May 19 00:53:07 2012 for ROSE by  doxygen 1.4.7