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 private: 00063 00064 static bool is_initialized_; 00065 00066 static std::vector<SgNode*> func_defs_; 00067 static std::vector<SgNode*> func_decls_; 00068 static std::vector<SgNode*> class_defs_; 00069 static std::vector<SgNode*> class_decls_; 00070 static std::vector<SgNode*> namespace_defs_; 00071 static std::vector<SgNode*> template_instance_decl_; 00072 static std::vector<SgNode*> typedef_decl_; 00073 00074 static void initialize() 00075 { 00076 if(RoseNodes::is_initialized_ == true) { 00077 return; 00078 } 00079 00080 SgProject *project = risc::get_project(); 00081 00082 assert(project && "Project is not yet initialized"); 00083 00084 RoseNodes::func_defs_ 00085 = NodeQuery::querySubTree(project, V_SgFunctionDefinition); 00086 00087 RoseNodes::func_decls_ 00088 = NodeQuery::querySubTree(project, V_SgFunctionDeclaration); 00089 00090 RoseNodes::class_defs_ 00091 = NodeQuery::querySubTree(project, V_SgClassDefinition); 00092 00093 RoseNodes::class_decls_ 00094 = NodeQuery::querySubTree(project, V_SgClassDeclaration); 00095 00096 RoseNodes::namespace_defs_ 00097 = NodeQuery::querySubTree(project, V_SgNamespaceDefinitionStatement); 00098 00099 RoseNodes::template_instance_decl_ 00100 = NodeQuery::querySubTree(project, V_SgTemplateInstantiationDecl); 00101 00102 RoseNodes::typedef_decl_ 00103 = NodeQuery::querySubTree(project, V_SgTypedefDeclaration); 00104 00105 RoseNodes::is_initialized_ = true; 00106 } 00107 }; 00108 00109 }; // end of namespace tools 00110 00111 }; // end of namespace risc 00112 00113 #endif /* ROSE_NODES_H_INCLUDED_ */ 00114 00115 /* ex: set softtabstop=2 tabstop=2 shiftwidth=2 expandtab: */