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