2 import IR.Tree.FlagExpressionNode;
3 import IR.Tree.TagExpressionList;
4 import IR.Tree.FlagEffects;
5 import java.util.Vector;
6 import java.util.Hashtable;
7 import IR.Tree.Modifiers;
14 public class TaskDescriptor extends Descriptor {
16 protected Hashtable flagstable;
17 protected Hashtable tagstable;
19 protected String identifier;
20 protected Vector params;
21 protected SymbolTable paramtable;
23 public TaskDescriptor(String identifier) {
25 this.identifier=identifier;
26 this.uniqueid=count++;
27 flagstable=new Hashtable();
28 tagstable=new Hashtable(); //BUGFIX - added initialization here
30 paramtable=new SymbolTable();
33 public void addFlagEffects(Vector vfe) {
37 public Vector getFlagEffects() {
41 public SymbolTable getParameterTable() {
45 public void addParameter(TypeDescriptor type, String paramname, FlagExpressionNode fen, TagExpressionList tel) {
46 if (paramname.equals("this"))
47 throw new Error("Can't have parameter named this");
48 VarDescriptor vd=new VarDescriptor(type, paramname);
50 flagstable.put(vd, fen);
51 if (tel!=null) {//BUGFIX - added null check here...test with any bristlecone program
52 tagstable.put(vd, tel);
53 for(int i=0;i<tel.numTags();i++) {
54 TagVarDescriptor tvd=new TagVarDescriptor(new TagDescriptor(tel.getType(i)), tel.getName(i));
55 if (paramtable.getFromSameScope(tel.getName(i))==null) {
57 } else if (!((paramtable.getFromSameScope(tel.getName(i)) instanceof TagVarDescriptor)&¶mtable.getFromSameScope(tel.getName(i)).equals(tvd)))
58 throw new Error("Parameter "+paramname+" already defined");
62 if (paramtable.getFromSameScope(paramname)!=null) {
63 throw new Error("Parameter "+paramname+" already defined");
68 public int numParameters() {
72 public VarDescriptor getParameter(int i) {
73 return (VarDescriptor)params.get(i);
76 public String getParamName(int i) {
77 return ((VarDescriptor)params.get(i)).getName();
80 public TypeDescriptor getParamType(int i) {
81 return ((VarDescriptor)params.get(i)).getType();
84 public FlagExpressionNode getFlag(VarDescriptor vd) {
85 return (FlagExpressionNode) flagstable.get(vd);
88 public TagExpressionList getTag(VarDescriptor vd) {
89 return (TagExpressionList) flagstable.get(vd);
92 public String toString() {
93 String st=identifier+"(";
94 for(int i=0;i<params.size();i++) {
95 st+=getParamType(i)+" "+getParamName(i);
96 if ((i+1)!=params.size())