This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 package IR;
2 import IR.Tree.*;
3 import IR.Flat.*;
4 import IR.*;
5 import java.util.*;
6 import Analysis.TaskStateAnalysis.*;
7
8 public class State {
9     public State() {
10         this.classes=new SymbolTable();
11         this.tasks=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         this.tagmap=new Hashtable();
18         this.selfloops=new HashSet();
19     }
20
21     public void addParseNode(ParseNode parsetree) {
22         parsetrees.add(parsetree);
23     }
24
25     public void storeAnalysisResult(Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults) {
26         this.analysisresults=analysisresults;
27     }
28
29     public Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> getAnalysisResult() {
30         return analysisresults;
31     }
32
33
34     public void storeOptionalTaskDescriptors(Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors){
35         this.optionaltaskdescriptors=optionaltaskdescriptors;
36     }
37
38     public Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> getOptionalTaskDescriptors(){
39         return optionaltaskdescriptors;
40     }
41
42     /** Boolean flag which indicates whether compiler is compiling a task-based
43      * program. */
44     public boolean WEBINTERFACE=false;
45     public boolean TASK=false;
46     public boolean DSM=false;
47     public boolean PREFETCH=false;
48     public boolean TASKSTATE=false;
49     public boolean TAGSTATE=false;
50     public boolean FLATIRGRAPH=false;
51     public boolean FLATIRGRAPHTASKS=false;
52     public boolean FLATIRGRAPHUSERMETHODS=false;
53     public boolean FLATIRGRAPHLIBMETHODS=false;
54     public boolean OWNERSHIP=false;
55     public boolean OPTIONAL=false;
56     public boolean SCHEDULING=false;  
57     public boolean THREAD=false;
58     public boolean CONSCHECK=false;
59     public boolean INSTRUCTIONFAILURE=false;
60     public String structfile;
61     public String main;
62
63     public HashSet selfloops;
64     public SymbolTable classes;
65     public SymbolTable tasks;
66     public Set parsetrees;
67     public Hashtable treemethodmap;
68     public Hashtable flatmethodmap;
69     private HashSet arraytypes;
70     public Hashtable arraytonumber;
71     private int numclasses=0;
72     private int numtasks=0;
73     private int arraycount=0;
74
75
76     private Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors;
77     private Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults;
78
79     private Hashtable tagmap;
80     private int numtags=0;
81
82     public void addArrayType(TypeDescriptor td) {
83         if (!arraytypes.contains(td)) {
84             arraytypes.add(td);
85             arraytonumber.put(td,new Integer(arraycount++));
86         }
87     }
88
89     public Iterator getArrayIterator() {
90         return arraytypes.iterator();
91     }
92
93     public int getTagId(TagDescriptor tag) {
94         if (tagmap.containsKey(tag)) {
95             return ((Integer) tagmap.get(tag)).intValue();
96         } else {
97             tagmap.put(tag, new Integer(numtags));
98             return numtags++;
99         }
100     }
101
102     public int getArrayNumber(TypeDescriptor td) {
103         return ((Integer)arraytonumber.get(td)).intValue();
104     }
105
106     public int numArrays() {
107         return arraytypes.size();
108     }
109
110     public static TypeDescriptor getTypeDescriptor(int t) {
111         TypeDescriptor td=new TypeDescriptor(t);
112         return td;
113     }
114
115     public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
116         TypeDescriptor td=new TypeDescriptor(n);
117         return td;
118     }
119
120     public void addClass(ClassDescriptor tdn) {
121         if (classes.contains(tdn.getSymbol()))
122             throw new Error("Class "+tdn.getSymbol()+" defined twice");
123         classes.add(tdn);
124         numclasses++;
125     }
126
127     public int numClasses() {
128         return numclasses;
129     }
130
131     public BlockNode getMethodBody(MethodDescriptor md) {
132         return (BlockNode)treemethodmap.get(md);
133     }
134
135     public BlockNode getMethodBody(TaskDescriptor td) {
136         return (BlockNode)treemethodmap.get(td);
137     }
138
139     public SymbolTable getClassSymbolTable() {
140         return classes;
141     }
142
143     public SymbolTable getTaskSymbolTable() {
144         return tasks;
145     }
146
147     /** Returns Flat IR representation of MethodDescriptor md. */
148
149     public FlatMethod getMethodFlat(MethodDescriptor md) {
150         return (FlatMethod)flatmethodmap.get(md);
151     }
152
153     /** Returns Flat IR representation of TaskDescriptor td. */
154
155     public FlatMethod getMethodFlat(TaskDescriptor td) {
156         return (FlatMethod)flatmethodmap.get(td);
157     }
158
159     public void addTreeCode(MethodDescriptor md, BlockNode bn) {
160         treemethodmap.put(md,bn);
161     }
162
163     public void addTreeCode(TaskDescriptor td, BlockNode bn) {
164         treemethodmap.put(td,bn);
165     }
166
167     public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
168         flatmethodmap.put(md,bn);
169     }
170
171     public void addFlatCode(TaskDescriptor td, FlatMethod bn) {
172         flatmethodmap.put(td,bn);
173     }
174
175     public void addTask(TaskDescriptor td) {
176         if (tasks.contains(td.getSymbol()))
177             throw new Error("Task "+td.getSymbol()+" defined twice");
178         tasks.add(td);
179         numtasks++;
180     }
181 }