ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DefUseChain.h
Go to the documentation of this file.
1 #ifndef DEF_USE_CHAIN_H
2 #define DEF_USE_CHAIN_H
3 
4 #include "ReachingDefinition.h"
5 #include "StmtInfoCollect.h"
6 
7 class ROSE_DLL_API DefUseChainNode : public MultiGraphElem
8 {
9  bool isdef;
10  AstNodePtr ref, stmt;
11  public:
12  DefUseChainNode( MultiGraphCreate* c, const AstNodePtr& _ref,
13  const AstNodePtr& _stmt, bool def)
14  : MultiGraphElem(c), isdef(def), ref(_ref), stmt(_stmt) {}
15  bool is_definition() const { return isdef; }
16  AstNodePtr get_ref() const { return ref; }
17  AstNodePtr get_stmt() const { return stmt; }
18  void Dump() const;
19  std::string toString() const;
20 };
21 
22 
23 template <class Node>
25  : public VirtualGraphCreateTemplate<Node, MultiGraphElem>
26 {
27  public:
28  typedef MultiGraphElem Edge;
29  typedef typename VirtualGraphCreateTemplate<Node, Edge>::NodeIterator NodeIterator;
30  typedef typename VirtualGraphCreateTemplate<Node, Edge>::EdgeIterator EdgeIterator;
31 
32  DefUseChain( BaseGraphCreate* c)
33  : VirtualGraphCreateTemplate<Node, Edge>(c) {}
34 
35  virtual Node* CreateNode( AstInterface& fa, const AstNodePtr& ref,
36  const AstNodePtr& stmt, bool def)
37  {
38  Node* n = new Node(this, ref, stmt, def);
39  VirtualGraphCreateTemplate<Node, Edge>::AddNode(n);
40 
41  return n;
42  }
43  Edge* CreateEdge( Node* n1, Node* n2)
44  {
45  Edge* e = new Edge(this);
46  this->AddEdge( n1, n2, e);
47  return e;
48  }
49 
50  void build( AstInterface& fa,
52  AliasAnalysisInterface& alias,
53  FunctionSideEffectInterface* f = 0);
54  void build(AstInterface& fa, AstNodePtr root,
55  AliasAnalysisInterface* alias = 0,
56  FunctionSideEffectInterface* f = 0);
57 };
58 
59 template<class Node>
61  public:
62  virtual void init(CollectObject<Node*>& newnodes ) = 0;
63  virtual bool update_def_node( Node* def, const Node* use,
64  CollectObject<Node*>& newnodes) = 0;
65  virtual bool update_use_node( Node* use, const Node* def,
66  CollectObject<Node*>& newnodes) = 0;
67 
69 };
70 
71 class DefaultDUchain : public DefUseChain<DefUseChainNode>
72 {
73  public:
74  DefaultDUchain( BaseGraphCreate* c = 0)
76 };
77 
78 template<class Node>
81 
82 #define TEMPLATE_ONLY
83 #include <DefUseChain.C>
84 #undef TEMPLATE_ONLY
85 
86 #endif
87