707a44bd07da8b11249e4c70f3ebd45ff999785c
[IRC.git] / Robust / src / Analysis / Prefetch / PrefetchPair.java
1 package Analysis.Prefetch;
2 import IR.Flat.*;
3 import java.util.*;
4 import IR.*;
5
6 public class PrefetchPair {
7         TempDescriptor td;
8         FieldDescriptor[] fd;
9         int arryindex;
10
11         public PrefetchPair() {
12         }
13
14         public PrefetchPair(TempDescriptor td) {
15                 this.td = td;
16         }
17
18         public PrefetchPair(TempDescriptor td, int index) {
19                 this.td = td;
20                 fd = new FieldDescriptor[index];
21                 arryindex = index;
22         }
23
24         public TempDescriptor getTemp() {
25                 return td;
26         }
27
28         public FieldDescriptor getField(int index) {
29                 return fd[index];
30         }
31
32         public int  getIndex() {
33                 return arryindex;
34         }
35
36         public int hashCode() {
37                 int hashcode = td.hashCode(); 
38                 for(int i=0; i<arryindex; i++) {
39                         hashcode = hashcode ^ fd[i].hashCode();
40                 }
41                 return hashcode;
42         }
43
44         public String toString() {
45                 //if(getTemp()!=null)
46                 return"<"+getTemp()+">";
47         }
48
49         public boolean equals(Object o) {
50                 if(o instanceof PrefetchPair) {
51                         PrefetchPair pp = (PrefetchPair) o;
52                         if(td != pp.td)
53                                 return false;
54                         for(int i=0; i< arryindex; i++) {
55                                 if(!fd[i].equals(pp.fd[i]))
56                                         return false;
57                         }
58                 }
59                 return false;
60         }
61 }