1 package Analysis.Disjoint;
3 import Analysis.OwnershipAnalysis.EffectsKey;
4 import IR.FieldDescriptor;
5 import IR.Flat.TempDescriptor;
10 public static final int read = 1;
11 public static final int write = 2;
12 public static final int strongupdate = 3;
14 // identify a parameter index
15 protected Integer paramIndex;
17 // identify an inset var
18 protected TempDescriptor insetVar;
20 // identify an allocation site of inset var
21 protected AllocSite insetAllocSite;
23 // identify an allocation site of affected object
24 protected AllocSite affectedAllocSite;
26 // identify operation type
30 protected FieldDescriptor field;
32 public Effect(Integer pi, AllocSite insetAS, AllocSite affectedAS, int type, FieldDescriptor field) {
34 this.insetAllocSite = insetAS;
35 this.affectedAllocSite = affectedAS;
40 public Integer getParamIndex() {
44 public void setParamIndex(Integer paramIndex) {
45 this.paramIndex = paramIndex;
48 public TempDescriptor getInsetVar() {
52 public void setInsetVar(TempDescriptor insetVar) {
53 this.insetVar = insetVar;
56 public AllocSite getInsetAllocSite() {
57 return insetAllocSite;
60 public void setInsetAllocSite(AllocSite insetAllocSite) {
61 this.insetAllocSite = insetAllocSite;
64 public AllocSite getAffectedAllocSite() {
65 return affectedAllocSite;
68 public void setAffectedAllocSite(AllocSite affectedAllocSite) {
69 this.affectedAllocSite = affectedAllocSite;
72 public int getType() {
76 public void setType(int type) {
80 public FieldDescriptor getField() {
84 public void setField(FieldDescriptor field) {
88 public boolean equals(Object o) {
94 if (!(o instanceof Effect)) {
98 Effect in = (Effect) o;
100 if (paramIndex != null) {
101 if (!paramIndex.equals(in.getParamIndex())) {
105 if (!insetVar.equals(in.getInsetVar())
106 && !insetAllocSite.equals(in.getInsetAllocSite())) {
111 if (affectedAllocSite.equals(in.getAffectedAllocSite())
112 && type == in.getType()
113 && field.equals(in.getField())) {
120 public int hashCode() {
122 int hash = affectedAllocSite.hashCode();
124 if (paramIndex != null) {
125 hash = hash ^ paramIndex.hashCode();
126 } else if (insetAllocSite != null) {
127 hash = hash ^ insetAllocSite.hashCode();
133 hash = hash ^ field.hashCode();
140 public String toString() {
143 if (paramIndex != null) {
144 s += "param" + paramIndex;
147 s += ", " + insetAllocSite.toStringBrief();
150 s += ", " + affectedAllocSite.toStringBrief();
154 } else if (type == write) {
160 s += ", " + field.toStringBrief();