1 package Analysis.TaskStateAnalysis;
7 public class TaskBinding {
9 Vector<Integer> decisions;
10 Hashtable<TempDescriptor, TagWrapper> temptotag;
11 ObjWrapper[] parameterbindings;
14 public TaskBinding(TaskQueueIterator tqi) {
16 this.decisions=new Vector<Integer>();
17 int numobjs=tqi.ftsarray.length;
18 int numtags=tqi.tq.tags.size();
19 this.parameterbindings=new ObjWrapper[numobjs];
20 for(int i=0; i<(numtags+numobjs); i++) {
21 decisions.add(new Integer(0));
25 public ObjWrapper getParameter(int i) {
26 return parameterbindings[i];
29 public TagWrapper getTag(TempDescriptor tmp) {
30 return temptotag.get(tmp);
37 public boolean hasNext() {
38 Vector<TempDescriptor> tagv=tqi.tq.tags;
39 int numtags=tagv.size();
40 int numobjs=tqi.ftsarray.length;
41 int incrementlevel=numtags+numobjs;
43 //actually do increment
50 Hashtable<TagState, Vector<TagWrapper>> ttable=new Hashtable<TagState, Vector<TagWrapper>>();
51 temptotag=new Hashtable<TempDescriptor, TagWrapper>();
53 for(int i=0; i<(numtags+numobjs); i++) {
57 int objindex=i-numtags;
58 tag=tqi.ftsarray[objindex].ts;
60 TempDescriptor tmp=tagv.get(i);
63 int index=decisions.get(i).intValue();
64 int currentsize=ttable.get(tag).size();
65 if (i==incrementlevel) {
66 if (index==currentsize) {
67 if (incrementlevel==0)
73 decisions.set(i, new Integer(index));
75 } else if (i>incrementlevel) {
77 decisions.set(i, new Integer(index));
79 if (index>currentsize) {
80 tw=new TagWrapper(tag);
81 if (!ttable.containsKey(tag)) {
82 ttable.put(tag, new Vector<TagWrapper>());
84 ttable.get(tag).add(tw);
87 tw=ttable.get(tag).get(index);
90 int objindex=i-numtags;
91 FlagTagState fts=tqi.ftsarray[objindex];
92 ObjWrapper ow=new ObjWrapper(fts.fs);
93 Hashtable <TagState,Set<TagWrapper>> ctable=new Hashtable<TagState, Set<TagWrapper>>();
94 ctable.put(tw.getState(), new HashSet<TagWrapper>());
95 ctable.get(tw.getState()).add(tw);
97 TagExpressionList tel=tqi.tq.task.getTag(tqi.tq.task.getParameter(i));
98 for(int j=0; j<tel.numTags(); j++) {
99 TempDescriptor tagtmp=tel.getTemp(j);
100 TagWrapper twtmp=temptotag.get(tagtmp);
101 if (!ctable.containsKey(twtmp.ts))
102 ctable.put(twtmp.getState(), new HashSet<TagWrapper>());
103 ctable.get(twtmp.getState()).add(twtmp);
105 int tagcount=ctable.get(twtmp.ts).size();
106 int fstagcount=fts.fs.getTagCount(twtmp.getState().getTag());
107 if (fstagcount>=0&&(tagcount>fstagcount)) {
108 //Too many unique tags of this type bound to object wrapper
113 parameterbindings[objindex]=ow;
115 TempDescriptor tmp=tagv.get(i);
116 temptotag.put(tmp, tw);