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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/library_loader.dart

Issue 23258002: Load builtin helper libraries on demand. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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 part of dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * [CompilerTask] for loading libraries and setting up the import/export scopes. 8 * [CompilerTask] for loading libraries and setting up the import/export scopes.
9 * 9 *
10 * The library loader uses four different kinds of URIs in different parts of 10 * The library loader uses four different kinds of URIs in different parts of
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 213 }
214 214
215 /** 215 /**
216 * Implementation class for [LibraryLoader]. The distinction between 216 * Implementation class for [LibraryLoader]. The distinction between
217 * [LibraryLoader] and [LibraryLoaderTask] is made to hide internal members from 217 * [LibraryLoader] and [LibraryLoaderTask] is made to hide internal members from
218 * the [LibraryLoader] interface. 218 * the [LibraryLoader] interface.
219 */ 219 */
220 class LibraryLoaderTask extends LibraryLoader { 220 class LibraryLoaderTask extends LibraryLoader {
221 LibraryLoaderTask(Compiler compiler) : super(compiler); 221 LibraryLoaderTask(Compiler compiler) : super(compiler);
222 String get name => 'LibraryLoader'; 222 String get name => 'LibraryLoader';
223 List onLibraryLoadedCallbacks = [];
223 224
224 final Map<String, LibraryElement> libraryNames = 225 final Map<String, LibraryElement> libraryNames =
225 new LinkedHashMap<String, LibraryElement>(); 226 new LinkedHashMap<String, LibraryElement>();
226 227
227 LibraryDependencyHandler currentHandler; 228 LibraryDependencyHandler currentHandler;
228 229
229 LibraryElement loadLibrary(Uri resolvedUri, Node node, Uri canonicalUri) { 230 LibraryElement loadLibrary(Uri resolvedUri, Node node, Uri canonicalUri) {
230 return measure(() { 231 return measure(() {
231 assert(currentHandler == null); 232 assert(currentHandler == null);
232 currentHandler = new LibraryDependencyHandler(compiler); 233 currentHandler = new LibraryDependencyHandler(compiler);
233 LibraryElement library = 234 LibraryElement library =
234 createLibrary(currentHandler, null, resolvedUri, node, canonicalUri); 235 createLibrary(currentHandler, null, resolvedUri, node, canonicalUri);
235 currentHandler.computeExports(); 236 currentHandler.computeExports();
236 currentHandler = null; 237 currentHandler = null;
238 var workList = onLibraryLoadedCallbacks;
239 onLibraryLoadedCallbacks = [];
240 workList.forEach((f) => f());
237 return library; 241 return library;
238 }); 242 });
239 } 243 }
240 244
241 /** 245 /**
242 * Processes the library tags in [library]. 246 * Processes the library tags in [library].
243 * 247 *
244 * The imported/exported libraries are loaded and processed recursively but 248 * The imported/exported libraries are loaded and processed recursively but
245 * the import/export scopes are not set up. 249 * the import/export scopes are not set up.
246 */ 250 */
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 library = createLibrary(); 430 library = createLibrary();
427 } else { 431 } else {
428 library = compiler.libraries.putIfAbsent(canonicalUri.toString(), 432 library = compiler.libraries.putIfAbsent(canonicalUri.toString(),
429 createLibrary); 433 createLibrary);
430 } 434 }
431 if (newLibrary) { 435 if (newLibrary) {
432 compiler.withCurrentElement(library, () { 436 compiler.withCurrentElement(library, () {
433 compiler.scanner.scanLibrary(library); 437 compiler.scanner.scanLibrary(library);
434 processLibraryTags(handler, library); 438 processLibraryTags(handler, library);
435 handler.registerLibraryExports(library); 439 handler.registerLibraryExports(library);
436 compiler.onLibraryScanned(library, resolvedUri); 440 onLibraryLoadedCallbacks.add(
441 () => compiler.onLibraryLoaded(library, resolvedUri));
437 }); 442 });
438 } 443 }
439 return library; 444 return library;
440 } 445 }
441 446
442 // TODO(johnniwinther): Remove this method when 'js_helper' is handled by 447 // TODO(johnniwinther): Remove this method when 'js_helper' is handled by
443 // [LibraryLoaderTask]. 448 // [LibraryLoaderTask].
444 void importLibrary(LibraryElement importingLibrary, 449 void importLibrary(LibraryElement importingLibrary,
445 LibraryElement importedLibrary, 450 LibraryElement importedLibrary,
446 Import tag) { 451 Import tag) {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 } 834 }
830 835
831 /** 836 /**
832 * Registers all top-level entities of [library] as starting point for the 837 * Registers all top-level entities of [library] as starting point for the
833 * fixed-point computation of the import/export scopes. 838 * fixed-point computation of the import/export scopes.
834 */ 839 */
835 void registerLibraryExports(LibraryElement library) { 840 void registerLibraryExports(LibraryElement library) {
836 nodeMap[library].registerInitialExports(); 841 nodeMap[library].registerInitialExports();
837 } 842 }
838 } 843 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698