changes.
[IRC.git] / Robust / src / Analysis / SSJava / LocationInfo.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.ClassDescriptor;
9 import IR.Descriptor;
10 import IR.MethodDescriptor;
11
12 public class LocationInfo {
13
14   Map<String, Set<Descriptor>> mapLocNameToDescSet;
15   Map<String, String> mapDescSymbolToLocName;
16   Map<Descriptor, CompositeLocation> mapDescToInferCompositeLocation;
17   MethodDescriptor md;
18   ClassDescriptor cd;
19
20   public LocationInfo() {
21     mapDescSymbolToLocName = new HashMap<String, String>();
22     mapLocNameToDescSet = new HashMap<String, Set<Descriptor>>();
23     mapDescToInferCompositeLocation = new HashMap<Descriptor, CompositeLocation>();
24   }
25
26   public LocationInfo(ClassDescriptor cd) {
27     this.cd = cd;
28     this.mapDescSymbolToLocName = new HashMap<String, String>();
29   }
30
31   public void mapDescriptorToCompositeLocation(Descriptor desc, CompositeLocation inferLoc) {
32     mapDescToInferCompositeLocation.put(desc, inferLoc);
33   }
34
35   public void mapDescSymbolToLocName(String descSymbol, String locName) {
36     mapDescSymbolToLocName.put(descSymbol, locName);
37   }
38
39   public String getLocName(String descSymbol) {
40     if (!mapDescSymbolToLocName.containsKey(descSymbol)) {
41       mapDescSymbolToLocName.put(descSymbol, descSymbol);
42     }
43     return mapDescSymbolToLocName.get(descSymbol);
44   }
45
46   public void addMappingOfLocNameToDescriptor(String locName, Descriptor desc) {
47
48     // System.out.println("### MAP LocName=" + locName + " to " + desc);
49
50     if (!mapLocNameToDescSet.containsKey(locName)) {
51       mapLocNameToDescSet.put(locName, new HashSet<Descriptor>());
52     }
53
54     mapLocNameToDescSet.get(locName).add(desc);
55
56   }
57
58   public Set<Descriptor> getFlowNodeSet(String locName) {
59
60     if (!mapLocNameToDescSet.containsKey(locName)) {
61       mapLocNameToDescSet.put(locName, new HashSet<Descriptor>());
62     }
63
64     return mapLocNameToDescSet.get(locName);
65   }
66
67 }