Add support for tasks & flags
[IRC.git] / Robust / src / IR / State.java
1 package IR;
2 import IR.Tree.*;
3 import IR.Flat.*;
4 import IR.*;
5 import java.util.*;
6
7 public class State {
8     public String main;
9
10     public State() {
11         this.classes=new SymbolTable();
12         this.treemethodmap=new Hashtable();
13         this.flatmethodmap=new Hashtable();
14         this.parsetrees=new HashSet();
15         this.arraytypes=new HashSet();
16         this.arraytonumber=new Hashtable();
17     }
18
19     public void addParseNode(ParseNode parsetree) {
20         parsetrees.add(parsetree);
21     }
22
23     public SymbolTable classes;
24     public Set parsetrees;
25     public Hashtable treemethodmap;
26     public Hashtable flatmethodmap;
27     private HashSet arraytypes;
28     public Hashtable arraytonumber;
29     private int numclasses=0;
30     private int arraycount=0;
31
32     public void addArrayType(TypeDescriptor td) {
33         if (!arraytypes.contains(td)) {
34             arraytypes.add(td);
35             arraytonumber.put(td,new Integer(arraycount++));
36         }
37     }
38
39     public Iterator getArrayIterator() {
40         return arraytypes.iterator();
41     }
42
43     public int getArrayNumber(TypeDescriptor td) {
44         return ((Integer)arraytonumber.get(td)).intValue();
45     }
46
47     public int numArrays() {
48         return arraytypes.size();
49     }
50
51     public static TypeDescriptor getTypeDescriptor(int t) {
52         TypeDescriptor td=new TypeDescriptor(t);
53         return td;
54     }
55
56     public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
57         TypeDescriptor td=new TypeDescriptor(n);
58         return td;
59     }
60
61     public void addClass(ClassDescriptor tdn) {
62         if (classes.contains(tdn.getSymbol()))
63             throw new Error("Class "+tdn.getSymbol()+" defined twice");
64         classes.add(tdn);
65         numclasses++;
66     }
67
68     public int numClasses() {
69         return numclasses;
70     }
71
72     public BlockNode getMethodBody(MethodDescriptor md) {
73         return (BlockNode)treemethodmap.get(md);
74     }
75
76     public SymbolTable getClassSymbolTable() {
77         return classes;
78     }
79
80     public FlatMethod getMethodFlat(MethodDescriptor md) {
81         return (FlatMethod)flatmethodmap.get(md);
82     }
83
84     public void addTreeCode(MethodDescriptor md, BlockNode bn) {
85         treemethodmap.put(md,bn);
86     }
87
88     public void addTreeCode(TaskDescriptor td, BlockNode bn) {
89         treemethodmap.put(td,bn);
90     }
91
92     public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
93         flatmethodmap.put(md,bn);
94     }
95 }