ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
procedure.h
Go to the documentation of this file.
1 
2 #ifndef BDWY_PROCEDURE_H
3 #define BDWY_PROCEDURE_H
4 
5 // ----------------------------------------------------------------------
6 // Procedure Annotation
7 // ----------------------------------------------------------------------
8 
9 #ifdef __PROCLOCATION
10 typedef std::set< procLocation * > proclocation_set;
11 typedef proclocation_set::iterator proclocation_set_p;
12 typedef proclocation_set::const_iterator proclocation_set_cp;
13 #endif
14 
15 #ifdef _CALLSITEENTRY
16 class callsiteEntry
17 {
18 private:
19 
22  threeAddrNode * _stmt;
23 
26  operandNode * _call;
27 
32 #ifdef __PROCLOCATION
33  proclocation_set _contexts;
34 #endif
35 
36 public:
37 
40  callsiteEntry(threeAddrNode * stmt, operandNode * call)
41  : _stmt(stmt),
42  _call(call),
43  _contexts()
44  {}
45 
46  inline threeAddrNode * stmt() const { return _stmt; }
47  inline operandNode * call() const { return _call; }
48 
49 #ifdef __PROCLOCATION
50  inline proclocation_set & contexts() { return _contexts; }
51 #endif
52 };
53 
54 typedef std::map< threeAddrNode *, callsiteEntry * > callsite_map;
55 typedef callsite_map::iterator callsite_map_p;
56 typedef callsite_map::const_iterator callsite_map_cp;
57 
58 #endif /* _CALLSITEENTRY */
59 
60 typedef std::set< enumPropertyAnn * > enum_property_set;
61 typedef enum_property_set::iterator enum_property_set_p;
62 typedef enum_property_set::const_iterator enum_property_set_cp;
63 
64 typedef std::map< annVariable *, enum_property_set > variable_property_map;
65 typedef variable_property_map::iterator variable_property_map_p;
66 typedef variable_property_map::const_iterator variable_property_map_cp;
67 
68 
73 class procedureAnn : public Ann
74 {
75 public:
76 
78 
79 private:
80 
83  std::string _name;
84 
92 
98 
104 
110 
116 
122 
129 
136 
143 
148 
151 
153 
161 
167 
172 
177 
181 #ifdef __ACTIONS
182  TREE action_list _actions;
183 #endif
184 
190 #ifdef __PROCNODE
191  TREE procNode * _proc;
192 #endif
193 
202 
209 
216 #ifdef __CALLSITE_MAP
217  TREE callsite_map _callsites;
218 #endif
219 
225 
231 
233 
234 public:
235 
247  procedureAnn(parserID * name, parserid_list * params, Annotations * anns,
248  const int line);
249 
256  ~procedureAnn();
257 
262 
263  inline const std::string & name() const { return _name; }
264 
265  inline const var_map & variables() const { return _variables; }
266 
267  inline const var_set & uses() const { return _uses; }
268  inline const var_set & defs() const { return _defs; }
269 
270  inline const var_list & formal_params() const { return _formal_params; }
271 
272  inline const structure_list & on_entry() const { return _on_entry; }
273  inline const structure_list & on_exit() const { return _on_exit; }
274 
275  inline const pointerrule_list & pointer_rules() const { return _pointer_rules; }
277 
278  inline const analyze_map & analyses() const { return _analyses; }
279 
280  inline const report_list & reports() const { return _reports; }
281 
282 #ifdef __ACTIONS
283  inline const action_list & actions() const { return _actions; }
284 #endif
285 
286 #ifdef __PROCNODE
287  inline procNode * proc() const { return _proc; }
288 #endif
290 
291 #ifdef __CALLSITE_MAP
292  inline const callsite_map & callsites() const { return _callsites; }
293 #endif
294 
295  inline bool pure_function() const { return _pure_function; }
296  inline bool allocates_memory() const { return _allocates_memory; }
297  inline bool deallocates_memory() const { return _deallocates_memory; }
298  inline bool modifies_globals() const { return _modifies_globals; }
299  inline bool accesses_io() const { return _accesses_io; }
300 
302 
316  annVariable * lookup(const std::string & variable, bool create, bool is_new = false);
317 
318  // --- Manage uses and defs -----------------------
319 
329 
335  void add_one_def(annVariable * var);
336 
346 
352  void add_one_use(annVariable * var);
353 
360 #ifdef __PROCLOCATION
361  stmtLocation * def_use_location(procLocation * procloc);
362 #endif
363 
372 #ifdef __PROCLOCATION
373  stmtLocation * dealloc_location(procLocation * procloc);
374 #endif
375 
384 #ifdef __PROCLOCATION
385  stmtLocation * alloc_location(procLocation * procloc);
386 #endif
387 
388 
389  // --- Manage property uses and defs -----------------------
390 
396  void add_property_use(annVariable * var, enumPropertyAnn * enum_property);
397 
402  inline const variable_property_map & property_uses() const { return _property_uses; }
403 
409  void add_property_def(annVariable * var, enumPropertyAnn * enum_property);
410 
415  inline const variable_property_map & property_defs() const { return _property_defs; }
416 
422  void add_property_weak_def(annVariable * var, enumPropertyAnn * enum_property);
423 
429 
430  // ---------------------------------------
431 
438  void add_delete(parserID * id);
439 
447  void postprocess();
448 
460  void add_on_entry(structuretree_list * structures);
461 
473  void add_on_exit(structuretree_list * structures);
474 
481  void add_on_exit(pointerRuleAnn * pointer_rule);
482 
493  void add_global_structures(Annotations * annotations,
494  annVariable * parent_var,
495  structureTreeAnn * parent_node);
496 
501  void add_analysis(analyzeAnn * new_analysis);
502 
507 #ifdef __PROCLOCATION
508  void add_calling_context(operandNode * call, procLocation * where);
509 #endif
510 
513  void add_report(reportAnn * report);
514 
516  void add_action(actionAnn * action);
517 
522 #ifdef __CALLSITE_MAP
523  callsiteEntry * find_callsite(threeAddrNode * stmt);
524 #endif
525 
530  void process_reports(Analyzer * analyzer);
531 
537  void test_actions(Analyzer * analyzer);
538 
546 #ifdef __CALLSITE_MAP
547  actionAnn * find_applicable_action(threeAddrNode * stmt);
548 #endif
549 
553  void clear();
554 
555  // --- Output
556 
557  friend std::ostream& operator<<(std::ostream & o, const procedureAnn & pa) {
558  pa.print(o);
559  return o;
560  }
561 
562  void print(std::ostream & o) const;
563 
564 private:
565 
566  void add_structures(bool is_on_entry,
567  structure_list & the_list,
568  annVariable * parent_var,
569  structureTreeAnn * parent_node);
570 
580 
584 
586 
587  void postprocess_variables(parserid_list & uses_or_defs,
588  bool is_defs);
589 };
590 
591 #endif /* */