changes
[IRC.git] / Robust / src / IR / TaskDescriptor.java
index 96489bc804ad348cb42d4f90084f1f4dea34d825..2478d217ce9c9175fa1ed04f0731d7ee159746c6 100644 (file)
@@ -1,8 +1,10 @@
 package IR;
 import IR.Tree.FlagExpressionNode;
+import IR.Tree.TagExpressionList;
 import IR.Tree.FlagEffects;
 import java.util.Vector;
 import java.util.Hashtable;
+import IR.Tree.Modifiers;
 
 /**
  * Descriptor 
@@ -11,47 +13,52 @@ import java.util.Hashtable;
 
 public class TaskDescriptor extends Descriptor {
 
+    protected Hashtable flagstable;
+    protected Hashtable tagstable;
+    protected Vector vfe;
     protected String identifier;
     protected Vector params;
     protected SymbolTable paramtable;
-    protected VarDescriptor thisvd;
-    protected Hashtable flagstable;
-    protected Vector vfe;
 
     public TaskDescriptor(String identifier) {
        super(identifier);
        this.identifier=identifier;
        this.uniqueid=count++;
        flagstable=new Hashtable();
+       tagstable=new Hashtable(); //BUGFIX - added initialization here
        params=new Vector();
        paramtable=new SymbolTable();
-       thisvd=null;
     }
 
     public void addFlagEffects(Vector vfe) {
        this.vfe=vfe;
     }
 
-    public String getSafeMethodDescriptor() {
-       String st="";
-       for(int i=0;i<numParameters();i++) {
-           st+=getParamType(i).getSafeDescriptor();
-           if ((i+1)<numParameters())
-               st+="_";
-       }
-       return st;
+    public Vector getFlagEffects() {
+       return vfe;
     }
 
     public SymbolTable getParameterTable() {
        return paramtable;
     }
 
-    public void addParameter(TypeDescriptor type, String paramname, FlagExpressionNode fen) {
+    public void addParameter(TypeDescriptor type, String paramname, FlagExpressionNode fen, TagExpressionList tel) {
        if (paramname.equals("this"))
            throw new Error("Can't have parameter named this");
        VarDescriptor vd=new VarDescriptor(type, paramname);
        params.add(vd);
        flagstable.put(vd, fen);
+       if (tel!=null) {//BUGFIX - added null check here...test with any bristlecone program
+           tagstable.put(vd, tel);
+           for(int i=0;i<tel.numTags();i++) {
+               TagVarDescriptor tvd=new TagVarDescriptor(new TagDescriptor(tel.getType(i)), tel.getName(i));
+               if (paramtable.getFromSameScope(tel.getName(i))==null) {
+                   paramtable.add(tvd);
+               } else if (!(((paramtable.getFromSameScope(tel.getName(i)) instanceof TagVarDescriptor)&&paramtable.getFromSameScope(tel.getName(i))).equals(tvd))) 
+                   throw new Error("Parameter "+paramname+" already defined");
+           }
+       }
+       
        if (paramtable.getFromSameScope(paramname)!=null) {
            throw new Error("Parameter "+paramname+" already defined");
        }
@@ -74,6 +81,14 @@ public class TaskDescriptor extends Descriptor {
        return ((VarDescriptor)params.get(i)).getType();
     }
 
+    public FlagExpressionNode getFlag(VarDescriptor vd) {
+       return (FlagExpressionNode) flagstable.get(vd);
+    }
+
+    public TagExpressionList getTag(VarDescriptor vd) {
+       return (TagExpressionList) flagstable.get(vd);
+    }
+
     public String toString() {
        String st=identifier+"(";
        for(int i=0;i<params.size();i++) {