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;
13 public class TaskDescriptor extends Descriptor {
15 protected Hashtable flagstable;
17 protected String identifier;
18 protected Vector params;
19 protected SymbolTable paramtable;
21 public TaskDescriptor(String identifier) {
23 this.identifier=identifier;
24 this.uniqueid=count++;
25 flagstable=new Hashtable();
27 paramtable=new SymbolTable();
30 public void addFlagEffects(Vector vfe) {
34 public Vector getFlagEffects() {
38 public SymbolTable getParameterTable() {
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);
47 flagstable.put(vd, fen);
48 if (paramtable.getFromSameScope(paramname)!=null) {
49 throw new Error("Parameter "+paramname+" already defined");
54 public int numParameters() {
58 public VarDescriptor getParameter(int i) {
59 return (VarDescriptor)params.get(i);
62 public String getParamName(int i) {
63 return ((VarDescriptor)params.get(i)).getName();
66 public TypeDescriptor getParamType(int i) {
67 return ((VarDescriptor)params.get(i)).getType();
70 public FlagExpressionNode getFlag(VarDescriptor vd) {
71 return (FlagExpressionNode) flagstable.get(vd);
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())