Changed inheritance to separate task/method descriptors again
[IRC.git] / Robust / src / IR / State.java
index b8b43463c92a8b50a1a78d6ca76451ed5060169d..c893c20ee70e0ceb9c1579297fe01a869074a4f0 100644 (file)
@@ -9,6 +9,7 @@ public class State {
 
     public State() {
        this.classes=new SymbolTable();
+       this.tasks=new SymbolTable();
        this.treemethodmap=new Hashtable();
        this.flatmethodmap=new Hashtable();
        this.parsetrees=new HashSet();
@@ -21,17 +22,21 @@ public class State {
     }
 
     public SymbolTable classes;
+    public SymbolTable tasks;
     public Set parsetrees;
     public Hashtable treemethodmap;
     public Hashtable flatmethodmap;
     private HashSet arraytypes;
     public Hashtable arraytonumber;
     private int numclasses=0;
+    private int numtasks=0;
     private int arraycount=0;
 
     public void addArrayType(TypeDescriptor td) {
-       arraytypes.add(td);
-       arraytonumber.put(td,new Integer(arraycount++));
+       if (!arraytypes.contains(td)) {
+           arraytypes.add(td);
+           arraytonumber.put(td,new Integer(arraycount++));
+       }
     }
 
     public Iterator getArrayIterator() {
@@ -71,10 +76,18 @@ public class State {
        return (BlockNode)treemethodmap.get(md);
     }
 
+    public BlockNode getMethodBody(TaskDescriptor td) {
+       return (BlockNode)treemethodmap.get(td);
+    }
+
     public SymbolTable getClassSymbolTable() {
        return classes;
     }
 
+    public SymbolTable getTaskSymbolTable() {
+       return tasks;
+    }
+
     public FlatMethod getMethodFlat(MethodDescriptor md) {
        return (FlatMethod)flatmethodmap.get(md);
     }
@@ -83,7 +96,22 @@ public class State {
        treemethodmap.put(md,bn);
     }
 
+    public void addTreeCode(TaskDescriptor td, BlockNode bn) {
+       treemethodmap.put(td,bn);
+    }
+
     public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
        flatmethodmap.put(md,bn);
     }
+
+    public void addFlatCode(TaskDescriptor td, FlatMethod bn) {
+       flatmethodmap.put(td,bn);
+    }
+
+    public void addTask(TaskDescriptor td) {
+       if (tasks.contains(td.getSymbol()))
+           throw new Error("Task "+td.getSymbol()+" defined twice");
+       tasks.add(td);
+       numtasks++;
+    }
 }