00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef SHINTERNALS_HPP
00021 #define SHINTERNALS_HPP
00022
00023 #include <map>
00024 #include "ShDllExport.hpp"
00025 #include "ShVariableNode.hpp"
00026 #include "ShCtrlGraph.hpp"
00027 #include "ShBackend.hpp"
00028 #include "ShProgramNode.hpp"
00029 #include "ShStructural.hpp"
00030 #include <map>
00031
00032 namespace SH {
00033
00034 typedef std::map<ShVariableNodePtr, ShVariableNodePtr> ShVarMap;
00035
00036 struct
00037 SH_DLLEXPORT ShVariableReplacer {
00038
00039 ShVariableReplacer(ShVarMap& v);
00040
00041
00042 ShVariableReplacer& operator=(ShVariableReplacer const&);
00043
00044
00045 void operator()(const ShCtrlGraphNodePtr& node);
00046
00047
00048 void operator()(ShProgramNode::VarList &varList);
00049
00050
00051
00052 void operator()(const ShStructuralNodePtr& node);
00053
00054
00055 void repVar(ShVariable& var);
00056
00057 ShVarMap& varMap;
00058 };
00059
00060
00065 class
00066 SH_DLLEXPORT ShVarTransformMap {
00067 private:
00068 ShVarMap m_NewToOldMap;
00069
00070 public:
00071 ShVarTransformMap() {}
00072 explicit ShVarTransformMap(const ShVarTransformMap &m)
00073 : m_NewToOldMap(m.m_NewToOldMap)
00074 {}
00075 ShVarTransformMap & operator=(const ShVarTransformMap &m)
00076 {
00077 m_NewToOldMap = m.m_NewToOldMap;
00078 return *this;
00079 }
00080
00082 void clear() { m_NewToOldMap.clear(); }
00083
00087 void add_variable_transform(const ShVariableNodePtr& origVar, const ShVariableNodePtr& newVar);
00088
00092 ShVariableNodePtr get_original_variable(const ShVariableNodePtr& newVar) const
00093 {
00094 ShVarMap::const_iterator i = m_NewToOldMap.find(newVar);
00095 return (i != m_NewToOldMap.end() ? i->second : newVar);
00096 }
00097 };
00098
00099
00100 }
00101
00102 #endif
00103