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 int getTaskType() {
24 public void addFlagAction(TempDescriptor td, FlagDescriptor fd, boolean status) {
25 TempFlagPair tfp=new TempFlagPair(td,fd);
26 if (tempflagpairs.containsKey(tfp)) {
27 throw new Error("Temp/Flag combination used twice: "+tfp);
29 tempflagpairs.put(tfp, new Boolean(status));
33 return FKind.FlatFlagActionNode;
36 /** This method returns an iterator over the Temp/Flag pairs. */
38 public Iterator getTempFlagPairs() {
39 return tempflagpairs.keySet().iterator();
42 public boolean getFlagChange(TempFlagPair tfp) {
43 return ((Boolean)tempflagpairs.get(tfp)).booleanValue();
46 public TempDescriptor [] readsTemps() {
47 if (tempflagpairs.size()==0)
48 return new TempDescriptor [0];
50 HashSet temps=new HashSet();
51 for(Iterator it=tempflagpairs.keySet().iterator();it.hasNext();) {
52 TempFlagPair tfp=(TempFlagPair)it.next();
53 temps.add(tfp.getTemp());
55 return (TempDescriptor[]) temps.toArray(new TempDescriptor [temps.size()]);
59 public String toString() {
60 return "FlatFlagActionNode";