b8b43463c92a8b50a1a78d6ca76451ed5060169d
[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         arraytypes.add(td);
34         arraytonumber.put(td,new Integer(arraycount++));
35     }
36
37     public Iterator getArrayIterator() {
38         return arraytypes.iterator();
39     }
40
41     public int getArrayNumber(TypeDescriptor td) {
42         return ((Integer)arraytonumber.get(td)).intValue();
43     }
44
45     public int numArrays() {
46         return arraytypes.size();
47     }
48
49     public static TypeDescriptor getTypeDescriptor(int t) {
50         TypeDescriptor td=new TypeDescriptor(t);
51         return td;
52     }
53
54     public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
55         TypeDescriptor td=new TypeDescriptor(n);
56         return td;
57     }
58
59     public void addClass(ClassDescriptor tdn) {
60         if (classes.contains(tdn.getSymbol()))
61             throw new Error("Class "+tdn.getSymbol()+" defined twice");
62         classes.add(tdn);
63         numclasses++;
64     }
65
66     public int numClasses() {
67         return numclasses;
68     }
69
70     public BlockNode getMethodBody(MethodDescriptor md) {
71         return (BlockNode)treemethodmap.get(md);
72     }
73
74     public SymbolTable getClassSymbolTable() {
75         return classes;
76     }
77
78     public FlatMethod getMethodFlat(MethodDescriptor md) {
79         return (FlatMethod)flatmethodmap.get(md);
80     }
81
82     public void addTreeCode(MethodDescriptor md, BlockNode bn) {
83         treemethodmap.put(md,bn);
84     }
85
86     public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
87         flatmethodmap.put(md,bn);
88     }
89 }