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("-nostalltr")){
343 state.NOSTALLTR = true;
344 }else if (option.equals("-help")) {
345 System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
346 System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
347 System.out.println("-dir outputdirectory -- output code in outputdirectory");
348 System.out.println("-struct structfile -- output structure declarations for repair tool");
349 System.out.println("-mainclass -- main function to call");
350 System.out.println("-dsm -- distributed shared memory support");
351 System.out.println("-singleTM -- single machine committing transactions");
352 System.out.println("-abortreaders -- abort readers");
353 System.out.println("-precise -- use precise garbage collection");
354 System.out.println("-conscheck -- turn on consistency checking");
355 System.out.println("-task -- compiler for tasks");
356 System.out.println("-fastcheck -- fastcheckpointing for Bristlecone");
357 System.out.println("-thread -- threads");
358 System.out.println("-trueprob <d> -- probability of true branch");
359 System.out.println("-printflat -- print out flat representation");
360 System.out.println("-instructionfailures -- insert code for instruction level failures");
361 System.out.println("-taskstate -- do task state analysis");
362 System.out.println("-flatirtasks -- create dot files for flat IR graphs of tasks");
363 System.out.println("-flatirusermethods -- create dot files for flat IR graphs of user methods");
364 System.out.println("-flatirlibmethods -- create dot files for flat IR graphs of library class methods");
365 System.out.println(" note: -flatirusermethods or -flatirlibmethods currently generate all class method flat IR graphs");
366 System.out.println("-ownership -- do ownership analysis");
367 System.out.println("-ownallocdepth <d> -- set allocation depth for ownership analysis");
368 System.out.println("-ownwritedots <all/final> -- write ownership graphs; can be all results or just final results");
369 System.out.println("-ownaliasfile <filename> -- write a text file showing all detected aliases in program tasks");
370 System.out.println("-optimize -- enable optimizations");
371 System.out.println("-noloop -- disable loop optimizations");
372 System.out.println("-optional -- enable optional arguments");
373 System.out.println("-abcclose close the array boundary check");
374 System.out.println("-scheduling do task scheduling");
375 System.out.println("-mlp <num cores> <max sese age> build mlp code");
376 System.out.println("-mlpdebug if mlp, report progress and interim results");
377 System.out.println("-multicore generate multi-core version binary");
378 System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1");
379 System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)");
380 System.out.println("-rawconfig config raw simulator as 4xn (should be used together with -raw)");
381 System.out.println("-rawpath print out execute path information for raw version (should be used together with -raw)");
382 System.out.println("-useprofile use profiling data for scheduling (should be used together with -raw)");
383 System.out.println("-threadsimulate generate multi-thread simulate version binary");
384 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");
385 System.out.println("-printscheduling -- print out scheduling graphs");
386 System.out.println("-printschedulesim -- print out scheduling simulation result graphs");
387 System.out.println("-webinterface -- enable web interface");
388 System.out.println("-help -- print out help");
391 sourcefiles.add(args[i]);
395 //add default classpath
396 if (state.classpath.size()==1)
397 state.classpath.add(ClassLibraryPrefix);
399 BuildIR bir=new BuildIR(state);
400 TypeUtil tu=new TypeUtil(state, bir);
403 SemanticCheck sc=new SemanticCheck(state,tu);
405 for(int i=0;i<sourcefiles.size();i++)
406 loadClass(state, bir,(String)sourcefiles.get(i));
409 //Stuff the runtime wants to see
410 sc.getClass("String");
413 sc.getClass("Socket");
414 sc.getClass("ServerSocket");
415 sc.getClass("FileInputStream");
416 sc.getClass("FileOutputStream");
418 sc.getClass("TagDescriptor");
420 if (state.THREAD||state.DSM||state.SINGLETM||state.MGC) {
421 sc.getClass("Thread");
427 tu.createFullTable();
429 BuildFlat bf=new BuildFlat(state,tu);
431 SafetyAnalysis sa=null;
432 PrefetchAnalysis pa=null;
433 MLPAnalysis mlpa=null;
434 OoOJavaAnalysis oooa=null;
435 if (state.INLINEATOMIC) {
436 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
437 while(classit.hasNext()) {
438 ClassDescriptor cn=(ClassDescriptor)classit.next();
439 Iterator methodit=cn.getMethods();
440 while(methodit.hasNext()) {
442 MethodDescriptor md=(MethodDescriptor)methodit.next();
443 FlatMethod fm=state.getMethodFlat(md);
444 Inliner.inlineAtomic(state, tu, fm, state.inlineatomicdepth);
450 if (state.OPTIMIZE) {
451 CallGraph callgraph=new CallGraph(state);
452 CopyPropagation cp=new CopyPropagation();
453 DeadCode dc=new DeadCode();
454 GlobalFieldType gft=new GlobalFieldType(callgraph, state, tu.getMain());
455 CSE cse=new CSE(gft, tu);
456 localCSE lcse=new localCSE(gft, tu);
457 LoopOptimize lo=null;
459 lo=new LoopOptimize(gft, tu);
460 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
461 while(classit.hasNext()) {
462 ClassDescriptor cn=(ClassDescriptor)classit.next();
463 Iterator methodit=cn.getMethods();
464 while(methodit.hasNext()) {
465 /* Classify parameters */
466 MethodDescriptor md=(MethodDescriptor)methodit.next();
467 FlatMethod fm=state.getMethodFlat(md);
484 if (state.FLATIRGRAPH) {
485 FlatIRGraph firg = new FlatIRGraph(state,
486 state.FLATIRGRAPHTASKS,
487 state.FLATIRGRAPHUSERMETHODS,
488 state.FLATIRGRAPHLIBMETHODS);
491 if (state.OWNERSHIP && !state.MLP) {
492 CallGraph callGraph = new CallGraph(state);
493 Liveness liveness = new Liveness();
494 ArrayReferencees ar = new ArrayReferencees(state);
495 OwnershipAnalysis oa = new OwnershipAnalysis(state,
500 state.OWNERSHIPALLOCDEPTH,
501 state.OWNERSHIPWRITEDOTS,
502 state.OWNERSHIPWRITEALL,
503 state.OWNERSHIPALIASFILE,
504 state.METHODEFFECTS);
508 CallGraph callGraph = new CallGraph(state);
509 Liveness liveness = new Liveness();
510 ArrayReferencees ar = new ArrayReferencees(state);
511 OwnershipAnalysis oa = new OwnershipAnalysis(state,
516 state.OWNERSHIPALLOCDEPTH,
517 state.OWNERSHIPWRITEDOTS,
518 state.OWNERSHIPWRITEALL,
519 state.OWNERSHIPALIASFILE,
520 state.METHODEFFECTS);
521 mlpa = new MLPAnalysis(state,
527 if (state.DISJOINT && !state.OOOJAVA) {
528 CallGraph cg = new CallGraph(state);
529 Liveness l = new Liveness();
530 ArrayReferencees ar = new ArrayReferencees(state);
531 DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar, null, null, null);
535 CallGraph cg = new CallGraph(state);
536 Liveness l = new Liveness();
537 ArrayReferencees ar = new ArrayReferencees(state);
538 oooa = new OoOJavaAnalysis(state, tu, cg, l, ar);
542 if (state.TAGSTATE) {
543 CallGraph callgraph=new CallGraph(state);
544 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
545 TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis, tu);
548 if (state.TASKSTATE) {
549 CallGraph callgraph=new CallGraph(state);
550 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
551 TaskAnalysis ta=new TaskAnalysis(state, taganalysis, tu);
553 TaskGraph tg=new TaskGraph(state, ta);
556 if (state.OPTIONAL) {
557 ExecutionGraph et=new ExecutionGraph(state, ta);
558 et.createExecutionGraph();
559 sa = new SafetyAnalysis(et.getExecutionGraph(), state, ta);
561 state.storeAnalysisResult(sa.getResult());
562 state.storeOptionalTaskDescriptors(sa.getOptionalTaskDescriptors());
565 if (state.WEBINTERFACE) {
566 GarbageAnalysis ga=new GarbageAnalysis(state, ta);
567 WebInterface wi=new WebInterface(state, ta, tg, ga, taganalysis);
568 JhttpServer serve=new JhttpServer(8000,wi);
572 if (state.SCHEDULING) {
573 // Use ownership analysis to get alias information
574 CallGraph callGraph = new CallGraph(state);
575 Liveness liveness = new Liveness();
576 ArrayReferencees ar = new ArrayReferencees(state);
577 OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state,
582 state.OWNERSHIPALLOCDEPTH,
583 state.OWNERSHIPWRITEDOTS,
584 state.OWNERSHIPWRITEALL,
585 state.OWNERSHIPALIASFILE);*/
587 // synthesis a layout according to target multicore processor
588 MCImplSynthesis mcImplSynthesis = new MCImplSynthesis(state,
591 if(isDistributeInfo) {
592 mcImplSynthesis.distribution(isDisAll, startnum);
594 double timeStartAnalysis = (double) System.nanoTime();
595 mcImplSynthesis.setScheduleThreshold(20);
596 mcImplSynthesis.setProbThreshold(0);
597 mcImplSynthesis.setGenerateThreshold(30);
598 Vector<Schedule> scheduling = mcImplSynthesis.synthesis();
600 double timeEndAnalysis = (double) System.nanoTime();
601 if(state.BAMBOOCOMPILETIME) {
602 double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
603 System.err.println("The analysis took" + dt + "sec.");
607 // generate multicore codes
608 if(state.MULTICORE) {
609 BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
614 mcImplSynthesis.getCoreNum(),
617 bcm.setOwnershipAnalysis(oa);
627 // generate multicore codes
628 if(state.MULTICORE) {
629 BuildCodeMGC bcmgc=new BuildCodeMGC(state,
641 if(!state.MULTICORE) {
642 if (state.DSM||state.SINGLETM) {
643 CallGraph callgraph=new CallGraph(state);
644 if (state.PREFETCH) {
645 //speed up prefetch generation using locality analysis results
646 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
647 pa=new PrefetchAnalysis(state, callgraph, tu, la);
649 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
650 GenerateConversions gc=new GenerateConversions(la, state);
651 BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa, mlpa,oooa);
654 BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa, mlpa,oooa);
659 System.out.println("Lines="+state.lines);
663 public static void loadClass(State state, BuildIR bir, String sourcefile) {
665 ParseNode pn=readSourceFile(state, sourcefile);
666 bir.buildtree(pn, null);
667 } catch (Exception e) {
668 System.out.println("Error in sourcefile:"+sourcefile);
672 System.out.println("Error in sourcefile:"+sourcefile);
678 /** Reads in a source file and adds the parse tree to the state object. */
680 public static ParseNode readSourceFile(State state, String sourcefile) {
682 Reader fr= new BufferedReader(new FileReader(sourcefile));
683 Lex.Lexer l = new Lex.Lexer(fr);
684 java_cup.runtime.lr_parser g;
685 g = new Parse.Parser(l);
688 p=(ParseNode) g./*debug_*/parse().value;
689 } catch (Exception e) {
690 System.err.println("Error parsing file:"+sourcefile);
694 state.addParseNode(p);
695 if (l.numErrors()!=0) {
696 System.out.println("Error parsing "+sourcefile);
697 System.exit(l.numErrors());
699 state.lines+=l.line_num;
702 } catch (Exception e) {