changes on inference
[IRC.git] / Robust / src / Analysis / SSJava / InferGraph.java
1 package Analysis.SSJava;
2
3 import java.util.HashMap;
4 import java.util.HashSet;
5 import java.util.Map;
6 import java.util.Set;
7
8 import IR.Descriptor;
9
10 public class InferGraph {
11
12   Set<InferNode> nodeSet;
13
14   // having one location for the top location
15   private static final int topLocationID = 1;
16
17   // unique ID seed
18   private static int uniqueID = 10000;
19
20   // maps descriptors (field and local var descriptors) to its unique integer id
21   Map<Descriptor, Integer> mapDescriptorToUniqueID;
22
23   // maps field/var descriptros to infer nodes
24   Map<Descriptor, InferNode> mapDescToInferNode;
25
26   boolean debug = true;
27
28   public InferGraph() {
29     nodeSet = new HashSet<InferNode>();
30     mapDescToInferNode = new HashMap<Descriptor, InferNode>();
31     mapDescriptorToUniqueID = new HashMap<Descriptor, Integer>();
32   }
33
34   public void addValueFlowEdge(Descriptor fromDesc, Descriptor toDesc) {
35
36   }
37
38   public InferNode getInferNode(Descriptor desc) {
39     if (mapDescToInferNode.containsKey(desc)) {
40
41     }
42     return null;
43   }
44
45   public void assignTopLocationToDescriptor(Descriptor desc) {
46     mapDescriptorToUniqueID.put(desc, Integer.valueOf((topLocationID)));
47     debug_uniqueid_print(desc);
48   }
49
50   public void assignUniqueIDtoDescriptor(Descriptor desc) {
51     mapDescriptorToUniqueID.put(desc, getUniqueID());
52     debug_uniqueid_print(desc);
53   }
54
55   private int getUniqueID() {
56     return uniqueID++;
57   }
58
59   private void debug_uniqueid_print(Descriptor d) {
60     if (debug) {
61       int id = mapDescriptorToUniqueID.get(d).intValue();
62       System.out.print(d + " -> ");
63       if (id == topLocationID) {
64         System.out.println("TOP");
65       } else {
66         System.out.println(id);
67       }
68
69     }
70   }
71 }