09adf72d36b43d7a4f7d8dc3d54cd9be37d7efcf
[IRC.git] / Robust / src / Analysis / Pointer / Graph.java
1 package Analysis.Pointer;
2 import java.util.*;
3 import Analysis.Disjoint.PointerMethod;
4 import Analysis.Pointer.AllocFactory.AllocNode;
5 import IR.Flat.*;
6
7 public class Graph {
8   /* This is field is set is this Graph is just a delta on the parent
9    * graph. */
10
11   Graph parent;
12   HashMap<AllocNode, MySet<Edge>> nodeMap;
13   HashMap<TempDescriptor, MySet<Edge>> varMap;
14   HashMap<AllocNode, MySet<Edge>> backMap;
15   MySet<Edge> strongUpdateSet;
16   MySet<Edge> reachEdge;
17   HashSet<AllocNode> reachNode;
18
19   /* Need this information for mapping in callee results */
20   HashSet<AllocNode> nodeAges;
21
22   public Graph(Graph parent) {
23     nodeMap=new HashMap<AllocNode, MySet<Edge>>();
24     backMap=new HashMap<AllocNode, MySet<Edge>>();
25     varMap=new HashMap<TempDescriptor, MySet<Edge>>();
26     nodeAges=new HashSet<AllocNode>();
27     this.parent=parent;
28   }
29
30   public boolean containsNode(AllocNode node) {
31     return nodeAges.contains(node)||parent!=null&&parent.nodeAges.contains(node);
32   }
33
34   public MySet<Edge> getEdges(TempDescriptor tmp) {
35     if (varMap.containsKey(tmp))
36       return varMap.get(tmp);
37     else if (parent!=null&&parent.varMap.containsKey(tmp))
38       return parent.varMap.get(tmp);
39     else return emptySet;
40   }
41
42   public MySet<Edge> getEdges(AllocNode node) {
43     if (nodeMap.containsKey(node))
44       return nodeMap.get(node);
45     else if (parent!=null&&parent.nodeMap.containsKey(node))
46       return parent.nodeMap.get(node);
47     else return emptySet;
48   }
49
50   public static MySet<Edge> emptySet=new MySet<Edge>();
51 }