changes to handle fixed point analysis properly + bug fix.
[IRC.git] / Robust / src / Analysis / MLP / MethodSummary.java
1 package Analysis.MLP;
2
3 import java.util.HashSet;
4 import java.util.Iterator;
5 import java.util.Set;
6
7 public class MethodSummary {
8         
9         public static final Integer VOID=new Integer(0);
10         public static final Integer ACCESSIBLE = new Integer(1);
11         public static final Integer INACCESSIBLE=new Integer(2);
12
13         private int childSESECount;
14         private HashSet<PreEffectsKey> effectsSet;
15         private Integer accessibility;
16         private StallSite returnStallSite;
17         private HashSet<Integer> stallParamIdxSet;
18
19         public MethodSummary() {
20                 effectsSet = new HashSet<PreEffectsKey>();
21                 accessibility = MethodSummary.VOID;
22                 childSESECount = 0;
23                 returnStallSite=null;
24                 stallParamIdxSet=new HashSet<Integer>();
25         }
26         
27         public HashSet<Integer> getStallParamIdxSet(){
28                 return stallParamIdxSet;
29         }
30         
31         public void addStallParamIdxSet(Set<Integer> newSet){
32                 if(newSet!=null){
33                         stallParamIdxSet.addAll(newSet);
34                 }
35         }
36         
37         public void setReturnStallSite(StallSite ss){
38                 returnStallSite=ss;
39         }
40         
41         public StallSite getReturnStallSite(){
42                 return returnStallSite;
43         }
44
45         public void increaseChildSESECount() {
46                 childSESECount++;
47         }
48
49         public int getChildSESECount() {
50                 return childSESECount;
51         }
52
53         public Integer getReturnValueAccessibility() {
54                 return accessibility;
55         }
56
57         public void setReturnValueAccessibility(Integer accessibility) {
58                 this.accessibility = accessibility;
59         }
60
61         public HashSet<PreEffectsKey> getEffectsSet() {
62                 return effectsSet;
63         }
64
65         @Override
66         public String toString() {
67                 return "MethodSummary [accessibility=" + accessibility
68                                 + ", childSESECount=" + childSESECount + ", effectsSet="
69                                 + effectsSet + "]";
70         }
71         
72         public HashSet<PreEffectsKey> getEffectsSetByParamIdx(int paramIdx){
73                 
74                 HashSet<PreEffectsKey> returnSet=new HashSet<PreEffectsKey>();
75
76                 for (Iterator iterator = effectsSet.iterator(); iterator.hasNext();) {
77                         PreEffectsKey preEffectsKey = (PreEffectsKey) iterator.next();
78                         if(preEffectsKey.getParamIndex().equals(new Integer(paramIdx))){
79                                 returnSet.add(preEffectsKey);
80                         }
81                 }
82                 
83                 return returnSet;
84         }
85         
86 }
87
88 class PreEffectsKey {
89
90         public static final Integer READ_EFFECT = new Integer(1);
91         public static final Integer WRITE_EFFECT = new Integer(2);
92
93         private String type;
94         private String field;
95         private Integer effectType;
96         private Integer paramIndex;
97
98         public PreEffectsKey(Integer paramIndex, String field, String type,
99                         Integer effectType) {
100                 this.paramIndex = paramIndex;
101                 this.field = field;
102                 this.type = type;
103                 this.effectType = effectType;
104         }
105
106         public String getType() {
107                 return type;
108         }
109
110         public String getField() {
111                 return field;
112         }
113
114         public Integer getEffectType() {
115                 return effectType;
116         }
117
118         public Integer getParamIndex() {
119                 return paramIndex;
120         }
121
122         public String toString() {
123                 return "PreEffectsKey [effectType=" + effectType + ", field=" + field
124                                 + ", paramIndex=" + paramIndex + ", type=" + type + "]";
125         }
126
127         public boolean equals(Object o) {
128
129                 if (o == null) {
130                         return false;
131                 }
132
133                 if (!(o instanceof PreEffectsKey)) {
134                         return false;
135                 }
136
137                 PreEffectsKey in = (PreEffectsKey) o;
138
139                 this.paramIndex = paramIndex;
140                 this.field = field;
141                 this.type = type;
142                 this.effectType = effectType;
143
144                 if (paramIndex.equals(in.getParamIndex())
145                                 && field.equals(in.getField()) && type.equals(in.getType())
146                                 && effectType.equals(in.getEffectType())) {
147                         return true;
148                 } else {
149                         return false;
150                 }
151
152         }
153
154 }