| 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.library_loader; | 5 library dart2js.library_loader; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'common/names.dart' show Uris; | 9 import 'common/names.dart' show Uris; |
| 10 import 'common/tasks.dart' show CompilerTask, Measurer; | 10 import 'common/tasks.dart' show CompilerTask, Measurer; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 ErroneousElementX, | 24 ErroneousElementX, |
| 25 ExportElementX, | 25 ExportElementX, |
| 26 ImportElementX, | 26 ImportElementX, |
| 27 LibraryElementX, | 27 LibraryElementX, |
| 28 LibraryDependencyElementX, | 28 LibraryDependencyElementX, |
| 29 PrefixElementX, | 29 PrefixElementX, |
| 30 SyntheticImportElement; | 30 SyntheticImportElement; |
| 31 import 'enqueue.dart' show DeferredAction; | 31 import 'enqueue.dart' show DeferredAction; |
| 32 import 'environment.dart'; | 32 import 'environment.dart'; |
| 33 import 'io/source_file.dart' show Binary; | 33 import 'io/source_file.dart' show Binary; |
| 34 import 'kernel/element_map_impl.dart' show KernelToElementMapImpl; | 34 import 'kernel/element_map_impl.dart' show KernelToElementMapForImpactImpl; |
| 35 import 'patch_parser.dart' show PatchParserTask; | 35 import 'patch_parser.dart' show PatchParserTask; |
| 36 import 'resolved_uri_translator.dart'; | 36 import 'resolved_uri_translator.dart'; |
| 37 import 'script.dart'; | 37 import 'script.dart'; |
| 38 import 'serialization/serialization.dart' show LibraryDeserializer; | 38 import 'serialization/serialization.dart' show LibraryDeserializer; |
| 39 import 'tree/tree.dart'; | 39 import 'tree/tree.dart'; |
| 40 import 'util/util.dart' show Link, LinkBuilder; | 40 import 'util/util.dart' show Link, LinkBuilder; |
| 41 | 41 |
| 42 import 'package:kernel/ast.dart' as ir; | 42 import 'package:kernel/ast.dart' as ir; |
| 43 import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder; | 43 import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder; |
| 44 | 44 |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 final DiagnosticReporter reporter; | 814 final DiagnosticReporter reporter; |
| 815 | 815 |
| 816 final ResolvedUriTranslator uriTranslator; | 816 final ResolvedUriTranslator uriTranslator; |
| 817 | 817 |
| 818 /// Loads the contents of a script file (a .dart file). Used when loading | 818 /// Loads the contents of a script file (a .dart file). Used when loading |
| 819 /// libraries from source. | 819 /// libraries from source. |
| 820 final ScriptLoader scriptLoader; | 820 final ScriptLoader scriptLoader; |
| 821 | 821 |
| 822 /// Holds the mapping of Kernel IR to KElements that is constructed as a | 822 /// Holds the mapping of Kernel IR to KElements that is constructed as a |
| 823 /// result of loading a program. | 823 /// result of loading a program. |
| 824 final KernelToElementMapImpl _elementMap; | 824 final KernelToElementMapForImpactImpl _elementMap; |
| 825 | 825 |
| 826 List<LibraryEntity> _allLoadedLibraries; | 826 List<LibraryEntity> _allLoadedLibraries; |
| 827 | 827 |
| 828 DillLibraryLoaderTask(this._elementMap, this.uriTranslator, this.scriptLoader, | 828 DillLibraryLoaderTask(this._elementMap, this.uriTranslator, this.scriptLoader, |
| 829 this.reporter, Measurer measurer) | 829 this.reporter, Measurer measurer) |
| 830 : _allLoadedLibraries = new List<LibraryEntity>(), | 830 : _allLoadedLibraries = new List<LibraryEntity>(), |
| 831 super(measurer); | 831 super(measurer); |
| 832 | 832 |
| 833 /// Loads an entire Kernel [Program] from a file on disk (note, not just a | 833 /// Loads an entire Kernel [Program] from a file on disk (note, not just a |
| 834 /// library, so this name is actually a bit of a misnomer). | 834 /// library, so this name is actually a bit of a misnomer). |
| (...skipping 20 matching lines...) Expand all Loading... |
| 855 _allLoadedLibraries.add(_elementMap.lookupLibrary(library.importUri))); | 855 _allLoadedLibraries.add(_elementMap.lookupLibrary(library.importUri))); |
| 856 LibraryEntity rootLibrary = null; | 856 LibraryEntity rootLibrary = null; |
| 857 if (program.mainMethod != null) { | 857 if (program.mainMethod != null) { |
| 858 rootLibrary = _elementMap | 858 rootLibrary = _elementMap |
| 859 .lookupLibrary(program.mainMethod.enclosingLibrary.importUri); | 859 .lookupLibrary(program.mainMethod.enclosingLibrary.importUri); |
| 860 } | 860 } |
| 861 return new _LoadedLibrariesAdapter( | 861 return new _LoadedLibrariesAdapter( |
| 862 rootLibrary, _allLoadedLibraries, _elementMap); | 862 rootLibrary, _allLoadedLibraries, _elementMap); |
| 863 } | 863 } |
| 864 | 864 |
| 865 KernelToElementMapImpl get elementMap => _elementMap; | 865 KernelToElementMapForImpactImpl get elementMap => _elementMap; |
| 866 | 866 |
| 867 void reset({bool reuseLibrary(LibraryElement library)}) { | 867 void reset({bool reuseLibrary(LibraryElement library)}) { |
| 868 throw new UnimplementedError('DillLibraryLoaderTask.reset'); | 868 throw new UnimplementedError('DillLibraryLoaderTask.reset'); |
| 869 } | 869 } |
| 870 | 870 |
| 871 Future resetAsync(Future<bool> reuseLibrary(LibraryElement library)) { | 871 Future resetAsync(Future<bool> reuseLibrary(LibraryElement library)) { |
| 872 throw new UnimplementedError('DillLibraryLoaderTask.resetAsync'); | 872 throw new UnimplementedError('DillLibraryLoaderTask.resetAsync'); |
| 873 } | 873 } |
| 874 | 874 |
| 875 Iterable<LibraryEntity> get libraries => _allLoadedLibraries; | 875 Iterable<LibraryEntity> get libraries => _allLoadedLibraries; |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 } | 1589 } |
| 1590 | 1590 |
| 1591 String toString() => 'root=$rootLibrary,libraries=${_newLibraries}'; | 1591 String toString() => 'root=$rootLibrary,libraries=${_newLibraries}'; |
| 1592 } | 1592 } |
| 1593 | 1593 |
| 1594 /// Adapter class to mimic the behavior of LoadedLibraries for Kernel element | 1594 /// Adapter class to mimic the behavior of LoadedLibraries for Kernel element |
| 1595 /// behavior. Ultimately we'll just access worldBuilder instead. | 1595 /// behavior. Ultimately we'll just access worldBuilder instead. |
| 1596 class _LoadedLibrariesAdapter implements LoadedLibraries { | 1596 class _LoadedLibrariesAdapter implements LoadedLibraries { |
| 1597 final LibraryEntity rootLibrary; | 1597 final LibraryEntity rootLibrary; |
| 1598 final List<LibraryEntity> _newLibraries; | 1598 final List<LibraryEntity> _newLibraries; |
| 1599 final KernelToElementMapImpl worldBuilder; | 1599 final KernelToElementMapForImpactImpl worldBuilder; |
| 1600 | 1600 |
| 1601 _LoadedLibrariesAdapter( | 1601 _LoadedLibrariesAdapter( |
| 1602 this.rootLibrary, this._newLibraries, this.worldBuilder) { | 1602 this.rootLibrary, this._newLibraries, this.worldBuilder) { |
| 1603 assert(rootLibrary != null); | 1603 assert(rootLibrary != null); |
| 1604 } | 1604 } |
| 1605 | 1605 |
| 1606 bool containsLibrary(Uri uri) => getLibrary(uri) != null; | 1606 bool containsLibrary(Uri uri) => getLibrary(uri) != null; |
| 1607 | 1607 |
| 1608 LibraryEntity getLibrary(Uri uri) => worldBuilder.lookupLibrary(uri); | 1608 LibraryEntity getLibrary(Uri uri) => worldBuilder.lookupLibrary(uri); |
| 1609 | 1609 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 } | 1667 } |
| 1668 | 1668 |
| 1669 /// API used by the library loader to synchronously scan a library or | 1669 /// API used by the library loader to synchronously scan a library or |
| 1670 /// compilation unit and ensure that their library tags are computed. | 1670 /// compilation unit and ensure that their library tags are computed. |
| 1671 abstract class ElementScanner { | 1671 abstract class ElementScanner { |
| 1672 void scanLibrary(LibraryElement library); | 1672 void scanLibrary(LibraryElement library); |
| 1673 void scanUnit(CompilationUnitElement unit); | 1673 void scanUnit(CompilationUnitElement unit); |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 const _reuseLibrarySubtaskName = "Reuse library"; | 1676 const _reuseLibrarySubtaskName = "Reuse library"; |
| OLD | NEW |