checking in changes
[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 State(ParseNode parsetree) {
9         this.parsetree=parsetree;
10         this.classes=new SymbolTable();
11         this.treemethodmap=new Hashtable();
12         this.flatmethodmap=new Hashtable();
13     }
14
15     public SymbolTable classes;
16     public ParseNode parsetree;
17     public Hashtable treemethodmap;
18     public Hashtable flatmethodmap;
19
20     public static TypeDescriptor getTypeDescriptor(int t) {
21         TypeDescriptor td=new TypeDescriptor(t);
22         return td;
23     }
24
25     public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
26         TypeDescriptor td=new TypeDescriptor(n);
27         return td;
28     }
29
30     public void addClass(ClassDescriptor tdn) {
31         if (classes.contains(tdn.getSymbol()))
32             throw new Error("Class "+tdn.getSymbol()+" defined twice");
33         classes.add(tdn);
34     }
35
36     public BlockNode getMethodBody(MethodDescriptor md) {
37         return (BlockNode)treemethodmap.get(md);
38     }
39
40     public SymbolTable getClassSymbolTable() {
41         return classes;
42     }
43
44     public FlatMethod getMethodFlat(MethodDescriptor md) {
45         return (FlatMethod)flatmethodmap.get(md);
46     }
47
48     public void addTreeCode(MethodDescriptor md, BlockNode bn) {
49         treemethodmap.put(md,bn);
50     }
51
52     public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
53         flatmethodmap.put(md,bn);
54     }
55 }