Fixed lots of bugs with increment operations and +=/etc...
[IRC.git] / Robust / src / IR / TaskDescriptor.java
1 package IR;
2 import IR.Tree.FlagExpressionNode;
3 import IR.Tree.FlagEffects;
4 import java.util.Vector;
5 import java.util.Hashtable;
6 import IR.Tree.Modifiers;
7
8 /**
9  * Descriptor 
10  *
11  */
12
13 public class TaskDescriptor extends Descriptor {
14
15     protected Hashtable flagstable;
16     protected Vector vfe;
17     protected String identifier;
18     protected Vector params;
19     protected SymbolTable paramtable;
20
21     public TaskDescriptor(String identifier) {
22         super(identifier);
23         this.identifier=identifier;
24         this.uniqueid=count++;
25         flagstable=new Hashtable();
26         params=new Vector();
27         paramtable=new SymbolTable();
28     }
29
30     public void addFlagEffects(Vector vfe) {
31         this.vfe=vfe;
32     }
33
34     public Vector getFlagEffects() {
35         return vfe;
36     }
37
38     public SymbolTable getParameterTable() {
39         return paramtable;
40     }
41
42     public void addParameter(TypeDescriptor type, String paramname, FlagExpressionNode fen) {
43         if (paramname.equals("this"))
44             throw new Error("Can't have parameter named this");
45         VarDescriptor vd=new VarDescriptor(type, paramname);
46         params.add(vd);
47         flagstable.put(vd, fen);
48         if (paramtable.getFromSameScope(paramname)!=null) {
49             throw new Error("Parameter "+paramname+" already defined");
50         }
51         paramtable.add(vd);
52     }
53
54     public int numParameters() {
55         return params.size();
56     }
57
58     public VarDescriptor getParameter(int i) {
59         return (VarDescriptor)params.get(i);
60     }
61
62     public String getParamName(int i) {
63         return ((VarDescriptor)params.get(i)).getName();
64     }
65
66     public TypeDescriptor getParamType(int i) {
67         return ((VarDescriptor)params.get(i)).getType();
68     }
69
70     public FlagExpressionNode getFlag(VarDescriptor vd) {
71         return (FlagExpressionNode) flagstable.get(vd);
72     }
73
74     public String toString() {
75         String st=identifier+"(";
76         for(int i=0;i<params.size();i++) {
77             st+=getParamType(i)+" "+getParamName(i);
78             if ((i+1)!=params.size())
79                 st+=", ";
80         }
81         st+=")";
82         return st;
83     }
84 }