check in locality analysis
[IRC.git] / Robust / src / Analysis / Locality / LocalityBinding.java
1 package Analysis.Locality;
2 import IR.MethodDescriptor;
3
4 public class LocalityBinding {
5     private MethodDescriptor md;
6     private Integer[] isglobal;
7     private boolean istransaction;
8     private Integer isglobalreturn;
9     private Integer isglobalthis;
10
11     public LocalityBinding(MethodDescriptor md, boolean transaction) {
12         this.md=md;
13         isglobal=new boolean[md.numParameters()];
14         istransaction=transaction;
15     }
16
17     public String toString() {
18         String st=md.toString()+" ";
19         for(int i=0;i<isglobal.length;i++)
20             if (isglobal[i])
21                 st+="global ";
22             else
23                 st+="local ";
24         return st;
25     }
26
27     public void setGlobal(int i, Integer global) {
28         isglobal[i]=global;
29     }
30
31     public Integer isGlobal(int i) {
32         return isglobal[i];
33     }
34
35     public void setGlobalReturn(Integer global) {
36         isglobalreturn=global;
37     }
38
39     public Integer getGlobalReturn() {
40         return isglobalreturn;
41     }
42
43     public void setGlobalThis(Integer global) {
44         isglobalthis=global;
45     }
46
47     public Integer getGlobalThis() {
48         return isglobalthis;
49     }
50
51     public MethodDescriptor getMethod() {
52         return md;
53     }
54
55     public boolean isTransaction() {
56         return istransaction;
57     }
58
59     public boolean equals(Object o) {
60         if (o instanceof LocalityBinding) {
61             LocalityBinding lb=(LocalityBinding)o;
62             if (md!=lb.md)
63                 return false;
64             for(int i=0;i<isglobal.length;i++)
65                 if (!isglobal[i].equals(lb.isglobal[i]))
66                     return false;
67             if (!isglobalthis.equals(lb.isglobalthis))
68                 return false;
69             return !istransaction.equals(lb.istransaction);
70         }
71         return false;
72     }
73
74     public int hashCode() {
75         int hashcode=md.hashCode();
76         for(int i=0;i<isglobal.length;i++) {
77             hashcode=hashcode*31+(isglobal[i]?0:1);
78         }
79         hashcode=hashcode*31+(istransaction?0:1);
80         return hashcode;
81     }
82 }