Patch in effects analysis hooks....have to add new accessor methods...add interface...
[IRC.git] / Robust / src / Analysis / Disjoint / Effect.java
1 package Analysis.Disjoint;
2
3 import IR.FieldDescriptor;
4 import IR.Flat.TempDescriptor;
5
6 public class Effect {
7
8   // operation type
9   public static final int read = 1;
10   public static final int write = 2;
11   public static final int strongupdate = 3;
12
13   // identify an allocation site of affected object
14   protected Alloc affectedAllocSite;
15
16   // identify operation type
17   protected int type;
18
19   // identify a field
20   protected FieldDescriptor field;
21
22   public Effect(Alloc affectedAS, int type, FieldDescriptor field) {
23     this.affectedAllocSite = affectedAS;
24     this.type = type;
25     this.field = field;
26   }
27
28   public Alloc getAffectedAllocSite() {
29     return affectedAllocSite;
30   }
31
32   public void setAffectedAllocSite(Alloc affectedAllocSite) {
33     this.affectedAllocSite = affectedAllocSite;
34   }
35
36   public int getType() {
37     return type;
38   }
39
40   public void setType(int type) {
41     this.type = type;
42   }
43
44   public FieldDescriptor getField() {
45     return field;
46   }
47
48   public void setField(FieldDescriptor field) {
49     this.field = field;
50   }
51
52   public boolean equals(Object o) {
53
54     if (o == null) {
55       return false;
56     }
57
58     if (!(o instanceof Effect)) {
59       return false;
60     }
61
62     Effect in = (Effect) o;
63     
64     if (affectedAllocSite.equals(in.getAffectedAllocSite()) 
65         && type == in.getType() 
66         && field.equals(in.getField())) {
67       return true;
68     } else {
69       return false;
70     }
71   }
72
73   public int hashCode() {
74
75     int hash = affectedAllocSite.hashCode();
76
77     hash = hash + type;
78
79     if (field != null) {
80       hash = hash ^ field.hashCode();
81     }
82
83     return hash;
84
85   }
86
87   public String toString() {
88     String s = "(";
89
90     s += affectedAllocSite.toStringBrief();
91     s += ", ";
92     if (type == read) {
93       s += "read";
94     } else if (type == write) {
95       s += "write";
96     } else {
97       s += "SU";
98     }
99
100     s += ", " + field.toStringBrief();
101
102     return s + ")";
103   }
104
105 }