Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: pkg/compiler/lib/src/library_loader.dart

Issue 2798443002: Add "load from .dill" file capability and run a white-box test. (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
11 import 'common.dart'; 11 import 'common.dart';
12 import 'elements/elements.dart' 12 import 'elements/elements.dart'
13 show 13 show
14 CompilationUnitElement, 14 CompilationUnitElement,
15 Element, 15 Element,
16 ImportElement, 16 ImportElement,
17 ExportElement, 17 ExportElement,
18 LibraryElement; 18 LibraryElement;
19 import 'elements/entities.dart' show LibraryEntity;
19 import 'elements/modelx.dart' 20 import 'elements/modelx.dart'
20 show 21 show
21 CompilationUnitElementX, 22 CompilationUnitElementX,
22 DeferredLoaderGetterElementX, 23 DeferredLoaderGetterElementX,
23 ErroneousElementX, 24 ErroneousElementX,
24 ExportElementX, 25 ExportElementX,
25 ImportElementX, 26 ImportElementX,
26 LibraryElementX, 27 LibraryElementX,
27 LibraryDependencyElementX, 28 LibraryDependencyElementX,
28 PrefixElementX, 29 PrefixElementX,
29 SyntheticImportElement; 30 SyntheticImportElement;
30 import 'enqueue.dart' show DeferredAction; 31 import 'enqueue.dart' show DeferredAction;
31 import 'environment.dart'; 32 import 'environment.dart';
33 import 'kernel/world_builder.dart' show KernelWorldBuilder;
32 import 'patch_parser.dart' show PatchParserTask; 34 import 'patch_parser.dart' show PatchParserTask;
33 import 'resolved_uri_translator.dart'; 35 import 'resolved_uri_translator.dart';
34 import 'script.dart'; 36 import 'script.dart';
35 import 'serialization/serialization.dart' show LibraryDeserializer; 37 import 'serialization/serialization.dart' show LibraryDeserializer;
36 import 'tree/tree.dart'; 38 import 'tree/tree.dart';
37 import 'util/util.dart' show Link, LinkBuilder; 39 import 'util/util.dart' show Link, LinkBuilder;
38 40
41 import 'package:kernel/ast.dart' as ir;
42 import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder;
43
39 typedef Future<Iterable<LibraryElement>> ReuseLibrariesFunction( 44 typedef Future<Iterable<LibraryElement>> ReuseLibrariesFunction(
40 Iterable<LibraryElement> libraries); 45 Iterable<LibraryElement> libraries);
41 46
42 typedef Uri PatchResolverFunction(String dartLibraryPath); 47 typedef Uri PatchResolverFunction(String dartLibraryPath);
43 48
44 /** 49 /**
45 * [CompilerTask] for loading libraries and setting up the import/export scopes. 50 * [CompilerTask] for loading libraries and setting up the import/export scopes.
46 * 51 *
47 * The library loader uses four different kinds of URIs in different parts of 52 * The library loader uses four different kinds of URIs in different parts of
48 * the loading process. 53 * the loading process.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 * 135 *
131 * import 'package:foo.dart' as a; 136 * import 'package:foo.dart' as a;
132 * import 'packages/foo.dart' as b; 137 * import 'packages/foo.dart' as b;
133 * 138 *
134 * do _not_ resolve to the same library when the package root URI happens to 139 * do _not_ resolve to the same library when the package root URI happens to
135 * point to the 'packages' folder. 140 * point to the 'packages' folder.
136 * 141 *
137 */ 142 */
138 abstract class LibraryLoaderTask implements LibraryProvider, CompilerTask { 143 abstract class LibraryLoaderTask implements LibraryProvider, CompilerTask {
139 factory LibraryLoaderTask( 144 factory LibraryLoaderTask(
140 ResolvedUriTranslator uriTranslator, 145 bool loadFromDillFile,
141 ScriptLoader scriptLoader, 146 ResolvedUriTranslator uriTranslator,
142 ElementScanner scriptScanner, 147 ScriptLoader scriptLoader,
143 LibraryDeserializer deserializer, 148 ElementScanner scriptScanner,
144 PatchResolverFunction patchResolverFunc, 149 LibraryDeserializer deserializer,
145 PatchParserTask patchParser, 150 PatchResolverFunction patchResolverFunc,
146 Environment environment, 151 PatchParserTask patchParser,
147 DiagnosticReporter reporter, 152 Environment environment,
148 Measurer measurer) = _LibraryLoaderTask; 153 DiagnosticReporter reporter,
154 Measurer measurer) =>
155 loadFromDillFile
156 ? new _DillLibraryLoaderTask(
157 uriTranslator, scriptLoader, reporter, measurer)
158 : new _LibraryLoaderTask(
159 uriTranslator,
160 scriptLoader,
161 scriptScanner,
162 deserializer,
163 patchResolverFunc,
164 patchParser,
165 environment,
166 reporter,
167 measurer);
149 168
150 /// Returns all libraries that have been loaded. 169 /// Returns all libraries that have been loaded.
151 Iterable<LibraryElement> get libraries; 170 Iterable<LibraryEntity> get libraries;
152 171
153 /// Loads the library specified by the [resolvedUri] and returns the 172 /// Loads the library specified by the [resolvedUri] and returns the
154 /// [LoadedLibraries] that were loaded to load the specified uri. The 173 /// [LoadedLibraries] that were loaded to load the specified uri. The
155 /// [LibraryElement] itself can be found by calling 174 /// [LibraryElement] itself can be found by calling
156 /// `loadedLibraries.rootLibrary`. 175 /// `loadedLibraries.rootLibrary`.
157 /// 176 ///
158 /// If the library is not already loaded, the method creates the 177 /// If the library is not already loaded, the method creates the
159 /// [LibraryElement] for the library and computes the import/export scope, 178 /// [LibraryElement] for the library and computes the import/export scope,
160 /// loading and computing the import/export scopes of all required libraries 179 /// loading and computing the import/export scopes of all required libraries
161 /// in the process. The method handles cyclic dependency between libraries. 180 /// in the process. The method handles cyclic dependency between libraries.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 223
205 /// Returns the location of the patch-file associated with [libraryName] 224 /// Returns the location of the patch-file associated with [libraryName]
206 /// resolved from [plaformConfigUri]. 225 /// resolved from [plaformConfigUri].
207 /// 226 ///
208 /// Returns null if there is none. 227 /// Returns null if there is none.
209 static Uri resolvePatchUri(String libraryName, Uri platformConfigUri) { 228 static Uri resolvePatchUri(String libraryName, Uri platformConfigUri) {
210 String patchLocation = _patchLocations[libraryName]; 229 String patchLocation = _patchLocations[libraryName];
211 if (patchLocation == null) return null; 230 if (patchLocation == null) return null;
212 return platformConfigUri.resolve(patchLocation); 231 return platformConfigUri.resolve(patchLocation);
213 } 232 }
233
234 /// This is horrible temporary addition to the API that is only useful if we
235 /// are loading kernel files. Otherwise this returns null.
236 KernelWorldBuilder get worldBuilder;
214 } 237 }
215 238
216 /// Interface for an entity that provide libraries. For instance from normal 239 /// Interface for an entity that provide libraries. For instance from normal
217 /// library loading or from deserialization. 240 /// library loading or from deserialization.
218 // TODO(johnniwinther): Use this to integrate deserialized libraries better. 241 // TODO(johnniwinther): Use this to integrate deserialized libraries better.
219 abstract class LibraryProvider { 242 abstract class LibraryProvider {
220 /// Looks up the library with the [canonicalUri]. 243 /// Looks up the library with the [canonicalUri].
221 LibraryElement lookupLibrary(Uri canonicalUri); 244 LibraryEntity lookupLibrary(Uri canonicalUri);
222 } 245 }
223 246
224 /// Handle for creating synthesized/patch libraries during library loading. 247 /// Handle for creating synthesized/patch libraries during library loading.
225 abstract class LibraryLoader { 248 abstract class LibraryLoader {
226 /// This method must be called when a new synthesized/patch library has been 249 /// This method must be called when a new synthesized/patch library has been
227 /// created to ensure that [library] will part of library dependency graph 250 /// created to ensure that [library] will part of library dependency graph
228 /// used for computing import/export scopes. 251 /// used for computing import/export scopes.
229 void registerNewLibrary(LibraryElement library); 252 void registerNewLibrary(LibraryElement library);
230 253
231 /// This method must be called when a new synthesized/patch library has been 254 /// This method must be called when a new synthesized/patch library has been
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 388
366 String get name => 'LibraryLoader'; 389 String get name => 'LibraryLoader';
367 390
368 final Map<Uri, LibraryElement> libraryCanonicalUriMap = 391 final Map<Uri, LibraryElement> libraryCanonicalUriMap =
369 new Map<Uri, LibraryElement>(); 392 new Map<Uri, LibraryElement>();
370 final Map<Uri, LibraryElement> libraryResourceUriMap = 393 final Map<Uri, LibraryElement> libraryResourceUriMap =
371 new Map<Uri, LibraryElement>(); 394 new Map<Uri, LibraryElement>();
372 final Map<String, LibraryElement> libraryNames = 395 final Map<String, LibraryElement> libraryNames =
373 new Map<String, LibraryElement>(); 396 new Map<String, LibraryElement>();
374 397
375 Iterable<LibraryElement> get libraries => libraryCanonicalUriMap.values; 398 Iterable<LibraryEntity> get libraries => libraryCanonicalUriMap.values;
376 399
377 LibraryElement lookupLibrary(Uri canonicalUri) { 400 LibraryEntity lookupLibrary(Uri canonicalUri) {
378 return libraryCanonicalUriMap[canonicalUri]; 401 return libraryCanonicalUriMap[canonicalUri];
379 } 402 }
380 403
381 void reset({bool reuseLibrary(LibraryElement library)}) { 404 void reset({bool reuseLibrary(LibraryElement library)}) {
382 measure(() { 405 measure(() {
383 Iterable<LibraryElement> reusedLibraries = null; 406 Iterable<LibraryElement> reusedLibraries = null;
384 if (reuseLibrary != null) { 407 if (reuseLibrary != null) {
385 reusedLibraries = measureSubtask(_reuseLibrarySubtaskName, () { 408 reusedLibraries = measureSubtask(_reuseLibrarySubtaskName, () {
386 // Call [toList] to force eager calls to [reuseLibrary]. 409 // Call [toList] to force eager calls to [reuseLibrary].
387 return libraryCanonicalUriMap.values.where(reuseLibrary).toList(); 410 return libraryCanonicalUriMap.values.where(reuseLibrary).toList();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 {bool skipFileWithPartOfTag: false}) { 488 {bool skipFileWithPartOfTag: false}) {
466 return measure(() async { 489 return measure(() async {
467 LibraryDependencyHandler handler = new LibraryDependencyHandler(this); 490 LibraryDependencyHandler handler = new LibraryDependencyHandler(this);
468 LibraryElement library = await createLibrary( 491 LibraryElement library = await createLibrary(
469 handler, null, resolvedUri, NO_LOCATION_SPANNABLE, 492 handler, null, resolvedUri, NO_LOCATION_SPANNABLE,
470 skipFileWithPartOfTag: skipFileWithPartOfTag); 493 skipFileWithPartOfTag: skipFileWithPartOfTag);
471 if (library == null) return null; 494 if (library == null) return null;
472 return reporter.withCurrentElement(library, () { 495 return reporter.withCurrentElement(library, () {
473 return measure(() { 496 return measure(() {
474 handler.computeExports(); 497 handler.computeExports();
475 return new _LoadedLibraries(library, handler.newLibraries, this); 498 return new _LoadedLibraries(library, handler.newLibraries);
476 }); 499 });
477 }); 500 });
478 }); 501 });
479 } 502 }
480 503
481 /** 504 /**
482 * Processes the library tags in [library]. 505 * Processes the library tags in [library].
483 * 506 *
484 * The imported/exported libraries are loaded and processed recursively but 507 * The imported/exported libraries are loaded and processed recursively but
485 * the import/export scopes are not set up. 508 * the import/export scopes are not set up.
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 825
803 void registerDeferredAction(DeferredAction action) { 826 void registerDeferredAction(DeferredAction action) {
804 _deferredActions.add(action); 827 _deferredActions.add(action);
805 } 828 }
806 829
807 Iterable<DeferredAction> pullDeferredActions() { 830 Iterable<DeferredAction> pullDeferredActions() {
808 Iterable<DeferredAction> actions = _deferredActions.toList(); 831 Iterable<DeferredAction> actions = _deferredActions.toList();
809 _deferredActions.clear(); 832 _deferredActions.clear();
810 return actions; 833 return actions;
811 } 834 }
835
836 KernelWorldBuilder get worldBuilder => null;
837 }
838
839 /// A task for loading a pre-processed .dill file into memory rather than
840 /// parsing Dart source. Use of this task only makes sense when used in
841 /// conjunction with --use-kernel.
842 class _DillLibraryLoaderTask extends CompilerTask implements LibraryLoaderTask {
843 final DiagnosticReporter reporter;
844
845 final ResolvedUriTranslator uriTranslator;
846
847 /// Loads the contents of a script file (a .dart file). Used when loading
848 /// libraries from source.
849 final ScriptLoader scriptLoader;
850
851 /// Holds the mapping of Kernel IR to KElements that is constructed as a
852 /// result of loading a program.
853 KernelWorldBuilder _worldBuilder;
854
855 List<LibraryEntity> _allLoadedLibraries;
856
857 _DillLibraryLoaderTask(
858 this.uriTranslator, this.scriptLoader, this.reporter, Measurer measurer)
859 : _allLoadedLibraries = new List<LibraryEntity>(),
860 super(measurer);
861
862 /// Loads an entire Kernel [Program] from a file on disk (note, not just a
863 /// library, so this name is actuall a bit of a misnomer).
864 // TODO(efortuna): Rename this once the Element library loader class goes
865 // away.
866 Future<LoadedLibraries> loadLibrary(Uri resolvedUri,
867 {bool skipFileWithPartOfTag: false}) {
868 assert(resolvedUri.pathSegments.last.endsWith('.dill'));
869 Uri readableUri = uriTranslator.translate(null, resolvedUri, null);
870 return measure(() async {
871 Script script = await scriptLoader.readScript(readableUri, null);
872 ir.Program program = new ir.Program();
873 // Hack because the existing file has a terminating 0 and the
874 // BinaryBuilder doesn't expect that.
875 var bytes = new List<int>.from(script.file.slowUtf8ZeroTerminatedBytes());
876 bytes.removeLast();
877 new BinaryBuilder(bytes).readProgram(program);
878 //return reporter.withCurrentElement(program, () {
Johnni Winther 2017/04/04 07:25:20 Just remove this. It's only need if we report an e
Emily Fortuna 2017/04/04 20:03:52 ah yes, sorry I intended to clean that up, but for
879 // TODO: change withCurrentElement API to accept Kernel instead of just
880 // Elements.
881 return measure(() {
882 _worldBuilder = new KernelWorldBuilder(reporter, program);
883 program.libraries.forEach((ir.Library library) => _allLoadedLibraries
884 .add(_worldBuilder.lookupLibrary(library.importUri)));
885 return new _LoadedLibrariesAdapter(
886 _worldBuilder
887 .lookupLibrary(program.mainMethod.enclosingLibrary.importUri),
Johnni Winther 2017/04/04 07:25:20 We need to handle `program.mainMethod == null` gra
Emily Fortuna 2017/04/04 20:03:52 Added TODO
888 _allLoadedLibraries,
889 _worldBuilder);
890 });
891 //});
892 });
893 }
894
895 KernelWorldBuilder get worldBuilder => _worldBuilder;
896
897 void reset({bool reuseLibrary(LibraryElement library)}) {
898 throw new UnimplementedError('_DillLibraryLoaderTask.reset');
899 }
900
901 Future resetAsync(Future<bool> reuseLibrary(LibraryElement library)) {
902 throw new UnimplementedError('_DillLibraryLoaderTask.resetAsync');
903 }
904
905 Iterable<LibraryEntity> get libraries => _allLoadedLibraries;
906
907 LibraryEntity lookupLibrary(Uri canonicalUri) {
908 return _worldBuilder?.lookupLibrary(canonicalUri);
909 }
910
911 Future<Null> resetLibraries(ReuseLibrariesFunction reuseLibraries) {
912 throw new UnimplementedError('_DillLibraryLoaderTask.reuseLibraries');
913 }
914
915 void registerDeferredAction(DeferredAction action) {
916 throw new UnimplementedError(
917 '_DillLibraryLoaderTask.registerDeferredAction');
918 }
919
920 Iterable<DeferredAction> pullDeferredActions() {
921 throw new UnimplementedError('_DillLibraryLoaderTask.pullDeferredActions');
922 }
812 } 923 }
813 924
814 /// A state machine for checking script tags come in the correct order. 925 /// A state machine for checking script tags come in the correct order.
815 class TagState { 926 class TagState {
816 /// Initial state. 927 /// Initial state.
817 static const int NO_TAG_SEEN = 0; 928 static const int NO_TAG_SEEN = 0;
818 929
819 /// Passed to [checkTag] when a library declaration (the syntax "library 930 /// Passed to [checkTag] when a library declaration (the syntax "library
820 /// name;") has been seen. Not an actual state. 931 /// name;") has been seen. Not an actual state.
821 static const int LIBRARY = 1; 932 static const int LIBRARY = 1;
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 Future processLibraryTags(LibraryElement library) { 1486 Future processLibraryTags(LibraryElement library) {
1376 return task.processLibraryTags(this, library); 1487 return task.processLibraryTags(this, library);
1377 } 1488 }
1378 } 1489 }
1379 1490
1380 /// Information on the set libraries loaded as a result of a call to 1491 /// Information on the set libraries loaded as a result of a call to
1381 /// [LibraryLoader.loadLibrary]. 1492 /// [LibraryLoader.loadLibrary].
1382 abstract class LoadedLibraries { 1493 abstract class LoadedLibraries {
1383 /// The accesss the library object created corresponding to the library 1494 /// The accesss the library object created corresponding to the library
1384 /// passed to [LibraryLoader.loadLibrary]. 1495 /// passed to [LibraryLoader.loadLibrary].
1385 LibraryElement get rootLibrary; 1496 LibraryEntity get rootLibrary;
1386 1497
1387 /// Returns `true` if a library with canonical [uri] was loaded in this bulk. 1498 /// Returns `true` if a library with canonical [uri] was loaded in this bulk.
1388 bool containsLibrary(Uri uri); 1499 bool containsLibrary(Uri uri);
1389 1500
1390 /// Returns the library with canonical [uri] that was loaded in this bulk. 1501 /// Returns the library with canonical [uri] that was loaded in this bulk.
1391 LibraryElement getLibrary(Uri uri); 1502 LibraryEntity getLibrary(Uri uri);
1392 1503
1393 /// Applies all libraries in this bulk to [f]. 1504 /// Applies all libraries in this bulk to [f].
1394 void forEachLibrary(f(LibraryElement library)); 1505 void forEachLibrary(f(LibraryEntity library));
1395 1506
1396 /// Applies all imports chains of [uri] in this bulk to [callback]. 1507 /// Applies all imports chains of [uri] in this bulk to [callback].
1397 /// 1508 ///
1398 /// The argument [importChainReversed] to [callback] contains the chain of 1509 /// The argument [importChainReversed] to [callback] contains the chain of
1399 /// imports uris that lead to importing [uri] starting in [uri] and ending in 1510 /// imports uris that lead to importing [uri] starting in [uri] and ending in
1400 /// the uri that was passed in with [loadLibrary]. 1511 /// the uri that was passed in with [loadLibrary].
1401 /// 1512 ///
1402 /// [callback] is called once for each chain of imports leading to [uri] until 1513 /// [callback] is called once for each chain of imports leading to [uri] until
1403 /// [callback] returns `false`. 1514 /// [callback] returns `false`.
1404 void forEachImportChain(Uri uri, 1515 void forEachImportChain(Uri uri,
1405 {bool callback(Link<Uri> importChainReversed)}); 1516 {bool callback(Link<Uri> importChainReversed)});
1406 } 1517 }
1407 1518
1408 class _LoadedLibraries implements LoadedLibraries { 1519 class _LoadedLibraries implements LoadedLibraries {
1409 final _LibraryLoaderTask task;
1410 final LibraryElement rootLibrary; 1520 final LibraryElement rootLibrary;
1411 final Map<Uri, LibraryElement> loadedLibraries = <Uri, LibraryElement>{}; 1521 final Map<Uri, LibraryElement> loadedLibraries = <Uri, LibraryElement>{};
1412 final List<LibraryElement> _newLibraries; 1522 final List<LibraryElement> _newLibraries;
1413 1523
1414 _LoadedLibraries(this.rootLibrary, this._newLibraries, this.task) { 1524 _LoadedLibraries(this.rootLibrary, this._newLibraries) {
1415 _newLibraries.forEach((LibraryElement loadedLibrary) { 1525 _newLibraries.forEach((LibraryElement loadedLibrary) {
1416 loadedLibraries[loadedLibrary.canonicalUri] = loadedLibrary; 1526 loadedLibraries[loadedLibrary.canonicalUri] = loadedLibrary;
1417 }); 1527 });
1418 assert(rootLibrary != null); 1528 assert(rootLibrary != null);
1419 } 1529 }
1420 1530
1421 bool containsLibrary(Uri uri) => loadedLibraries.containsKey(uri); 1531 bool containsLibrary(Uri uri) => loadedLibraries.containsKey(uri);
1422 1532
1423 LibraryElement getLibrary(Uri uri) => loadedLibraries[uri]; 1533 LibraryElement getLibrary(Uri uri) => loadedLibraries[uri];
1424 1534
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 suffixChainMap[library] = suffixes; 1607 suffixChainMap[library] = suffixes;
1498 return; 1608 return;
1499 } 1609 }
1500 1610
1501 computeSuffixes(rootLibrary, const Link<Uri>()); 1611 computeSuffixes(rootLibrary, const Link<Uri>());
1502 } 1612 }
1503 1613
1504 String toString() => 'root=$rootLibrary,libraries=${_newLibraries}'; 1614 String toString() => 'root=$rootLibrary,libraries=${_newLibraries}';
1505 } 1615 }
1506 1616
1617 /// Adapter class to mimic the behavior of LoadedLibraries for Kernel element
1618 /// behavior. Ultimately we'll just access worldBuilder instead.
1619 class _LoadedLibrariesAdapter implements LoadedLibraries {
1620 final LibraryEntity rootLibrary;
1621 final List<LibraryEntity> _newLibraries;
1622 final KernelWorldBuilder worldBuilder;
1623
1624 _LoadedLibrariesAdapter(
1625 this.rootLibrary, this._newLibraries, this.worldBuilder) {
1626 assert(rootLibrary != null);
1627 }
1628
1629 bool containsLibrary(Uri uri) => getLibrary(uri) != null;
1630
1631 LibraryEntity getLibrary(Uri uri) => worldBuilder.lookupLibrary(uri);
1632
1633 void forEachLibrary(f(LibraryEntity library)) => _newLibraries.forEach(f);
1634
1635 void forEachImportChain(Uri uri,
1636 {bool callback(Link<Uri> importChainReversed)}) {
1637 // Currently a no-op. This seems wrong.
1638 }
1639
1640 String toString() => 'root=$rootLibrary,libraries=${_newLibraries}';
1641 }
1642
1507 // TODO(sigmund): remove ScriptLoader & ElementScanner. Such abstraction seems 1643 // TODO(sigmund): remove ScriptLoader & ElementScanner. Such abstraction seems
1508 // rather low-level. It might be more practical to split the library-loading 1644 // rather low-level. It might be more practical to split the library-loading
1509 // task itself. The task would continue to do the work of recursively loading 1645 // task itself. The task would continue to do the work of recursively loading
1510 // dependencies, but it can delegate to a set of subloaders how to do the actual 1646 // dependencies, but it can delegate to a set of subloaders how to do the actual
1511 // loading. We would then have a list of subloaders that use different 1647 // loading. We would then have a list of subloaders that use different
1512 // implementations: in-memory cache, deserialization, scanning from files. 1648 // implementations: in-memory cache, deserialization, scanning from files.
1513 // 1649 //
1514 // For example, the API might look like this: 1650 // For example, the API might look like this:
1515 // 1651 //
1516 // /// APIs to create [LibraryElement] and [CompilationUnitElements] given it's 1652 // /// APIs to create [LibraryElement] and [CompilationUnitElements] given it's
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 } 1686 }
1551 1687
1552 /// API used by the library loader to synchronously scan a library or 1688 /// API used by the library loader to synchronously scan a library or
1553 /// compilation unit and ensure that their library tags are computed. 1689 /// compilation unit and ensure that their library tags are computed.
1554 abstract class ElementScanner { 1690 abstract class ElementScanner {
1555 void scanLibrary(LibraryElement library); 1691 void scanLibrary(LibraryElement library);
1556 void scanUnit(CompilationUnitElement unit); 1692 void scanUnit(CompilationUnitElement unit);
1557 } 1693 }
1558 1694
1559 const _reuseLibrarySubtaskName = "Reuse library"; 1695 const _reuseLibrarySubtaskName = "Reuse library";
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698