get set up part of the stall site analysis
[IRC.git] / Robust / src / Analysis / Disjoint / Effect.java
1 package Analysis.Disjoint;
2
3 import Analysis.OwnershipAnalysis.EffectsKey;
4 import IR.FieldDescriptor;
5 import IR.Flat.TempDescriptor;
6
7 public class Effect {
8
9   // operation type
10   public static final int read = 1;
11   public static final int write = 2;
12   public static final int strongupdate = 3;
13
14   // identify a parameter index
15   protected Integer paramIndex;
16
17   // identify an inset var
18   protected TempDescriptor insetVar;
19
20   // identify an allocation site of inset var
21   protected AllocSite insetAllocSite;
22
23   // identify an allocation site of affected object
24   protected AllocSite affectedAllocSite;
25
26   // identify operation type
27   protected int type;
28
29   // identify a field
30   protected FieldDescriptor field;
31
32   public Effect(Integer pi, AllocSite insetAS, AllocSite affectedAS, int type, FieldDescriptor field) {
33     this.paramIndex = pi;
34     this.insetAllocSite = insetAS;
35     this.affectedAllocSite = affectedAS;
36     this.type = type;
37     this.field = field;
38   }
39
40   public Integer getParamIndex() {
41     return paramIndex;
42   }
43
44   public void setParamIndex(Integer paramIndex) {
45     this.paramIndex = paramIndex;
46   }
47
48   public TempDescriptor getInsetVar() {
49     return insetVar;
50   }
51
52   public void setInsetVar(TempDescriptor insetVar) {
53     this.insetVar = insetVar;
54   }
55
56   public AllocSite getInsetAllocSite() {
57     return insetAllocSite;
58   }
59
60   public void setInsetAllocSite(AllocSite insetAllocSite) {
61     this.insetAllocSite = insetAllocSite;
62   }
63
64   public AllocSite getAffectedAllocSite() {
65     return affectedAllocSite;
66   }
67
68   public void setAffectedAllocSite(AllocSite affectedAllocSite) {
69     this.affectedAllocSite = affectedAllocSite;
70   }
71
72   public int getType() {
73     return type;
74   }
75
76   public void setType(int type) {
77     this.type = type;
78   }
79
80   public FieldDescriptor getField() {
81     return field;
82   }
83
84   public void setField(FieldDescriptor field) {
85     this.field = field;
86   }
87
88   public boolean equals(Object o) {
89
90     if (o == null) {
91       return false;
92     }
93
94     if (!(o instanceof Effect)) {
95       return false;
96     }
97
98     Effect in = (Effect) o;
99
100     if (paramIndex != null) {
101       if (!paramIndex.equals(in.getParamIndex())) {
102         return false;
103       }
104     } else {
105       if (!insetVar.equals(in.getInsetVar()) 
106           && !insetAllocSite.equals(in.getInsetAllocSite())) {
107         return false;
108       }
109     }
110
111     if (affectedAllocSite.equals(in.getAffectedAllocSite()) 
112         && type == in.getType() 
113         && field.equals(in.getField())) {
114       return true;
115     } else {
116       return false;
117     }
118   }
119
120   public int hashCode() {
121
122     int hash = affectedAllocSite.hashCode();
123
124     if (paramIndex != null) {
125       hash = hash ^ paramIndex.hashCode();
126     } else if (insetAllocSite != null) {
127       hash = hash ^ insetAllocSite.hashCode();
128     }
129
130     hash = hash + type;
131
132     if (field != null) {
133       hash = hash ^ field.hashCode();
134     }
135
136     return hash;
137
138   }
139
140   public String toString() {
141     String s = "(";
142
143     if (paramIndex != null) {
144       s += "param" + paramIndex;
145     } else {
146       s += insetVar;
147       s += ", " + insetAllocSite.toStringBrief();
148     }
149
150     s += ", " + affectedAllocSite.toStringBrief();
151     s += ", ";
152     if (type == read) {
153       s += "read";
154     } else if (type == write) {
155       s += "write";
156     } else {
157       s += "SU";
158     }
159
160     s += ", " + field.toStringBrief();
161
162     return s + ")";
163   }
164
165 }