| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** The one true [World]. */ | 5 /** The one true [World]. */ |
| 6 World world; | 6 World world; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Experimental phase to enable await, only set when using the | 9 * Experimental phase to enable await, only set when using the |
| 10 * await/awaitc.dart entrypoint. | 10 * await/awaitc.dart entrypoint. |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (!options.enableLeg) return false; | 278 if (!options.enableLeg) return false; |
| 279 bool res = withTiming('try leg compile', () => leg.compile(this)); | 279 bool res = withTiming('try leg compile', () => leg.compile(this)); |
| 280 if (!res && options.legOnly) { | 280 if (!res && options.legOnly) { |
| 281 fatal("Leg could not compile ${options.dartScript}"); | 281 fatal("Leg could not compile ${options.dartScript}"); |
| 282 return true; // In --leg_only, always "handle" the compilation. | 282 return true; // In --leg_only, always "handle" the compilation. |
| 283 } | 283 } |
| 284 return res; | 284 return res; |
| 285 } | 285 } |
| 286 | 286 |
| 287 void runCompilationPhases() { | 287 void runCompilationPhases() { |
| 288 final lib = withTiming('first pass', processDartScript); | 288 final lib = withTiming('first pass', () => processDartScript()); |
| 289 withTiming('resolve top level', resolveAll); | 289 withTiming('resolve top level', resolveAll); |
| 290 if (experimentalAwaitPhase != null) { | 290 if (experimentalAwaitPhase != null) { |
| 291 withTiming('await translation', experimentalAwaitPhase); | 291 withTiming('await translation', experimentalAwaitPhase); |
| 292 } | 292 } |
| 293 withTiming('generate code', () { generateCode(lib); }); | 293 withTiming('generate code', () { generateCode(lib); }); |
| 294 } | 294 } |
| 295 | 295 |
| 296 String getGeneratedCode() { | 296 String getGeneratedCode() { |
| 297 // TODO(jimhug): Assert compilation is all done here. | 297 // TODO(jimhug): Assert compilation is all done here. |
| 298 if (legCode !== null) { | 298 if (legCode !== null) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 process() { | 333 process() { |
| 334 while (_todo.length > 0) { | 334 while (_todo.length > 0) { |
| 335 final todo = _todo; | 335 final todo = _todo; |
| 336 _todo = []; | 336 _todo = []; |
| 337 for (var lib in todo) { | 337 for (var lib in todo) { |
| 338 lib.visitSources(); | 338 lib.visitSources(); |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 Library processDartScript() { | 343 Library processDartScript([String script = null]) { |
| 344 Library library = getOrAddLibrary(options.dartScript); | 344 if (script == null) script = options.dartScript; |
| 345 Library library = getOrAddLibrary(script); |
| 345 process(); | 346 process(); |
| 346 return library; | 347 return library; |
| 347 } | 348 } |
| 348 | 349 |
| 349 resolveAll() { | 350 resolveAll() { |
| 350 for (var lib in libraries.getValues()) { | 351 for (var lib in libraries.getValues()) { |
| 351 lib.resolve(); | 352 lib.resolve(); |
| 352 } | 353 } |
| 353 } | 354 } |
| 354 | 355 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 452 |
| 452 withTiming(String name, f()) { | 453 withTiming(String name, f()) { |
| 453 final sw = new Stopwatch(); | 454 final sw = new Stopwatch(); |
| 454 sw.start(); | 455 sw.start(); |
| 455 var result = f(); | 456 var result = f(); |
| 456 sw.stop(); | 457 sw.stop(); |
| 457 info('$name in ${sw.elapsedInMs()}msec'); | 458 info('$name in ${sw.elapsedInMs()}msec'); |
| 458 return result; | 459 return result; |
| 459 } | 460 } |
| 460 } | 461 } |
| OLD | NEW |