1 package Analysis.SSJava;
3 import java.util.HashMap;
4 import java.util.HashSet;
10 public class InferGraph {
12 Set<InferNode> nodeSet;
14 // having one location for the top location
15 private static final int topLocationID = 1;
18 private static int uniqueID = 10000;
20 // maps descriptors (field and local var descriptors) to its unique integer id
21 Map<Descriptor, Integer> mapDescriptorToUniqueID;
23 // maps field/var descriptros to infer nodes
24 Map<Descriptor, InferNode> mapDescToInferNode;
29 nodeSet = new HashSet<InferNode>();
30 mapDescToInferNode = new HashMap<Descriptor, InferNode>();
31 mapDescriptorToUniqueID = new HashMap<Descriptor, Integer>();
34 public void addValueFlowEdge(Descriptor fromDesc, Descriptor toDesc) {
38 public InferNode getInferNode(Descriptor desc) {
39 if (mapDescToInferNode.containsKey(desc)) {
45 public void assignTopLocationToDescriptor(Descriptor desc) {
46 mapDescriptorToUniqueID.put(desc, Integer.valueOf((topLocationID)));
47 debug_uniqueid_print(desc);
50 public void assignUniqueIDtoDescriptor(Descriptor desc) {
51 mapDescriptorToUniqueID.put(desc, getUniqueID());
52 debug_uniqueid_print(desc);
55 private int getUniqueID() {
59 private void debug_uniqueid_print(Descriptor d) {
61 int id = mapDescriptorToUniqueID.get(d).intValue();
62 System.out.print(d + " -> ");
63 if (id == topLocationID) {
64 System.out.println("TOP");
66 System.out.println(id);