add more comments
[IRC.git] / Robust / src / Analysis / TaskStateAnalysis / TagBinding.java
1 package Analysis.TaskStateAnalysis;
2 import IR.MethodDescriptor;
3 import IR.TagDescriptor;
4 import Util.GraphNode;
5 import java.util.HashSet;
6 import java.util.Set;
7
8 public class TagBinding extends GraphNode {
9     private MethodDescriptor md;
10     private TagDescriptor[] tdarray;
11     private HashSet allocations;
12
13     public TagBinding(MethodDescriptor md) {
14         this.md=md;
15         tdarray=new TagDescriptor[md.numParameters()];
16         allocations=new HashSet();
17     }
18
19     public String toString() {
20         String st=md.toString();
21         for(int i=0;i<tdarray.length;i++)
22             st+=tdarray[i]+" ";
23         return st;
24     }
25
26     public Set getAllocations() {
27         return allocations;
28     }
29
30     public void setBinding(int i, TagDescriptor td) {
31         tdarray[i]=td;
32     }
33
34     public MethodDescriptor getMethod() {
35         return md;
36     }
37
38     public TagDescriptor getBinding(int i) {
39         return tdarray[i];
40     }
41
42     public boolean equals(Object o) {
43         if (o instanceof TagBinding) {
44             TagBinding tb=(TagBinding)o;
45             if (md!=tb.md)
46                 return false;
47             for(int i=0;i<tdarray.length;i++)
48                 if (tdarray[i]!=null) {
49                     if (!tdarray[i].equals(tb.tdarray[i]))
50                         return false;
51                 } else if(tb.tdarray[i]!=null)
52                     return false;
53             return true;
54         }
55         return false;
56     }
57
58     public int hashCode() {
59         int hashcode=md.hashCode();
60         for(int i=0;i<tdarray.length;i++) {
61             if (tdarray[i]!=null)
62                 hashcode^=tdarray[i].hashCode();
63         }
64         return hashcode;
65     }
66 }