change the debug mode for capturing null dereference to a global compilar option
[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 = 4;
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 static boolean isWrite(int effect) {
29     return (effect & Effect.write)==Effect.write;
30   }
31
32   public boolean isWrite() {
33     return type==write;
34   }
35
36   public boolean isRead() {
37     return type==read;
38   }
39
40   public Alloc getAffectedAllocSite() {
41     return affectedAllocSite;
42   }
43
44   public void setAffectedAllocSite(Alloc affectedAllocSite) {
45     this.affectedAllocSite = affectedAllocSite;
46   }
47
48   public int getType() {
49     return type;
50   }
51
52   public void setType(int type) {
53     this.type = type;
54   }
55
56   public FieldDescriptor getField() {
57     return field;
58   }
59
60   public void setField(FieldDescriptor field) {
61     this.field = field;
62   }
63
64   public boolean equals(Object o) {
65
66     if (o == null) {
67       return false;
68     }
69
70     if (!(o instanceof Effect)) {
71       return false;
72     }
73
74     Effect in = (Effect) o;
75
76     if (affectedAllocSite.equals(in.getAffectedAllocSite())
77         && type == in.getType()
78         && ((field!=null&&field.equals(in.getField()))||
79             (field==null&&in.getField()==null))) {
80       return true;
81     } else {
82       return false;
83     }
84   }
85
86   public int hashCode() {
87
88     int hash = affectedAllocSite.hashCode();
89
90     hash = hash + type;
91
92     if (field != null) {
93       hash = hash ^ field.hashCode();
94     }
95
96     return hash;
97
98   }
99
100   public String toString() {
101     String s = "(";
102
103     s += affectedAllocSite.toStringBrief();
104     s += ", ";
105     if (type == read) {
106       s += "read";
107     } else if (type == write) {
108       s += "write";
109     } else {
110       s += "SU";
111     }
112
113     if (field==null) {
114       s += ", []";
115     } else {
116       s += ", " + field.toStringBrief();
117     }
118     return s + ")";
119   }
120
121 }