93b5af68ceb1c4cbb98bfcf1cfa91fe8d6a80bea
[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     private int numclasses=0;
26
27
28     public static TypeDescriptor getTypeDescriptor(int t) {
29         TypeDescriptor td=new TypeDescriptor(t);
30         return td;
31     }
32
33     public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
34         TypeDescriptor td=new TypeDescriptor(n);
35         return td;
36     }
37
38     public void addClass(ClassDescriptor tdn) {
39         if (classes.contains(tdn.getSymbol()))
40             throw new Error("Class "+tdn.getSymbol()+" defined twice");
41         classes.add(tdn);
42         numclasses++;
43     }
44
45     public int numClasses() {
46         return numclasses;
47     }
48
49     public BlockNode getMethodBody(MethodDescriptor md) {
50         return (BlockNode)treemethodmap.get(md);
51     }
52
53     public SymbolTable getClassSymbolTable() {
54         return classes;
55     }
56
57     public FlatMethod getMethodFlat(MethodDescriptor md) {
58         return (FlatMethod)flatmethodmap.get(md);
59     }
60
61     public void addTreeCode(MethodDescriptor md, BlockNode bn) {
62         treemethodmap.put(md,bn);
63     }
64
65     public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
66         flatmethodmap.put(md,bn);
67     }
68 }