Outgoing socket I/O
[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     int taskexit;
10     public static final int NEWOBJECT=0;
11     public static final int PRE=1;
12     public static final int TASKEXIT=2;
13
14
15     public FlatFlagActionNode(int taskexit) {
16         tempflagpairs=new Hashtable();
17         this.taskexit=taskexit;
18     }
19
20     public int getTaskType() {
21         return taskexit;
22     }
23
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);
28         }
29         tempflagpairs.put(tfp, new Boolean(status));
30     }
31
32     public int kind() {
33         return FKind.FlatFlagActionNode;
34     }
35     
36     /** This method returns an iterator over the Temp/Flag pairs. */
37     
38     public Iterator getTempFlagPairs() {
39         return tempflagpairs.keySet().iterator();
40     }
41
42     public boolean getFlagChange(TempFlagPair tfp) {
43         return ((Boolean)tempflagpairs.get(tfp)).booleanValue();
44     }
45
46     public TempDescriptor [] readsTemps() {
47         if (tempflagpairs.size()==0)
48             return new TempDescriptor [0];
49         else {
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());
54             }
55             return (TempDescriptor[]) temps.toArray(new TempDescriptor [temps.size()]);
56         }
57     }
58
59     public String toString() {
60         return "FlatFlagActionNode";
61     }
62 }