changes.
[IRC.git] / Robust / src / Analysis / SSJava / MethodLocationInfo.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 import IR.MethodDescriptor;
10
11 public class MethodLocationInfo extends LocationInfo {
12
13   MethodDescriptor md;
14
15   String returnLocName;
16   String thisLocName;
17   String PCLocName;
18
19   Map<Integer, String> mapParamIdxToLocName;
20   Set<String> paramLocNameSet;
21   Map<FlowNode, CompositeLocation> mapFlowNodeToLocation;
22
23   public MethodLocationInfo(MethodDescriptor md) {
24     this.md = md;
25     this.mapParamIdxToLocName = new HashMap<Integer, String>();
26     this.paramLocNameSet = new HashSet<String>();
27     this.PCLocName = SSJavaAnalysis.TOP;
28     this.mapFlowNodeToLocation = new HashMap<FlowNode, CompositeLocation>();
29   }
30
31   public void mapFlowNodeToInferLocation(FlowNode node, CompositeLocation location) {
32     mapFlowNodeToLocation.put(node, location);
33   }
34
35   public CompositeLocation getInferLocation(FlowNode node) {
36     return mapFlowNodeToLocation.get(node);
37   }
38
39   public String getReturnLocName() {
40     return returnLocName;
41   }
42
43   public void setReturnLocName(String returnLocName) {
44     this.returnLocName = returnLocName;
45   }
46
47   public String getThisLocName() {
48     return thisLocName;
49   }
50
51   public void setThisLocName(String thisLocName) {
52     this.thisLocName = thisLocName;
53   }
54
55   public String getPCLocName() {
56     return PCLocName;
57   }
58
59   public void setPCLocName(String pCLocName) {
60     PCLocName = pCLocName;
61   }
62
63   public void addParameter(String name, Descriptor desc, int idx) {
64     mapParamIdxToLocName.put(new Integer(idx), name);
65     addMappingOfLocNameToDescriptor(name, desc);
66   }
67
68   public Set<String> getParameterLocNameSet() {
69     Set<String> paramSet = new HashSet<String>();
70
71     paramSet.add(PCLocName);
72
73     if (thisLocName != null) {
74       paramSet.add(thisLocName);
75     }
76
77     if (returnLocName != null) {
78       paramSet.add(returnLocName);
79     }
80
81     paramSet.addAll(mapParamIdxToLocName.values());
82
83     return paramSet;
84   }
85
86 }