2 import IR.FlagDescriptor;
3 import java.util.Hashtable;
4 import java.util.HashSet;
5 import java.util.Iterator;
7 public class FlatFlagActionNode extends FlatNode {
8 Hashtable tempflagpairs;
10 public static final int NEWOBJECT=0;
11 public static final int PRE=1;
12 public static final int TASKEXIT=2;
15 public FlatFlagActionNode(int taskexit) {
16 tempflagpairs=new Hashtable();
17 this.taskexit=taskexit;
20 public void addFlagAction(TempDescriptor td, FlagDescriptor fd, boolean status) {
21 TempFlagPair tfp=new TempFlagPair(td,fd);
22 if (tempflagpairs.containsKey(tfp)) {
23 throw new Error("Temp/Flag combination used twice: "+tfp);
25 tempflagpairs.put(tfp, new Boolean(status));
29 return FKind.FlatFlagActionNode;
32 /** This method returns an iterator over the Temp/Flag pairs. */
34 public Iterator getTempFlagPairs() {
35 return tempflagpairs.keySet().iterator();
38 public boolean getFlagChange(TempFlagPair tfp) {
39 return ((Boolean)tempflagpairs.get(tfp)).booleanValue();
42 public TempDescriptor [] readsTemps() {
43 if (tempflagpairs.size()==0)
44 return new TempDescriptor [0];
46 HashSet temps=new HashSet();
47 for(Iterator it=tempflagpairs.keySet().iterator();it.hasNext();) {
48 TempFlagPair tfp=(TempFlagPair)it.next();
49 temps.add(tfp.getTemp());
51 return (TempDescriptor[]) temps.toArray(new TempDescriptor [temps.size()]);