All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rose_nodes.h
Go to the documentation of this file.
1 #ifndef ROSE_NODES_H_INCLUDED_
2 #define ROSE_NODES_H_INCLUDED_
3 
4 #include "rose.h"
5 #include "../internal_representation/design.h"
6 
7 namespace risc {
8 
9 extern SgProject* get_project();
10 };
11 
12 namespace risc {
13 
14 namespace tools {
15 
16 class RoseNodes {
17 
18 public:
19 
20  static const std::vector<SgNode*>& get_func_defs()
21  {
22  initialize();
23  return func_defs_;
24  }
25 
26  static const std::vector<SgNode*>& get_func_decls()
27  {
28  initialize();
29  return func_decls_;
30  }
31 
32  static const std::vector<SgNode*>& get_class_defs()
33  {
34  initialize();
35  return class_defs_;
36  }
37 
38  static const std::vector<SgNode*>& get_class_decls()
39  {
40  initialize();
41  return class_decls_;
42  }
43 
44  static const std::vector<SgNode*>& get_namespace_defs()
45  {
46  initialize();
47  return namespace_defs_;
48  }
49 
50  static const std::vector<SgNode*>& get_template_instance_decl()
51  {
52  initialize();
54  }
55 
56  static const std::vector<SgNode*>& get_typedef_decl()
57  {
58  initialize();
59  return typedef_decl_;
60  }
61 
62  static const std::vector<SgNode*>& get_var_decl()
63  {
64  initialize();
65  return var_decl_;
66  }
67 
68 private:
69 
70  static bool is_initialized_;
71 
72  static std::vector<SgNode*> func_defs_;
73  static std::vector<SgNode*> func_decls_;
74  static std::vector<SgNode*> class_defs_;
75  static std::vector<SgNode*> class_decls_;
76  static std::vector<SgNode*> namespace_defs_;
77  static std::vector<SgNode*> template_instance_decl_;
78  static std::vector<SgNode*> typedef_decl_;
79  static std::vector<SgNode*> var_decl_;
80 
81  static void initialize()
82  {
83  if(RoseNodes::is_initialized_ == true) {
84  return;
85  }
86 
87  SgProject *project = risc::get_project();
88 
89  assert(project && "Project is not yet initialized");
90 
92  = NodeQuery::querySubTree(project, V_SgFunctionDefinition);
93 
95  = NodeQuery::querySubTree(project, V_SgFunctionDeclaration);
96 
98  = NodeQuery::querySubTree(project, V_SgClassDefinition);
99 
101  = NodeQuery::querySubTree(project, V_SgClassDeclaration);
102 
104  = NodeQuery::querySubTree(project, V_SgNamespaceDefinitionStatement);
105 
107  = NodeQuery::querySubTree(project, V_SgTemplateInstantiationDecl);
108 
110  = NodeQuery::querySubTree(project, V_SgTypedefDeclaration);
111 
113  = NodeQuery::querySubTree(project, V_SgVariableDeclaration);
114 
116  }
117 };
118 
119 }; // end of namespace tools
120 
121 }; // end of namespace risc
122 
123 #endif /* ROSE_NODES_H_INCLUDED_ */
124 
125 /* ex: set softtabstop=2 tabstop=2 shiftwidth=2 expandtab: */
static const std::vector< SgNode * > & get_func_decls()
Definition: rose_nodes.h:26
static std::vector< SgNode * > class_defs_
Definition: rose_nodes.h:74
static const std::vector< SgNode * > & get_typedef_decl()
Definition: rose_nodes.h:56
static const std::vector< SgNode * > & get_func_defs()
Definition: rose_nodes.h:20
SgProject * get_project()
Definition: design.cpp:760
static std::vector< SgNode * > func_decls_
Definition: rose_nodes.h:73
static std::vector< SgNode * > template_instance_decl_
Definition: rose_nodes.h:77
Definition: rose_nodes.h:16
static const std::vector< SgNode * > & get_class_defs()
Definition: rose_nodes.h:32
static const std::vector< SgNode * > & get_var_decl()
Definition: rose_nodes.h:62
static bool is_initialized_
Definition: rose_nodes.h:70
static std::vector< SgNode * > typedef_decl_
Definition: rose_nodes.h:78
static const std::vector< SgNode * > & get_class_decls()
Definition: rose_nodes.h:38
static std::vector< SgNode * > class_decls_
Definition: rose_nodes.h:75
static std::vector< SgNode * > func_defs_
Definition: rose_nodes.h:72
static std::vector< SgNode * > namespace_defs_
Definition: rose_nodes.h:76
static std::vector< SgNode * > var_decl_
Definition: rose_nodes.h:79
static const std::vector< SgNode * > & get_template_instance_decl()
Definition: rose_nodes.h:50
static const std::vector< SgNode * > & get_namespace_defs()
Definition: rose_nodes.h:44
static void initialize()
Definition: rose_nodes.h:81