All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
instance_tree.h
Go to the documentation of this file.
1 #ifndef INSTANCE_TREE_H_INCLUDED_
2 #define INSTANCE_TREE_H_INCLUDED_
3 
4 #include "rose.h"
5 
6 #include <vector>
7 #include <list>
8 #include <utility>
9 
10 namespace risc {
11 
12 class Class;
13 class Object;
14 
15 class InstanceTree {
16 
17 public:
18  InstanceTree();
19 
20  InstanceTree(const InstanceTree &other);
21 
22  struct Element {
25  int id;
26 
27  Element(Class* first_, Object* second_, int id_ = 0):
28  first(first_), second(second_), id(id_)
29  { }
30 
32  first(NULL), second(NULL), id(0)
33  { }
34  };
35 
36  typedef std::list<Element> Path;
37 
45 
50  std::list<InstanceTree> find_all_instances_of(SgSymbol *var_sym);
51 
57 
62  void print_instance_tree();
63 
68  Class* get_scope();
69 
74  Object* get_object();
75 
80  SgVariableSymbol* get_object_symbol();
81 
86  void get_all_ports(std::list<InstanceTree>& occurence);
87 
92  void get_all_events(std::list<InstanceTree>& occurence);
93 
98  Element pop_back();
99 
104  void push_back(Element ohs);
105 
116  };
117 
131  void
133  SgVariableDefinition *var_def,
134  int instance_id,
135  risc::InstanceTree &tree,
136  VariableType type);
137 
148  void
150  SgVariableDefinition *var_def,
151  int &current_id,
152  int instance_id,
153  risc::InstanceTree &tree,
154  bool &found,
155  VariableType type);
156 
163  extend_with_symbol_list(std::list<SgVariableSymbol*> syms);
164 
165  bool operator==(const InstanceTree &ohs) const;
166 
168 
169 private:
176  void recursive_tree_walk(std::list<risc::InstanceTree>& occurence,
177  SgSymbol *var_sym);
178 
188  SgVariableSymbol* get_mapped_reference(SgVariableSymbol* reference,
189  SgClassDefinition *base_class_def,
190  SgClassDefinition *parent_class_def,
191  SgVariableDefinition *parent_member);
192 };
193 
194 } // end of namespace risc
195 
196 #endif /* INSTANCE_TREE_H_INCLUDED_ */
197 
198 /* ex: set softtabstop=2 tabstop=2 shiftwidth=2 expandtab: */
bool operator==(const InstanceTree &ohs) const
Definition: instance_tree.cpp:673
Definition: instance_tree.h:15
Definition: instance_tree.h:110
InstanceTree()
Definition: instance_tree.cpp:27
SgVariableSymbol * get_mapped_reference(SgVariableSymbol *reference, SgClassDefinition *base_class_def, SgClassDefinition *parent_class_def, SgVariableDefinition *parent_member)
This function determines the mapped variables symbol in the parent class. Only for internal use...
Definition: instance_tree.cpp:113
int id
Definition: instance_tree.h:25
std::list< Element > Path
Definition: instance_tree.h:36
Definition: instance_tree.h:22
Definition: class.h:53
Definition: object.h:10
void get_instance_tree(SgVariableDefinition *var_def, int instance_id, risc::InstanceTree &tree, VariableType type)
find the instance path to a variable with a given instance id of the hosting module ...
Definition: instance_tree.cpp:694
InstanceTree get_parent()
This function returns the parent variable of variable.
Definition: instance_tree.cpp:298
Definition: instance_tree.h:111
InstanceTree extend_with_symbol_list(std::list< SgVariableSymbol * > syms)
create a copy of current instance tree, extend the copy
Definition: instance_tree.cpp:408
Object * second
Definition: instance_tree.h:24
void print_instance_tree()
Prints the instance tree.
Definition: instance_tree.cpp:261
Element(Class *first_, Object *second_, int id_=0)
Definition: instance_tree.h:27
std::list< InstanceTree > find_all_instances_of(SgSymbol *var_sym)
This function returns all variables.
Definition: instance_tree.cpp:313
Path path_
Definition: instance_tree.h:167
VariableType
These are the kind for of variables for which a traversal can search.
Definition: instance_tree.h:109
Definition: instance_tree.h:114
InstanceTree get_real_mapped_variable()
This function returns mapped variables for a reference. If the mapped variable is a global variable...
Definition: instance_tree.cpp:36
void recursive_tree_walk(SgVariableDefinition *var_def, int &current_id, int instance_id, risc::InstanceTree &tree, bool &found, VariableType type)
For internal usage only!
Definition: instance_tree.cpp:719
Element()
Definition: instance_tree.h:31
Definition: instance_tree.h:115
void get_all_events(std::list< InstanceTree > &occurence)
returns all events
Definition: instance_tree.cpp:607
void get_all_ports(std::list< InstanceTree > &occurence)
returns all ports
Definition: instance_tree.cpp:496
SgVariableSymbol * get_object_symbol()
returns the symbol of the object
Definition: instance_tree.cpp:476
Class * get_scope()
returns the scope of the object
Definition: instance_tree.cpp:464
Object * get_object()
returns the object
Definition: instance_tree.cpp:470
Definition: instance_tree.h:113
void push_back(Element ohs)
Appends element ohs at the end of the list.
Definition: instance_tree.cpp:490
Class * first
Definition: instance_tree.h:23
Element pop_back()
Deletes the last element in the instance tree.
Definition: instance_tree.cpp:482