3 import java.io.FileOutputStream;
4 import java.io.PrintStream;
6 import java.io.BufferedReader;
7 import java.io.FileReader;
8 import java.io.FileInputStream;
9 import java.util.Hashtable;
10 import java.util.Iterator;
12 import java.util.Vector;
14 import IR.Tree.ParseNode;
15 import IR.Tree.BuildIR;
16 import IR.Tree.SemanticCheck;
17 import IR.Flat.BuildCodeMultiCore;
18 import IR.Flat.BuildCodeMGC;
19 import IR.Flat.BuildFlat;
20 import IR.Flat.BuildCode;
21 import IR.Flat.Inliner;
22 import IR.ClassDescriptor;
24 import IR.TaskDescriptor;
26 import Analysis.Scheduling.MCImplSynthesis;
27 import Analysis.Scheduling.Schedule;
28 import Analysis.Scheduling.ScheduleAnalysis;
29 import Analysis.Scheduling.ScheduleSimulator;
30 import Analysis.TaskStateAnalysis.TaskAnalysis;
31 import Analysis.TaskStateAnalysis.TaskTagAnalysis;
32 import Analysis.TaskStateAnalysis.TaskGraph;
33 import Analysis.CallGraph.CallGraph;
34 import Analysis.TaskStateAnalysis.FEdge;
35 import Analysis.TaskStateAnalysis.FlagState;
36 import Analysis.TaskStateAnalysis.TagAnalysis;
37 import Analysis.TaskStateAnalysis.GarbageAnalysis;
38 import Analysis.TaskStateAnalysis.ExecutionGraph;
39 import Analysis.TaskStateAnalysis.SafetyAnalysis;
40 import Analysis.Locality.LocalityAnalysis;
41 import Analysis.Locality.GenerateConversions;
42 import Analysis.Prefetch.PrefetchAnalysis;
43 import Analysis.FlatIRGraph.FlatIRGraph;
44 import Analysis.OwnershipAnalysis.OwnershipAnalysis;
45 import Analysis.MLP.MLPAnalysis;
46 import Analysis.Disjoint.DisjointAnalysis;
47 import Analysis.OoOJava.OoOJavaAnalysis;
48 import Analysis.Loops.*;
49 import Analysis.Liveness;
50 import Analysis.ArrayReferencees;
51 import IR.MethodDescriptor;
52 import IR.Flat.FlatMethod;
54 import Util.GraphNode;
55 import Util.GraphNode.DFS;
56 import Util.GraphNode.SCC;
60 /** Main method for the compiler. */
62 public static void main(String args[]) throws Exception {
63 String ClassLibraryPrefix="./ClassLibrary/";
64 State state=new State();
65 Vector sourcefiles=new Vector();
66 state.classpath.add(".");
68 String outputdir = null;
69 boolean isDistributeInfo = false;
70 boolean isDisAll = false;
73 for(int i=0; i<args.length; i++) {
74 String option=args[i];
75 if (option.equals("-precise"))
76 IR.Flat.BuildCode.GENERATEPRECISEGC=true;
77 else if (option.equals("-prefetch"))
79 else if (option.equals("-dir"))
80 IR.Flat.BuildCode.PREFIX=args[++i]+"/";
81 else if (option.equals("-fastcheck"))
83 else if (option.equals("-selfloop"))
84 state.selfloops.add(args[++i]);
85 else if (option.equals("-outputdir"))
86 state.outputdir = args[++i];
87 else if (option.equals("-excprefetch"))
88 state.excprefetch.add(args[++i]);
89 else if (option.equals("-classlibrary"))
90 state.classpath.add(args[++i]);
91 else if (option.equals("-inlineatomic")) {
92 state.INLINEATOMIC=true;
93 state.inlineatomicdepth=Integer.parseInt(args[++i]);
94 } else if(option.equals("-numcore")) {
96 state.CORENUM = Integer.parseInt(args[i]);
97 } else if(option.equals("-numcore4gc")) {
99 state.CORENUM4GC = Integer.parseInt(args[i]);
100 } else if (option.equals("-mainclass"))
101 state.main=args[++i];
102 else if (option.equals("-trueprob")) {
103 state.TRUEPROB=Double.parseDouble(args[++i]);
104 } else if (option.equals("-printflat"))
105 State.PRINTFLAT=true;
106 else if (option.equals("-printscheduling"))
107 State.PRINTSCHEDULING=true;
108 else if (option.equals("-minimize"))
110 else if (option.equals("-printschedulesim"))
111 State.PRINTSCHEDULESIM=true;
112 else if (option.equals("-printcriticalpath"))
113 State.PRINTCRITICALPATH=true;
114 else if (option.equals("-struct"))
115 state.structfile=args[++i];
116 else if (option.equals("-conscheck"))
117 state.CONSCHECK=true;
118 else if (option.equals("-task"))
120 else if (option.equals("-abortreaders"))
121 state.ABORTREADERS=true;
122 else if (option.equals("-sandbox"))
124 else if (option.equals("-taskstate"))
125 state.TASKSTATE=true;
126 else if (option.equals("-tagstate"))
128 else if (option.equals("-stmarray"))
130 else if (option.equals("-eventmonitor"))
131 state.EVENTMONITOR=true;
132 else if (option.equals("-dualview"))
134 else if (option.equals("-hybrid"))
136 else if (option.equals("-flatirtasks")) {
137 state.FLATIRGRAPH=true;
138 state.FLATIRGRAPHTASKS=true;
139 } else if (option.equals("-flatirusermethods")) {
140 state.FLATIRGRAPH=true;
141 state.FLATIRGRAPHUSERMETHODS=true;
142 } else if (option.equals("-flatirlibmethods")) {
143 state.FLATIRGRAPH=true;
144 state.FLATIRGRAPHLIBMETHODS=true;
145 } else if (option.equals("-bamboocompiletime")) {
146 state.BAMBOOCOMPILETIME = true;
147 } else if (option.equals("-multicore"))
148 state.MULTICORE=true;
149 else if (option.equals("-multicoregc"))
150 state.MULTICOREGC=true;
151 else if (option.equals("-mgc")) {
153 } else if (option.equals("-ownership"))
154 state.OWNERSHIP=true;
155 else if (option.equals("-ownallocdepth")) {
156 state.OWNERSHIPALLOCDEPTH=Integer.parseInt(args[++i]);
157 } else if (option.equals("-ownwritedots")) {
158 state.OWNERSHIPWRITEDOTS=true;
159 if (args[++i].equals("all")) {
160 state.OWNERSHIPWRITEALL=true;
162 } else if (option.equals("-ownaliasfile")) {
163 state.OWNERSHIPALIASFILE=args[++i];
164 } else if (option.equals("-ownaliasfiletab")) {
165 state.OWNERSHIPALIASFILE=args[++i];
166 state.OWNERSHIPALIASTAB=true;
167 } else if (option.equals("-owndebugcallee")) {
168 state.OWNERSHIPDEBUGCALLEE=args[++i];
169 } else if (option.equals("-owndebugcaller")) {
170 state.OWNERSHIPDEBUGCALLER=args[++i];
171 } else if (option.equals("-owndebugcallcount")) {
172 state.OWNERSHIPDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
175 else if (option.equals("-disjoint"))
178 else if (option.equals("-disjoint-k")) {
179 state.DISJOINTALLOCDEPTH=Integer.parseInt(args[++i]);
181 } else if (option.equals("-disjoint-write-dots")) {
182 state.DISJOINTWRITEDOTS = true;
183 String arg = args[++i];
184 if( arg.equals("all") ) {
185 state.DISJOINTWRITEALL = true;
186 } else if( arg.equals("final") ) {
187 state.DISJOINTWRITEALL = false;
189 throw new Error("disjoint-write-dots requires argument <all/final>");
192 } else if (option.equals("-disjoint-write-initial-contexts")) {
193 state.DISJOINTWRITEINITCONTEXTS = true;
195 } else if (option.equals("-disjoint-write-ihms")) {
196 state.DISJOINTWRITEIHMS = true;
198 } else if (option.equals("-disjoint-alias-file")) {
199 state.DISJOINTALIASFILE = args[++i];
200 String arg = args[++i];
201 if( arg.equals("normal") ) {
202 state.DISJOINTALIASTAB = false;
203 } else if( arg.equals("tabbed") ) {
204 state.DISJOINTALIASTAB = true;
206 throw new Error("disjoint-alias-file requires arguments: <filename> <normal/tabbed>");
209 } else if (option.equals("-disjoint-debug-callsite")) {
210 state.DISJOINTDEBUGCALLEE=args[++i];
211 state.DISJOINTDEBUGCALLER=args[++i];
212 state.DISJOINTDEBUGCALLVISITTOSTART=Integer.parseInt(args[++i]);
213 state.DISJOINTDEBUGCALLNUMVISITS=Integer.parseInt(args[++i]);
214 String arg = args[++i];
215 if( arg.equals("true") ) {
216 state.DISJOINTDEBUGCALLSTOPAFTER = true;
217 } else if( arg.equals("false") ) {
218 state.DISJOINTDEBUGCALLSTOPAFTER = false;
220 throw new Error("disjoint-debug-callsite requires arguments:\n"+
221 " <callee symbol> <caller symbol> <# visit to start> <# visits to capture> <T/F stop after>");
224 } else if (option.equals("-disjoint-debug-snap-method")) {
225 state.DISJOINTSNAPSYMBOL=args[++i];
226 state.DISJOINTSNAPVISITTOSTART=Integer.parseInt(args[++i]);
227 state.DISJOINTSNAPNUMVISITS=Integer.parseInt(args[++i]);
228 String arg = args[++i];
229 if( arg.equals("true") ) {
230 state.DISJOINTSNAPSTOPAFTER = true;
231 } else if( arg.equals("false") ) {
232 state.DISJOINTSNAPSTOPAFTER = false;
234 throw new Error("disjoint-debug-snap-method requires arguments:\n"+
235 " <method symbol> <# visit to start> <# visits to snap> <T/F stop after>");
238 } else if( option.equals( "-disjoint-release-mode" ) ) {
239 state.DISJOINTRELEASEMODE = true;
241 } else if( option.equals( "-disjoint-dvisit-stack" ) ) {
242 state.DISJOINTDVISITSTACK = true;
243 state.DISJOINTDVISITPQUE = false;
244 state.DISJOINTDVISITSTACKEESONTOP = false;
246 } else if( option.equals( "-disjoint-dvisit-pqueue" ) ) {
247 state.DISJOINTDVISITPQUE = true;
248 state.DISJOINTDVISITSTACK = false;
249 state.DISJOINTDVISITSTACKEESONTOP = false;
251 } else if( option.equals( "-disjoint-dvisit-stack-callees-on-top" ) ) {
252 state.DISJOINTDVISITSTACKEESONTOP = true;
253 state.DISJOINTDVISITPQUE = false;
254 state.DISJOINTDVISITSTACK = false;
256 } else if( option.equals( "-disjoint-desire-determinism" ) ) {
257 state.DISJOINTDETERMINISM = true;
259 // when asking analysis for a deterministic result, force
260 // a stack-based visiting scheme, because the priority queue
261 // requires a non-deterministic topological sort
262 state.DISJOINTDVISITSTACKEESONTOP = true;
263 state.DISJOINTDVISITPQUE = false;
264 state.DISJOINTDVISITSTACK = false;
267 } else if( option.equals( "-disjoint-debug-scheduling" ) ) {
268 state.DISJOINTDEBUGSCHEDULING = true;
272 else if (option.equals("-optional"))
274 else if (option.equals("-optimize"))
276 else if (option.equals("-noloop"))
278 else if (option.equals("-dcopts"))
280 else if (option.equals("-arraypad"))
282 else if (option.equals("-delaycomp"))
283 state.DELAYCOMP=true;
284 else if (option.equals("-raw"))
286 else if (option.equals("-scheduling"))
287 state.SCHEDULING=true;
288 else if (option.equals("-distributioninfo"))
289 isDistributeInfo=true;
290 else if (option.equals("-disall"))
292 else if (option.equals("-disstart"))
293 startnum = Integer.parseInt(args[++i]);
294 else if (option.equals("-useprofile")) {
295 state.USEPROFILE=true;
296 state.profilename = args[++i];
298 else if (option.equals("-thread"))
300 else if (option.equals("-dsm"))
302 else if (option.equals("-recoverystats"))
303 state.DSMRECOVERYSTATS=true;
304 else if (option.equals("-dsmtask"))
306 else if (option.equals("-singleTM"))
308 else if (option.equals("-readset"))
310 else if (option.equals("-webinterface"))
311 state.WEBINTERFACE=true;
312 else if (option.equals("-instructionfailures"))
313 state.INSTRUCTIONFAILURE=true;
314 else if (option.equals("-abcclose"))
315 state.ARRAYBOUNDARYCHECK=false;
317 else if (option.equals("-mlp")) {
319 state.OWNERSHIP = true;
320 state.MLP_NUMCORES = Integer.parseInt( args[++i] );
321 state.MLP_MAXSESEAGE = Integer.parseInt( args[++i] );
323 } else if (option.equals("-mlpdebug")) {
326 } else if (option.equals("-methodeffects")) {
327 state.METHODEFFECTS=true;
329 } else if (option.equals("-coreprof")) {
332 } else if (option.equals("-ooojava")) {
333 state.OOOJAVA = true;
334 state.DISJOINT = true;
335 state.MLP_NUMCORES = Integer.parseInt( args[++i] );
336 state.MLP_MAXSESEAGE = Integer.parseInt( args[++i] );
338 } else if (option.equals("-ooodebug") ){
339 state.OOODEBUG = true;
340 } else if (option.equals("-rcr")){
342 } else if (option.equals("-rcr_debug")){
343 state.RCR_DEBUG = true;
344 } else if (option.equals("-rcr_debug_verbose")){
345 state.RCR_DEBUG_VERBOSE = true;
346 } else if (option.equals("-nostalltr")){
347 state.NOSTALLTR = true;
348 }else if (option.equals("-help")) {
349 System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
350 System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
351 System.out.println("-dir outputdirectory -- output code in outputdirectory");
352 System.out.println("-struct structfile -- output structure declarations for repair tool");
353 System.out.println("-mainclass -- main function to call");
354 System.out.println("-dsm -- distributed shared memory support");
355 System.out.println("-singleTM -- single machine committing transactions");
356 System.out.println("-abortreaders -- abort readers");
357 System.out.println("-precise -- use precise garbage collection");
358 System.out.println("-conscheck -- turn on consistency checking");
359 System.out.println("-task -- compiler for tasks");
360 System.out.println("-fastcheck -- fastcheckpointing for Bristlecone");
361 System.out.println("-thread -- threads");
362 System.out.println("-trueprob <d> -- probability of true branch");
363 System.out.println("-printflat -- print out flat representation");
364 System.out.println("-instructionfailures -- insert code for instruction level failures");
365 System.out.println("-taskstate -- do task state analysis");
366 System.out.println("-flatirtasks -- create dot files for flat IR graphs of tasks");
367 System.out.println("-flatirusermethods -- create dot files for flat IR graphs of user methods");
368 System.out.println("-flatirlibmethods -- create dot files for flat IR graphs of library class methods");
369 System.out.println(" note: -flatirusermethods or -flatirlibmethods currently generate all class method flat IR graphs");
370 System.out.println("-ownership -- do ownership analysis");
371 System.out.println("-ownallocdepth <d> -- set allocation depth for ownership analysis");
372 System.out.println("-ownwritedots <all/final> -- write ownership graphs; can be all results or just final results");
373 System.out.println("-ownaliasfile <filename> -- write a text file showing all detected aliases in program tasks");
374 System.out.println("-optimize -- enable optimizations");
375 System.out.println("-noloop -- disable loop optimizations");
376 System.out.println("-optional -- enable optional arguments");
377 System.out.println("-abcclose close the array boundary check");
378 System.out.println("-scheduling do task scheduling");
379 System.out.println("-mlp <num cores> <max sese age> build mlp code");
380 System.out.println("-mlpdebug if mlp, report progress and interim results");
381 System.out.println("-multicore generate multi-core version binary");
382 System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1");
383 System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)");
384 System.out.println("-rawconfig config raw simulator as 4xn (should be used together with -raw)");
385 System.out.println("-rawpath print out execute path information for raw version (should be used together with -raw)");
386 System.out.println("-useprofile use profiling data for scheduling (should be used together with -raw)");
387 System.out.println("-threadsimulate generate multi-thread simulate version binary");
388 System.out.println("-rawuseio use standard io to output profiling data (should be used together with -raw and -profile), it only works with single core version");
389 System.out.println("-printscheduling -- print out scheduling graphs");
390 System.out.println("-printschedulesim -- print out scheduling simulation result graphs");
391 System.out.println("-webinterface -- enable web interface");
392 System.out.println("-help -- print out help");
395 sourcefiles.add(args[i]);
399 //add default classpath
400 if (state.classpath.size()==1)
401 state.classpath.add(ClassLibraryPrefix);
403 BuildIR bir=new BuildIR(state);
404 TypeUtil tu=new TypeUtil(state, bir);
407 SemanticCheck sc=new SemanticCheck(state,tu);
409 for(int i=0;i<sourcefiles.size();i++)
410 loadClass(state, bir,(String)sourcefiles.get(i));
413 //Stuff the runtime wants to see
414 sc.getClass("String");
417 sc.getClass("Socket");
418 sc.getClass("ServerSocket");
419 sc.getClass("FileInputStream");
420 sc.getClass("FileOutputStream");
422 sc.getClass("TagDescriptor");
424 if (state.THREAD||state.DSM||state.SINGLETM||state.MGC) {
425 sc.getClass("Thread");
431 tu.createFullTable();
433 BuildFlat bf=new BuildFlat(state,tu);
435 SafetyAnalysis sa=null;
436 PrefetchAnalysis pa=null;
437 MLPAnalysis mlpa=null;
438 OoOJavaAnalysis oooa=null;
439 if (state.INLINEATOMIC) {
440 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
441 while(classit.hasNext()) {
442 ClassDescriptor cn=(ClassDescriptor)classit.next();
443 Iterator methodit=cn.getMethods();
444 while(methodit.hasNext()) {
446 MethodDescriptor md=(MethodDescriptor)methodit.next();
447 FlatMethod fm=state.getMethodFlat(md);
448 Inliner.inlineAtomic(state, tu, fm, state.inlineatomicdepth);
454 if (state.OPTIMIZE) {
455 CallGraph callgraph=new CallGraph(state);
456 CopyPropagation cp=new CopyPropagation();
457 DeadCode dc=new DeadCode();
458 GlobalFieldType gft=new GlobalFieldType(callgraph, state, tu.getMain());
459 CSE cse=new CSE(gft, tu);
460 localCSE lcse=new localCSE(gft, tu);
461 LoopOptimize lo=null;
463 lo=new LoopOptimize(gft, tu);
464 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
465 while(classit.hasNext()) {
466 ClassDescriptor cn=(ClassDescriptor)classit.next();
467 Iterator methodit=cn.getMethods();
468 while(methodit.hasNext()) {
469 /* Classify parameters */
470 MethodDescriptor md=(MethodDescriptor)methodit.next();
471 FlatMethod fm=state.getMethodFlat(md);
488 if (state.FLATIRGRAPH) {
489 FlatIRGraph firg = new FlatIRGraph(state,
490 state.FLATIRGRAPHTASKS,
491 state.FLATIRGRAPHUSERMETHODS,
492 state.FLATIRGRAPHLIBMETHODS);
495 if (state.OWNERSHIP && !state.MLP) {
496 CallGraph callGraph = new CallGraph(state);
497 Liveness liveness = new Liveness();
498 ArrayReferencees ar = new ArrayReferencees(state);
499 OwnershipAnalysis oa = new OwnershipAnalysis(state,
504 state.OWNERSHIPALLOCDEPTH,
505 state.OWNERSHIPWRITEDOTS,
506 state.OWNERSHIPWRITEALL,
507 state.OWNERSHIPALIASFILE,
508 state.METHODEFFECTS);
512 CallGraph callGraph = new CallGraph(state);
513 Liveness liveness = new Liveness();
514 ArrayReferencees ar = new ArrayReferencees(state);
515 OwnershipAnalysis oa = new OwnershipAnalysis(state,
520 state.OWNERSHIPALLOCDEPTH,
521 state.OWNERSHIPWRITEDOTS,
522 state.OWNERSHIPWRITEALL,
523 state.OWNERSHIPALIASFILE,
524 state.METHODEFFECTS);
525 mlpa = new MLPAnalysis(state,
531 if (state.DISJOINT && !state.OOOJAVA) {
532 CallGraph cg = new CallGraph(state);
533 Liveness l = new Liveness();
534 ArrayReferencees ar = new ArrayReferencees(state);
535 DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar, null, null, null);
539 CallGraph cg = new CallGraph(state);
540 Liveness l = new Liveness();
541 ArrayReferencees ar = new ArrayReferencees(state);
542 oooa = new OoOJavaAnalysis(state, tu, cg, l, ar);
546 if (state.TAGSTATE) {
547 CallGraph callgraph=new CallGraph(state);
548 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
549 TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis, tu);
552 if (state.TASKSTATE) {
553 CallGraph callgraph=new CallGraph(state);
554 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
555 TaskAnalysis ta=new TaskAnalysis(state, taganalysis, tu);
557 TaskGraph tg=new TaskGraph(state, ta);
560 if (state.OPTIONAL) {
561 ExecutionGraph et=new ExecutionGraph(state, ta);
562 et.createExecutionGraph();
563 sa = new SafetyAnalysis(et.getExecutionGraph(), state, ta);
565 state.storeAnalysisResult(sa.getResult());
566 state.storeOptionalTaskDescriptors(sa.getOptionalTaskDescriptors());
569 if (state.WEBINTERFACE) {
570 GarbageAnalysis ga=new GarbageAnalysis(state, ta);
571 WebInterface wi=new WebInterface(state, ta, tg, ga, taganalysis);
572 JhttpServer serve=new JhttpServer(8000,wi);
576 if (state.SCHEDULING) {
577 // Use ownership analysis to get alias information
578 CallGraph callGraph = new CallGraph(state);
579 Liveness liveness = new Liveness();
580 ArrayReferencees ar = new ArrayReferencees(state);
581 OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state,
586 state.OWNERSHIPALLOCDEPTH,
587 state.OWNERSHIPWRITEDOTS,
588 state.OWNERSHIPWRITEALL,
589 state.OWNERSHIPALIASFILE);*/
591 // synthesis a layout according to target multicore processor
592 MCImplSynthesis mcImplSynthesis = new MCImplSynthesis(state,
595 if(isDistributeInfo) {
596 mcImplSynthesis.distribution(isDisAll, startnum);
598 double timeStartAnalysis = (double) System.nanoTime();
599 mcImplSynthesis.setScheduleThreshold(20);
600 mcImplSynthesis.setProbThreshold(0);
601 mcImplSynthesis.setGenerateThreshold(30);
602 Vector<Schedule> scheduling = mcImplSynthesis.synthesis();
604 double timeEndAnalysis = (double) System.nanoTime();
605 if(state.BAMBOOCOMPILETIME) {
606 double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
607 System.err.println("The analysis took" + dt + "sec.");
611 // generate multicore codes
612 if(state.MULTICORE) {
613 BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
618 mcImplSynthesis.getCoreNum(),
621 bcm.setOwnershipAnalysis(oa);
631 // generate multicore codes
632 if(state.MULTICORE) {
633 BuildCodeMGC bcmgc=new BuildCodeMGC(state,
645 if(!state.MULTICORE) {
646 if (state.DSM||state.SINGLETM) {
647 CallGraph callgraph=new CallGraph(state);
648 if (state.PREFETCH) {
649 //speed up prefetch generation using locality analysis results
650 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
651 pa=new PrefetchAnalysis(state, callgraph, tu, la);
653 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
654 GenerateConversions gc=new GenerateConversions(la, state);
655 BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa, mlpa,oooa);
658 BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa, mlpa,oooa);
663 System.out.println("Lines="+state.lines);
667 public static void loadClass(State state, BuildIR bir, String sourcefile) {
669 ParseNode pn=readSourceFile(state, sourcefile);
670 bir.buildtree(pn, null);
671 } catch (Exception e) {
672 System.out.println("Error in sourcefile:"+sourcefile);
676 System.out.println("Error in sourcefile:"+sourcefile);
682 /** Reads in a source file and adds the parse tree to the state object. */
684 public static ParseNode readSourceFile(State state, String sourcefile) {
686 Reader fr= new BufferedReader(new FileReader(sourcefile));
687 Lex.Lexer l = new Lex.Lexer(fr);
688 java_cup.runtime.lr_parser g;
689 g = new Parse.Parser(l);
692 p=(ParseNode) g./*debug_*/parse().value;
693 } catch (Exception e) {
694 System.err.println("Error parsing file:"+sourcefile);
698 state.addParseNode(p);
699 if (l.numErrors()!=0) {
700 System.out.println("Error parsing "+sourcefile);
701 System.exit(l.numErrors());
703 state.lines+=l.line_num;
706 } catch (Exception e) {