Code to keep track of flags in flat ir
[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
10     public FlatFlagActionNode() {
11         tempflagpairs=new Hashtable();
12     }
13
14     public void addFlagAction(TempDescriptor td, FlagDescriptor fd, boolean status) {
15         TempFlagPair tfp=new TempFlagPair(td,fd);
16         if (tempflagpairs.containsKey(tfp)) {
17             throw new Error("Temp/Flag combination used twice: "+tfp);
18         }
19         tempflagpairs.put(tfp, new Boolean(status));
20     }
21
22     public int kind() {
23         return FKind.FlatFlagActionNode;
24     }
25
26     public TempDescriptor [] readsTemps() {
27         if (tempflagpairs.size()==0)
28             return new TempDescriptor [0];
29         else {
30             HashSet temps=new HashSet();
31             for(Iterator it=tempflagpairs.keySet().iterator();it.hasNext();) {
32                 TempFlagPair tfp=(TempFlagPair)it.next();
33                 temps.add(tfp.getTemp());
34             }
35             return (TempDescriptor[]) temps.toArray(new TempDescriptor [temps.size()]);
36         }
37     }
38 }