2 import IR.FlagDescriptor;
3 import IR.TagDescriptor;
4 import java.util.Hashtable;
5 import java.util.HashSet;
6 import java.util.Iterator;
8 public class FlatFlagActionNode extends FlatNode {
9 Hashtable tempflagpairs;
10 Hashtable temptagpairs;
13 public static final int NEWOBJECT=0;
14 public static final int PRE=1;
15 public static final int TASKEXIT=2;
18 public FlatFlagActionNode(int taskexit) {
19 tempflagpairs=new Hashtable();
20 temptagpairs=new Hashtable();
21 this.taskexit=taskexit;
24 public int getTaskType() {
28 public void addFlagAction(TempDescriptor td, FlagDescriptor fd, boolean status) {
29 TempFlagPair tfp=new TempFlagPair(td,fd);
30 if (tempflagpairs.containsKey(tfp)) {
31 throw new Error("Temp/Flag combination used twice: "+tfp);
33 tempflagpairs.put(tfp, new Boolean(status));
36 public void addTagAction(TempDescriptor td, TagDescriptor tagd, TempDescriptor tagt, boolean status) {
37 TempTagPair ttp=new TempTagPair(td,tagd, tagt);
38 if (temptagpairs.containsKey(ttp)) {
39 throw new Error("Temp/Tag combination used twice: "+ttp);
41 temptagpairs.put(ttp, new Boolean(status));
45 return FKind.FlatFlagActionNode;
48 /** This method returns an iterator over the Temp/Flag pairs. */
50 public Iterator getTempFlagPairs() {
51 return tempflagpairs.keySet().iterator();
54 public Iterator getTempTagPairs() {
55 return temptagpairs.keySet().iterator();
58 public boolean getFlagChange(TempFlagPair tfp) {
59 return ((Boolean)tempflagpairs.get(tfp)).booleanValue();
62 public boolean getTagChange(TempTagPair ttp) {
63 return ((Boolean)temptagpairs.get(ttp)).booleanValue();
66 public TempDescriptor [] readsTemps() {
67 if (tempflagpairs.size()==0)
68 return new TempDescriptor [0];
70 HashSet temps=new HashSet();
71 for(Iterator it=tempflagpairs.keySet().iterator();it.hasNext();) {
72 TempFlagPair tfp=(TempFlagPair)it.next();
73 temps.add(tfp.getTemp());
75 for(Iterator it=temptagpairs.keySet().iterator();it.hasNext();) {
76 TempTagPair ttp=(TempTagPair)it.next();
77 temps.add(ttp.getTemp());
79 return (TempDescriptor[]) temps.toArray(new TempDescriptor [temps.size()]);
83 public String toString() {
84 return "FlatFlagActionNode";