Changes to allow multiple source files & library support
[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     }
16
17     public void addParseNode(ParseNode parsetree) {
18         parsetrees.add(parsetree);
19     }
20
21     public SymbolTable classes;
22     public Set parsetrees;
23     public Hashtable treemethodmap;
24     public Hashtable flatmethodmap;
25
26     public static TypeDescriptor getTypeDescriptor(int t) {
27         TypeDescriptor td=new TypeDescriptor(t);
28         return td;
29     }
30
31     public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
32         TypeDescriptor td=new TypeDescriptor(n);
33         return td;
34     }
35
36     public void addClass(ClassDescriptor tdn) {
37         if (classes.contains(tdn.getSymbol()))
38             throw new Error("Class "+tdn.getSymbol()+" defined twice");
39         classes.add(tdn);
40     }
41
42     public BlockNode getMethodBody(MethodDescriptor md) {
43         return (BlockNode)treemethodmap.get(md);
44     }
45
46     public SymbolTable getClassSymbolTable() {
47         return classes;
48     }
49
50     public FlatMethod getMethodFlat(MethodDescriptor md) {
51         return (FlatMethod)flatmethodmap.get(md);
52     }
53
54     public void addTreeCode(MethodDescriptor md, BlockNode bn) {
55         treemethodmap.put(md,bn);
56     }
57
58     public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
59         flatmethodmap.put(md,bn);
60     }
61 }