1 package Analysis.TaskStateAnalysis;
7 public class TaskQueueIterator {
11 FlagTagState ftsarray[];
12 Hashtable<TempDescriptor, TagState> tsarray;
13 Hashtable<TempDescriptor, Integer> tsindexarray;
14 Iterator<FlagTagState> itarray[];
18 public TaskQueueIterator(TaskQueue tq, int index, FlagTagState fts) {
22 this.ftsarray=new FlagTagState[tq.numParameters()];
23 this.ftsarray[index]=fts;
24 this.tsarray=new Hashtable<TempDescriptor, TagState>();
25 this.tsindexarray=new Hashtable<TempDescriptor, Integer>();
26 this.itarray=(Iterator<FlagTagState>[]) new Iterator[tq.numParameters()];
33 for(int i=ftsarray.length-1;i>=0;i--) {
35 itarray[i]=tq.parameterset[i].iterator();
36 VarDescriptor vd=tq.task.getParameter(i);
37 TagExpressionList tel=tq.task.getTag(vd);
39 for(int j=0;j<tel.numTags();j++) {
40 TempDescriptor tmp=tel.getTemp(j);
41 if (!tsindexarray.containsKey(tmp)) {
42 tsindexarray.put(tmp, new Integer(i));
48 public boolean hasNext() {
49 TaskDescriptor td=tq.task;
54 ftsarray[i]=itarray[i].next();
59 if (i==0&&index==0&&ftsarray[0]!=null&&!needit) {
65 for(;i<ftsarray.length;i++) {
66 FlagState currfs=ftsarray[i].fs;
67 VarDescriptor vd=td.getParameter(i);
68 TagExpressionList tel=td.getTag(vd);
71 j=(tel!=null)&&tel.numTags()>0?tel.numTags()-1:0;
76 for(;tel!=null&&j<tel.numTags();j++) {
77 TempDescriptor tmp=tel.getTemp(j);
78 TagState currtag=tsarray.get(tmp);
79 String type=tel.getType(j);
81 if (tsindexarray.get(tmp).intValue()==i) {
82 //doing the assignment right here!!!
83 Vector<FlagTagState> possts=tq.map.get(currfs);
86 index=possts.indexOf(new FlagTagState(currtag,currfs));
91 for(int k=index;k<possts.size();k++) {
92 FlagTagState posstag=possts.get(k);
93 if (posstag.ts.getTag().getSymbol().equals(type)) {
94 tsarray.put(tmp, posstag.ts);
100 //Backtrack on objects
111 //couldn't find a tag
112 tsarray.put(tmp, null);
115 //check tag compatibility
116 if (!currtag.containsFS(currfs)) {
117 //incompatible tag set by previous level
118 //need to increment object state
128 if (itarray[i].hasNext()) {
129 ftsarray[i]=itarray[i].next();
132 continue objloop; //backtrack and fix up everything
134 itarray[i]=tq.parameterset[i].iterator();//keep going backwards
143 public FlagTagState getFTS(int index) {
144 return ftsarray[index];
147 public TagState getTS(TempDescriptor tmp) {
148 return tsarray.get(tmp);