*/
public class IndexDescriptor extends Descriptor {
- public ArrayList<TempDescriptor> tddesc;
- public Integer offset;
+ public ArrayList<TempDescriptor> tddesc;
+ public Integer offset;
+
+ public IndexDescriptor(Integer offset) {
+ super(offset.toString());
+ this.offset = offset;
+ this.tddesc=new ArrayList<TempDescriptor>();
+ }
+
+ public IndexDescriptor(TempDescriptor tdesc, Integer offset) {
+ super(tdesc.toString());
+ tddesc = new ArrayList<TempDescriptor>();
+ tddesc.add(tdesc);
+ this.offset = offset;
+ }
+
+ public IndexDescriptor() {
+ super("Empty");
+ tddesc = new ArrayList<TempDescriptor>();
+ offset = 0;
+ }
- public IndexDescriptor(Integer offset) {
- super(offset.toString());
- this.offset = offset;
+ public IndexDescriptor(ArrayList<TempDescriptor> tdesc, Integer offset) {
+ super(tdesc.toString());
+ tddesc = new ArrayList<TempDescriptor>();
+ tddesc.addAll(tdesc);
+ this.offset = offset;
+ }
+
+ public ArrayList<TempDescriptor> getTempDesc() {
+ return tddesc;
+ }
+
+ public TempDescriptor getTempDescAt(int index) {
+ return ((TempDescriptor) (tddesc.get(index)));
+ }
+
+ public int getOffset() {
+ return offset.intValue();
+ }
+
+ public String toString() {
+ String label="[";
+ if(getTempDesc() == null) {
+ label += offset.toString();
+ return label;
+ } else {
+ ListIterator lit = getTempDesc().listIterator();
+ for(;lit.hasNext();) {
+ TempDescriptor td = (TempDescriptor) lit.next();
+ label += td.toString()+"+";
+ }
+ label +=offset.toString();
}
-
- public IndexDescriptor(TempDescriptor tdesc, Integer offset) {
- super(tdesc.toString());
- if(tddesc == null)
- tddesc = new ArrayList<TempDescriptor>();
- tddesc.add(tdesc);
- this.offset = offset;
- }
-
- public IndexDescriptor() {
- super("Empty");
- tddesc = new ArrayList<TempDescriptor>();
- offset = 0;
- }
-
- public IndexDescriptor(ArrayList<TempDescriptor> tdesc, Integer offset) {
- super(tdesc.toString());
- if(tddesc == null)
- tddesc = new ArrayList<TempDescriptor>();
- tddesc.addAll(tdesc);
- this.offset = offset;
- }
-
- public ArrayList<TempDescriptor> getTempDesc() {
- return tddesc;
- }
-
- public TempDescriptor getTempDescAt(int index) {
- return ((TempDescriptor) (tddesc.get(index)));
- }
-
- public int getOffset() {
- return offset.intValue();
- }
-
- public String toString() {
- String label="[";
- if(getTempDesc() == null) {
- label += offset.toString();
- return label;
- } else {
- ListIterator lit = getTempDesc().listIterator();
- for(;lit.hasNext();) {
- TempDescriptor td = (TempDescriptor) lit.next();
- label += td.toString()+"+";
- }
- label +=offset.toString();
- }
- label += "]";
- return label;
- }
-
- public int hashCode() {
- int hashcode = (Integer) offset.hashCode();
- if(tddesc != null) {
- ListIterator lit = tddesc.listIterator();
- while(lit.hasNext()) {
- hashcode = hashcode ^ lit.next().hashCode();
- }
- }
- return hashcode;
- }
-
- public boolean equals(Object o) {
- if(o instanceof IndexDescriptor) {
- IndexDescriptor idesc = (IndexDescriptor) o;
- if(!(offset.equals(idesc.offset))) {
- return false;
- }
- if(tddesc == null && idesc.tddesc == null) {
- return true;
- } else if(tddesc!=null && idesc.tddesc!=null) {
- if(tddesc.equals((ArrayList<TempDescriptor>)idesc.tddesc)){
- return true;
- }
- }else {
- return false;
- }
- }
- return false;
+ label += "]";
+ return label;
+ }
+
+ public int hashCode() {
+ int hashcode = (Integer) offset.hashCode();
+ hashcode^=tddesc.hashCode();
+ return hashcode;
+ }
+
+ public boolean equals(Object o) {
+ if(o instanceof IndexDescriptor) {
+ IndexDescriptor idesc = (IndexDescriptor) o;
+ return offset==idesc.offset&&
+ tddesc.equals(idesc.tddesc);
}
+ return false;
+ }
}
*/
public class PairMap {
- public HashMap<PrefetchPair, PrefetchPair> mappair;
+ public HashMap<PrefetchPair, PrefetchPair> mappair;
+
+ public PairMap() {
+ mappair = new HashMap<PrefetchPair, PrefetchPair>();
+ }
+
+ public void addPair(PrefetchPair ppKey, PrefetchPair ppValue) {
+ mappair.put(ppKey, ppValue);
+ }
+
+ public void removePair(PrefetchPair ppKey) {
+ mappair.remove(ppKey);
+ }
+
+ public PrefetchPair getPair(PrefetchPair ppKey) {
+ if(mappair != null)
+ return mappair.get(ppKey);
+ return null;
+ }
+
+ public int hashCode() {
+ return mappair.hashCode();
+ }
+
+ public int size() {
+ return mappair.size();
+ }
+
+ public boolean contains(PrefetchPair ppKey) {
+ if(mappair.containsKey(ppKey))
+ return true;
+ return false;
+ }
- public PairMap() {
- mappair = new HashMap<PrefetchPair, PrefetchPair>();
+ public String toString() {
+ String label = null;
+ Set mapping = mappair.entrySet();
+ Iterator it = mapping.iterator();
+ label = "Mappings are: ";
+ for(;it.hasNext();) {
+ Object o = it.next();
+ label += o.toString() + " , ";
}
+ return label;
+ }
- public void addPair(PrefetchPair ppKey, PrefetchPair ppValue) {
- mappair.put(ppKey, ppValue);
- }
-
- public void removePair(PrefetchPair ppKey) {
- mappair.remove(ppKey);
- }
-
- public PrefetchPair getPair(PrefetchPair ppKey) {
- if(mappair != null)
- return mappair.get(ppKey);
- return null;
- }
-
- public int hashCode() {
- int hashcode = mappair.hashCode();
- return hashcode;
- }
-
- public int size() {
- return mappair.size();
- }
-
- public boolean contains(PrefetchPair ppKey) {
- if(mappair.containsKey(ppKey))
- return true;
- return false;
- }
-
- public String toString() {
- String label = null;
- Set mapping = mappair.entrySet();
- Iterator it = mapping.iterator();
- label = "Mappings are: ";
- for(;it.hasNext();) {
- Object o = it.next();
- label += o.toString() + " , ";
- }
- return label;
- }
-
- public boolean equals(Object o) {
- if(o instanceof PairMap) {
- PairMap pm = (PairMap) o;
- if(mappair == null && pm.mappair == null) {
- return true;
- } else if(mappair != null && pm.mappair != null) {
- if(mappair.equals((HashMap) pm.mappair)) {
- return true;
- }
- } else {
- return false;
- }
- }
- return false;
- }
-
- public boolean isEmpty() {
- if(mappair.isEmpty())
- return true;
- return false;
+ public boolean equals(Object o) {
+ if(o instanceof PairMap) {
+ PairMap pm = (PairMap) o;
+ return mappair.equals(pm.mappair);
}
+ return false;
+ }
+
+ public boolean isEmpty() {
+ return mappair.isEmpty();
+ }
}
import IR.*;
public class PrefetchPair {
- public TempDescriptor base;
- public ArrayList<Descriptor> desc;
+ public TempDescriptor base;
+ public ArrayList<Descriptor> desc;
+
+ public PrefetchPair(){
+ base = new TempDescriptor("");
+ desc = new ArrayList<Descriptor>();
+ }
+
+ public PrefetchPair(TempDescriptor t, Descriptor f) {
+ base = t;
+ desc = new ArrayList<Descriptor>();
+ desc.add(f);
+ }
- public PrefetchPair(){
- base = new TempDescriptor("");
- desc = new ArrayList<Descriptor>();
- }
-
- public PrefetchPair(TempDescriptor t) {
- base = t;
- desc = null;
- }
-
- public PrefetchPair(TempDescriptor t, Descriptor f) {
- base = t;
- if (desc == null)
- desc = new ArrayList<Descriptor>();
- desc.add(f);
- }
-
- public PrefetchPair(TempDescriptor t, ArrayList<Descriptor> descriptor) {
- base = t;
- if(desc == null){
- desc = new ArrayList<Descriptor>();
- }
- desc.addAll(descriptor);
- }
-
- public TempDescriptor getBase() {
- return base;
- }
-
- public Descriptor getDescAt(int index) {
- return desc.get(index);
- }
+ public PrefetchPair(TempDescriptor t, ArrayList<Descriptor> descriptor) {
+ base = t;
+ desc = new ArrayList<Descriptor>();
+ desc.addAll(descriptor);
+ }
- public ArrayList<Descriptor> getDesc() {
- return desc;
+ public TempDescriptor getBase() {
+ return base;
+ }
+
+ public Descriptor getDescAt(int index) {
+ return desc.get(index);
+ }
+
+ public ArrayList<Descriptor> getDesc() {
+ return desc;
+ }
+
+ public FieldDescriptor getFieldDesc(int index) {
+ return (FieldDescriptor) desc.get(index);
+ }
+
+ public IndexDescriptor getIndexDesc(int index) {
+ return (IndexDescriptor) desc.get(index);
+ }
+
+ public int hashCode() {
+ int hashcode = base.toString().hashCode();
+ if(desc != null) {
+ hashcode^=desc.hashCode();
}
-
- public FieldDescriptor getFieldDesc(int index) {
- return (FieldDescriptor) desc.get(index);
- }
-
- public IndexDescriptor getIndexDesc(int index) {
- return (IndexDescriptor) desc.get(index);
- }
-
- public int hashCode() {
- int hashcode = base.toString().hashCode();
- if(desc != null) {
- ListIterator li = desc.listIterator();
- while(li.hasNext()) {
- hashcode = hashcode ^ li.next().toString().hashCode();
- }
- }
- return hashcode;
+ return hashcode;
+ }
+
+ public String toString() {
+ String label= getBase().toString();
+ if(getDesc() == null)
+ return label;
+ ListIterator it=getDesc().listIterator();
+ for(;it.hasNext();) {
+ Object o = it.next();
+ if(o instanceof FieldDescriptor) {
+ FieldDescriptor fd = (FieldDescriptor) o;
+ label+="."+ fd.toString();
+ } else {
+ IndexDescriptor id = (IndexDescriptor) o;
+ label+= id.toString();
+ }
}
-
- public String toString() {
- String label= getBase().toString();
- if(getDesc() == null)
- return label;
- ListIterator it=getDesc().listIterator();
- for(;it.hasNext();) {
- Object o = it.next();
- if(o instanceof FieldDescriptor) {
- FieldDescriptor fd = (FieldDescriptor) o;
- label+="."+ fd.toString();
- } else {
- IndexDescriptor id = (IndexDescriptor) o;
- label+= id.toString();
- }
- }
- return label;
- }
-
- public boolean equals(Object o) {
- if(o instanceof PrefetchPair) {
- PrefetchPair pp = (PrefetchPair) o;
- if(base != pp.base) {
- return false;
- }
- if(desc == null && pp.desc == null) {
- return true;
- } else if(desc != null && pp.desc != null) {
- if(desc.equals((ArrayList<Descriptor>)pp.desc)) {
- return true;
- }
- } else {
- return false;
- }
- }
- return false;
+ return label;
+ }
+
+ public boolean equals(Object o) {
+ if(o instanceof PrefetchPair) {
+ PrefetchPair pp = (PrefetchPair) o;
+ return base == pp.base && desc.equals(pp.desc);
}
-
- public Object clone() {
- PrefetchPair newpp = new PrefetchPair();
- ArrayList<TempDescriptor> td = null;
- newpp.base = this.base;
- for(int i = 0; i < this.desc.size(); i++) {
- Object o = desc.get(i);
- if(o instanceof FieldDescriptor) {
- newpp.desc.add((FieldDescriptor) o);
- } else {
- td = new ArrayList<TempDescriptor>();
- for(int j = 0; j < ((IndexDescriptor)o).tddesc.size(); j++) {
- td.add(((IndexDescriptor)o).getTempDescAt(j));
- }
- IndexDescriptor idesc = new IndexDescriptor();
- idesc.tddesc = td;
- idesc.offset = ((IndexDescriptor)o).offset;
- newpp.desc.add(idesc);
- }
+ return false;
+ }
+
+ public Object clone() {
+ PrefetchPair newpp = new PrefetchPair();
+ newpp.base = this.base;
+ for(int i = 0; i < this.desc.size(); i++) {
+ Object o = desc.get(i);
+ if(o instanceof FieldDescriptor) {
+ newpp.desc.add((FieldDescriptor) o);
+ } else {
+ ArrayList<TempDescriptor> td = new ArrayList<TempDescriptor>();
+ for(int j = 0; j < ((IndexDescriptor)o).tddesc.size(); j++) {
+ td.add(((IndexDescriptor)o).getTempDescAt(j));
}
- return newpp;
+ IndexDescriptor idesc = new IndexDescriptor();
+ idesc.tddesc = td;
+ idesc.offset = ((IndexDescriptor)o).offset;
+ newpp.desc.add(idesc);
+ }
}
+ return newpp;
+ }
}