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;
11 public FlatFlagActionNode(boolean taskexit) {
12 tempflagpairs=new Hashtable();
13 this.taskexit=taskexit;
16 public void addFlagAction(TempDescriptor td, FlagDescriptor fd, boolean status) {
17 TempFlagPair tfp=new TempFlagPair(td,fd);
18 if (tempflagpairs.containsKey(tfp)) {
19 throw new Error("Temp/Flag combination used twice: "+tfp);
21 tempflagpairs.put(tfp, new Boolean(status));
25 return FKind.FlatFlagActionNode;
28 /** This method returns an iterator over the Temp/Flag pairs. */
30 public Iterator getTempFlagPairs() {
31 return tempflagpairs.keySet().iterator();
34 public boolean getFlagChange(TempFlagPair tfp) {
35 return ((Boolean)tempflagpairs.get(tfp)).booleanValue();
38 public TempDescriptor [] readsTemps() {
39 if (tempflagpairs.size()==0)
40 return new TempDescriptor [0];
42 HashSet temps=new HashSet();
43 for(Iterator it=tempflagpairs.keySet().iterator();it.hasNext();) {
44 TempFlagPair tfp=(TempFlagPair)it.next();
45 temps.add(tfp.getTemp());
47 return (TempDescriptor[]) temps.toArray(new TempDescriptor [temps.size()]);