00001 #ifndef INSTANCE_TREE_H_INCLUDED_
00002 #define INSTANCE_TREE_H_INCLUDED_
00003
00004 #include "rose.h"
00005
00006 #include <vector>
00007 #include <list>
00008 #include <utility>
00009
00010 namespace risc {
00011
00012 class Class;
00013 class Object;
00014
00015 class InstanceTree {
00016
00017 public:
00018 InstanceTree();
00019
00020 InstanceTree(const InstanceTree &other);
00021
00022 struct Element {
00023 Class* first;
00024 Object* second;
00025 int id;
00026
00027 Element(Class* first_, Object* second_, int id_ = 0):
00028 first(first_), second(second_), id(id_)
00029 { }
00030
00031 Element():
00032 first(NULL), second(NULL), id(0)
00033 { }
00034 };
00035
00036 typedef std::list<Element> Path;
00037
00044 InstanceTree get_real_mapped_variable();
00045
00050 std::list<InstanceTree> find_all_instances_of(SgVariableDefinition *var_def);
00051
00056 InstanceTree get_parent();
00057
00062 void print_instance_tree();
00063
00068 Class* get_scope();
00069
00074 Object* get_object();
00075
00080 SgVariableSymbol* get_object_symbol();
00081
00086 void get_all_ports(std::list<InstanceTree>& occurence);
00087
00092 void get_all_events(std::list<InstanceTree>& occurence);
00093
00098 Element pop_back();
00099
00104 void push_back(Element ohs);
00105
00109 enum VariableType {
00110 ModuleInstance,
00111 PrimitiveChannelInstance,
00112 HierarchicalChannelInstance,
00113 EventInstance,
00114 VariableInstance,
00115 PortInstance
00116 };
00117
00129 void
00130 get_instance_tree(
00131 SgVariableDefinition *var_def,
00132 int instance_id,
00133 risc::InstanceTree &tree,
00134 VariableType type);
00135
00140 void
00141 recursive_tree_walk(
00142 SgVariableDefinition *var_def,
00143 int ¤t_id,
00144 int instance_id,
00145 risc::InstanceTree &tree,
00146 bool &found,
00147 VariableType type);
00148
00149 bool operator==(const InstanceTree &ohs);
00150
00151 Path path_;
00152
00153 private:
00159 void recursive_tree_walk(std::list<InstanceTree>& occurence,
00160 SgVariableDefinition *var_def);
00161
00168 SgVariableSymbol* get_mapped_reference(SgVariableSymbol* reference,
00169 SgClassDefinition *base_class_def,
00170 SgClassDefinition *parent_class_def,
00171 SgVariableDefinition *parent_member);
00172 };
00173
00174 }
00175
00176 #endif
00177
00178