| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart2js.compiler_base; | 5 library dart2js.compiler_base; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
| 8 | 8 |
| 9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
| 10 import 'cache_strategy.dart' show CacheStrategy; | 10 import 'cache_strategy.dart' show CacheStrategy; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 .join(MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING) | 478 .join(MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING) |
| 479 }); | 479 }); |
| 480 } | 480 } |
| 481 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); | 481 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); |
| 482 } | 482 } |
| 483 | 483 |
| 484 // TODO(johnniwinther): Move this to [PatchParser] when it is moved to the | 484 // TODO(johnniwinther): Move this to [PatchParser] when it is moved to the |
| 485 // [JavaScriptBackend]. Currently needed for testing. | 485 // [JavaScriptBackend]. Currently needed for testing. |
| 486 String get patchVersion => backend.patchVersion; | 486 String get patchVersion => backend.patchVersion; |
| 487 | 487 |
| 488 Element _unnamedListConstructor; | |
| 489 Element get unnamedListConstructor { | |
| 490 if (_unnamedListConstructor != null) return _unnamedListConstructor; | |
| 491 return _unnamedListConstructor = | |
| 492 coreClasses.listClass.lookupDefaultConstructor(); | |
| 493 } | |
| 494 | |
| 495 Element _filledListConstructor; | |
| 496 Element get filledListConstructor { | |
| 497 if (_filledListConstructor != null) return _filledListConstructor; | |
| 498 return _filledListConstructor = | |
| 499 coreClasses.listClass.lookupConstructor("filled"); | |
| 500 } | |
| 501 | |
| 502 /** | 488 /** |
| 503 * Get an [Uri] pointing to a patch for the dart: library with | 489 * Get an [Uri] pointing to a patch for the dart: library with |
| 504 * the given path. Returns null if there is no patch. | 490 * the given path. Returns null if there is no patch. |
| 505 */ | 491 */ |
| 506 Uri resolvePatchUri(String dartLibraryPath); | 492 Uri resolvePatchUri(String dartLibraryPath); |
| 507 | 493 |
| 508 Future runInternal(Uri uri) { | 494 Future runInternal(Uri uri) { |
| 509 // TODO(ahe): This prevents memory leaks when invoking the compiler | 495 // TODO(ahe): This prevents memory leaks when invoking the compiler |
| 510 // multiple times. Implement a better mechanism where we can store | 496 // multiple times. Implement a better mechanism where we can store |
| 511 // such caches in the compiler and get access to them through a | 497 // such caches in the compiler and get access to them through a |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 }); | 727 }); |
| 742 } | 728 } |
| 743 processQueue(enqueuer.codegen, mainFunction, | 729 processQueue(enqueuer.codegen, mainFunction, |
| 744 onProgress: showCodegenProgress); | 730 onProgress: showCodegenProgress); |
| 745 enqueuer.codegen.logSummary(reporter.log); | 731 enqueuer.codegen.logSummary(reporter.log); |
| 746 | 732 |
| 747 int programSize = backend.assembleProgram(); | 733 int programSize = backend.assembleProgram(); |
| 748 | 734 |
| 749 if (options.dumpInfo) { | 735 if (options.dumpInfo) { |
| 750 dumpInfoTask.reportSize(programSize); | 736 dumpInfoTask.reportSize(programSize); |
| 751 dumpInfoTask.dumpInfo(); | 737 dumpInfoTask.dumpInfo(closedWorld); |
| 752 } | 738 } |
| 753 | 739 |
| 754 backend.sourceInformationStrategy.onComplete(); | 740 backend.sourceInformationStrategy.onComplete(); |
| 755 | 741 |
| 756 checkQueues(); | 742 checkQueues(); |
| 757 }); | 743 }); |
| 758 | 744 |
| 759 /// Perform the steps needed to fully end the resolution phase. | 745 /// Perform the steps needed to fully end the resolution phase. |
| 760 ClosedWorldRefiner closeResolution() { | 746 ClosedWorldRefiner closeResolution() { |
| 761 phase = PHASE_DONE_RESOLVING; | 747 phase = PHASE_DONE_RESOLVING; |
| 762 | 748 |
| 763 WorldImpl world = resolverWorld.openWorld.closeWorld(reporter); | 749 WorldImpl world = resolverWorld.openWorld.closeWorld(reporter); |
| 764 // Compute whole-program-knowledge that the backend needs. (This might | 750 // Compute whole-program-knowledge that the backend needs. (This might |
| 765 // require the information computed in [world.closeWorld].) | 751 // require the information computed in [world.closeWorld].) |
| 766 backend.onResolutionComplete(world); | 752 backend.onResolutionComplete(world, world); |
| 767 | 753 |
| 768 deferredLoadTask.onResolutionComplete(mainFunction); | 754 deferredLoadTask.onResolutionComplete(mainFunction); |
| 769 | 755 |
| 770 // TODO(johnniwinther): Move this after rti computation but before | 756 // TODO(johnniwinther): Move this after rti computation but before |
| 771 // reflection members computation, and (re-)close the world afterwards. | 757 // reflection members computation, and (re-)close the world afterwards. |
| 772 closureToClassMapper.createClosureClasses(world); | 758 closureToClassMapper.createClosureClasses(world); |
| 773 return world; | 759 return world; |
| 774 } | 760 } |
| 775 | 761 |
| 776 /// Compute the [WorldImpact] for accessing all elements in [library]. | 762 /// Compute the [WorldImpact] for accessing all elements in [library]. |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 | 1470 |
| 1485 var element = library.find(name); | 1471 var element = library.find(name); |
| 1486 if (element == null) { | 1472 if (element == null) { |
| 1487 reporter.internalError( | 1473 reporter.internalError( |
| 1488 library, | 1474 library, |
| 1489 "The library '${library.canonicalUri}' does not contain required " | 1475 "The library '${library.canonicalUri}' does not contain required " |
| 1490 "element: '$name'."); | 1476 "element: '$name'."); |
| 1491 } | 1477 } |
| 1492 return element; | 1478 return element; |
| 1493 } | 1479 } |
| 1480 |
| 1481 ConstructorElement _unnamedListConstructor; |
| 1482 ConstructorElement get unnamedListConstructor => |
| 1483 _unnamedListConstructor ??= listClass.lookupDefaultConstructor(); |
| 1484 |
| 1485 ConstructorElement _filledListConstructor; |
| 1486 ConstructorElement get filledListConstructor => |
| 1487 _filledListConstructor ??= listClass.lookupConstructor("filled"); |
| 1494 } | 1488 } |
| 1495 | 1489 |
| 1496 class CompilerDiagnosticReporter extends DiagnosticReporter { | 1490 class CompilerDiagnosticReporter extends DiagnosticReporter { |
| 1497 final Compiler compiler; | 1491 final Compiler compiler; |
| 1498 final DiagnosticOptions options; | 1492 final DiagnosticOptions options; |
| 1499 | 1493 |
| 1500 Element _currentElement; | 1494 Element _currentElement; |
| 1501 bool hasCrashed = false; | 1495 bool hasCrashed = false; |
| 1502 | 1496 |
| 1503 /// `true` if the last diagnostic was filtered, in which case the | 1497 /// `true` if the last diagnostic was filtered, in which case the |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 _ElementScanner(this.scanner); | 2229 _ElementScanner(this.scanner); |
| 2236 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); | 2230 void scanLibrary(LibraryElement library) => scanner.scanLibrary(library); |
| 2237 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); | 2231 void scanUnit(CompilationUnitElement unit) => scanner.scan(unit); |
| 2238 } | 2232 } |
| 2239 | 2233 |
| 2240 class _EmptyEnvironment implements Environment { | 2234 class _EmptyEnvironment implements Environment { |
| 2241 const _EmptyEnvironment(); | 2235 const _EmptyEnvironment(); |
| 2242 | 2236 |
| 2243 String valueOf(String key) => null; | 2237 String valueOf(String key) => null; |
| 2244 } | 2238 } |
| OLD | NEW |