check in changes
[IRC.git] / Robust / src / IR / Flat / FlatFlagActionNode.java
1 package IR.Flat;
2 import IR.FlagDescriptor;
3 import java.util.Hashtable;
4 import java.util.HashSet;
5 import java.util.Iterator;
6
7 public class FlatFlagActionNode extends FlatNode {
8     Hashtable tempflagpairs; 
9     boolean taskexit;
10
11     public FlatFlagActionNode(boolean taskexit) {
12         tempflagpairs=new Hashtable();
13         this.taskexit=taskexit;
14     }
15
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);
20         }
21         tempflagpairs.put(tfp, new Boolean(status));
22     }
23
24     public int kind() {
25         return FKind.FlatFlagActionNode;
26     }
27     
28     /** This method returns an iterator over the Temp/Flag pairs. */
29     
30     public Iterator getTempFlagPairs() {
31         return tempflagpairs.keySet().iterator();
32     }
33
34     public boolean getFlagChange(TempFlagPair tfp) {
35         return ((Boolean)tempflagpairs.get(tfp)).booleanValue();
36     }
37
38     public TempDescriptor [] readsTemps() {
39         if (tempflagpairs.size()==0)
40             return new TempDescriptor [0];
41         else {
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());
46             }
47             return (TempDescriptor[]) temps.toArray(new TempDescriptor [temps.size()]);
48         }
49     }
50 }