ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
annvariable.h
Go to the documentation of this file.
1 
2 #ifndef BDWY_LOCALVARIABLE_H
3 #define BDWY_LOCALVARIABLE_H
4 
5 #include <map>
6 #include <list>
7 #include <set>
8 #include <string>
9 #include <iostream>
10 
11 typedef std::map< std::string , annVariable * > var_map;
12 typedef var_map::iterator var_map_p;
13 typedef var_map::const_iterator var_map_cp;
14 
15 typedef std::list< annVariable * > var_list;
16 typedef var_list::iterator var_list_p;
17 typedef var_list::const_iterator var_list_cp;
18 
19 typedef std::set< annVariable * > var_set;
20 typedef var_set::iterator var_set_p;
21 typedef var_set::const_iterator var_set_cp;
22 
23 #ifdef PROCLOCATION
24 typedef std::map< procLocation *, pointerValue > variable_binding_map;
25 typedef variable_binding_map::iterator variable_binding_map_p;
26 #endif
27 
35 {
36 private:
37 
40  std::string _name;
41 
52  // TB pointerValue _bindings;
53 
58 #ifdef PROCLOCATION
59  variable_binding_map _bindings /* TB _all_bindings */ ;
60 #endif
61 
64 #ifdef DECLNODE
65  declNode * _decl;
66 #endif
67 
71 
72  bool _is_new;
73  bool _is_used;
75  bool _is_global;
77  bool _is_formal;
78  bool _is_io;
81 
83 
84 public:
85 
92  annVariable(std::string name,
93  std::string procedure_name,
94  bool is_new,
95  bool is_global,
96  bool is_external,
97  bool is_formal,
98  bool is_io);
99 
106  ~annVariable();
107 
112 #ifdef PROCLOCATION
113  void clear(procLocation *where);
114  void clear_all() { _bindings.clear(); }
115 #endif
116 
117  // Fields access
118 
119  std::string & name() { return _name; }
120 
121 #ifdef DECLNODE
122  inline declNode * decl() const { return _decl; }
123 #endif
124  inline bool is_new() const { return _is_new; }
125  inline bool is_used() const { return _is_used; }
126  inline bool is_defined() const { return _is_defined; }
127  inline bool is_global() const { return _is_global; }
128  inline bool is_external() const { return _is_external; }
129  inline bool is_formal() const { return _is_formal; }
130  inline bool is_io() const { return _is_io; }
131  inline bool is_deleted() const { return _is_deleted; }
132  inline bool is_property_variable() const { return _is_property_variable; }
133 
134  inline void set_used() { _is_used = true; }
135  inline void set_defined() { _is_defined = true; }
136  inline void set_global()
137  {
138  _is_global = true;
139 #ifdef DECLNODE
140  _decl->decl_location(declNode::TOP);
141 #endif
142  }
143 
144  inline void set_external() { _is_external = true; }
145 
146  inline void set_formal()
147  {
148  _is_formal = true;
149 #ifdef DECLNODE
150  _decl->decl_location(declNode::FORMAL);
151 #endif
152  }
153 
154  inline void set_io() { _is_io = true; }
155  inline void set_deleted() { _is_deleted = true; }
157 
164  // TB add argument <where>
165 #ifdef PROCLOCATION
166  pointerValue & get_binding(procLocation *where);
167 #endif
168 
175 #ifdef PROCLOCATION
176  pointerValue & fresh_binding(procLocation *where)
177  {
178  clear(where);
179  return get_binding(where);
180  }
181 
187  void set_binding(memoryBlock * block, procLocation *where)
188  {
189  // clear();
190  _bindings[where].blocks.clear();
191  _bindings[where].blocks.insert(block);
192  }
193 
196  //TB void save_bindings(procLocation * where) { _all_bindings[where] = _bindings; }
197 #endif
198 
203  // void create_binding(memoryBlock * mb) {
204 
209  // bool has_binding(procLocation * loc = 0);
210 
211  // --- Output
212 
213  friend std::ostream& operator<<(std::ostream & o, const annVariable & var) {
214  var.print(o);
215  return o;
216  }
217 
218  void print(std::ostream & o) const;
219 };
220 
221 #endif /* */