00001 #ifndef ROSE_NODES_H_INCLUDED_ 00002 #define ROSE_NODES_H_INCLUDED_ 00003 00004 #include "rose.h" 00005 #include "../internal_representation/design.h" 00006 00007 namespace risc { 00008 00009 extern SgProject* get_project(); 00010 }; 00011 00012 namespace risc { 00013 00014 namespace tools { 00015 00016 class RoseNodes { 00017 00018 public: 00019 00020 static const std::vector<SgNode*>& get_func_defs() 00021 { 00022 initialize(); 00023 return func_defs_; 00024 } 00025 00026 static const std::vector<SgNode*>& get_func_decls() 00027 { 00028 initialize(); 00029 return func_decls_; 00030 } 00031 00032 static const std::vector<SgNode*>& get_class_defs() 00033 { 00034 initialize(); 00035 return class_defs_; 00036 } 00037 00038 static const std::vector<SgNode*>& get_class_decls() 00039 { 00040 initialize(); 00041 return class_decls_; 00042 } 00043 00044 static const std::vector<SgNode*>& get_namespace_defs() 00045 { 00046 initialize(); 00047 return namespace_defs_; 00048 } 00049 00050 static const std::vector<SgNode*>& get_template_instance_decl() 00051 { 00052 initialize(); 00053 return template_instance_decl_; 00054 } 00055 00056 static const std::vector<SgNode*>& get_typedef_decl() 00057 { 00058 initialize(); 00059 return typedef_decl_; 00060 } 00061 00062 static const std::vector<SgNode*>& get_var_decl() 00063 { 00064 initialize(); 00065 return var_decl_; 00066 } 00067 00068 private: 00069 00070 static bool is_initialized_; 00071 00072 static std::vector<SgNode*> func_defs_; 00073 static std::vector<SgNode*> func_decls_; 00074 static std::vector<SgNode*> class_defs_; 00075 static std::vector<SgNode*> class_decls_; 00076 static std::vector<SgNode*> namespace_defs_; 00077 static std::vector<SgNode*> template_instance_decl_; 00078 static std::vector<SgNode*> typedef_decl_; 00079 static std::vector<SgNode*> var_decl_; 00080 00081 static void initialize() 00082 { 00083 if(RoseNodes::is_initialized_ == true) { 00084 return; 00085 } 00086 00087 SgProject *project = risc::get_project(); 00088 00089 assert(project && "Project is not yet initialized"); 00090 00091 RoseNodes::func_defs_ 00092 = NodeQuery::querySubTree(project, V_SgFunctionDefinition); 00093 00094 RoseNodes::func_decls_ 00095 = NodeQuery::querySubTree(project, V_SgFunctionDeclaration); 00096 00097 RoseNodes::class_defs_ 00098 = NodeQuery::querySubTree(project, V_SgClassDefinition); 00099 00100 RoseNodes::class_decls_ 00101 = NodeQuery::querySubTree(project, V_SgClassDeclaration); 00102 00103 RoseNodes::namespace_defs_ 00104 = NodeQuery::querySubTree(project, V_SgNamespaceDefinitionStatement); 00105 00106 RoseNodes::template_instance_decl_ 00107 = NodeQuery::querySubTree(project, V_SgTemplateInstantiationDecl); 00108 00109 RoseNodes::typedef_decl_ 00110 = NodeQuery::querySubTree(project, V_SgTypedefDeclaration); 00111 00112 RoseNodes::var_decl_ 00113 = NodeQuery::querySubTree(project, V_SgVariableDeclaration); 00114 00115 RoseNodes::is_initialized_ = true; 00116 } 00117 }; 00118 00119 }; // end of namespace tools 00120 00121 }; // end of namespace risc 00122 00123 #endif /* ROSE_NODES_H_INCLUDED_ */ 00124 00125 /* ex: set softtabstop=2 tabstop=2 shiftwidth=2 expandtab: */