9 this.classes=new SymbolTable();
10 this.tasks=new SymbolTable();
11 this.treemethodmap=new Hashtable();
12 this.flatmethodmap=new Hashtable();
13 this.parsetrees=new HashSet();
14 this.arraytypes=new HashSet();
15 this.arraytonumber=new Hashtable();
16 this.tagmap=new Hashtable();
19 public void addParseNode(ParseNode parsetree) {
20 parsetrees.add(parsetree);
23 /** Boolean flag which indicates whether compiler is compiling a task-based
26 public boolean TASKSTATE=false;
27 public boolean THREAD=false;
28 public boolean INSTRUCTIONFAILURE=false;
29 public String structfile;
31 public boolean CONSCHECK=false;
33 public SymbolTable classes;
34 public SymbolTable tasks;
35 public Set parsetrees;
36 public Hashtable treemethodmap;
37 public Hashtable flatmethodmap;
38 private HashSet arraytypes;
39 public Hashtable arraytonumber;
40 private int numclasses=0;
41 private int numtasks=0;
42 private int arraycount=0;
44 private Hashtable tagmap;
45 private int numtags=0;
47 public void addArrayType(TypeDescriptor td) {
48 if (!arraytypes.contains(td)) {
50 arraytonumber.put(td,new Integer(arraycount++));
54 public Iterator getArrayIterator() {
55 return arraytypes.iterator();
58 public int getTagId(TagDescriptor tag) {
59 if (tagmap.containsKey(tag)) {
60 return ((Integer) tagmap.get(tag)).intValue();
62 tagmap.put(tag, new Integer(numtags));
67 public int getArrayNumber(TypeDescriptor td) {
68 return ((Integer)arraytonumber.get(td)).intValue();
71 public int numArrays() {
72 return arraytypes.size();
75 public static TypeDescriptor getTypeDescriptor(int t) {
76 TypeDescriptor td=new TypeDescriptor(t);
80 public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
81 TypeDescriptor td=new TypeDescriptor(n);
85 public void addClass(ClassDescriptor tdn) {
86 if (classes.contains(tdn.getSymbol()))
87 throw new Error("Class "+tdn.getSymbol()+" defined twice");
92 public int numClasses() {
96 public BlockNode getMethodBody(MethodDescriptor md) {
97 return (BlockNode)treemethodmap.get(md);
100 public BlockNode getMethodBody(TaskDescriptor td) {
101 return (BlockNode)treemethodmap.get(td);
104 public SymbolTable getClassSymbolTable() {
108 public SymbolTable getTaskSymbolTable() {
112 /** Returns Flat IR representation of MethodDescriptor md. */
114 public FlatMethod getMethodFlat(MethodDescriptor md) {
115 return (FlatMethod)flatmethodmap.get(md);
118 /** Returns Flat IR representation of TaskDescriptor td. */
120 public FlatMethod getMethodFlat(TaskDescriptor td) {
121 return (FlatMethod)flatmethodmap.get(td);
124 public void addTreeCode(MethodDescriptor md, BlockNode bn) {
125 treemethodmap.put(md,bn);
128 public void addTreeCode(TaskDescriptor td, BlockNode bn) {
129 treemethodmap.put(td,bn);
132 public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
133 flatmethodmap.put(md,bn);
136 public void addFlatCode(TaskDescriptor td, FlatMethod bn) {
137 flatmethodmap.put(td,bn);
140 public void addTask(TaskDescriptor td) {
141 if (tasks.contains(td.getSymbol()))
142 throw new Error("Task "+td.getSymbol()+" defined twice");