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

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

Issue 1192103002: Support serialization of the compiler backbone. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Handle (bypass) external const constructors. Created 5 years, 5 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 'dart2jslib.dart' show 9 import 'dart2jslib.dart' show
10 Compiler, 10 Compiler,
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 */ 476 */
477 Future scanPart(Part part, Uri resolvedUri, LibraryElement library) { 477 Future scanPart(Part part, Uri resolvedUri, LibraryElement library) {
478 if (!resolvedUri.isAbsolute) throw new ArgumentError(resolvedUri); 478 if (!resolvedUri.isAbsolute) throw new ArgumentError(resolvedUri);
479 Uri readableUri = compiler.translateResolvedUri(library, resolvedUri, part); 479 Uri readableUri = compiler.translateResolvedUri(library, resolvedUri, part);
480 if (readableUri == null) return new Future.value(); 480 if (readableUri == null) return new Future.value();
481 return compiler.withCurrentElement(library, () { 481 return compiler.withCurrentElement(library, () {
482 return compiler.readScript(part, readableUri). 482 return compiler.readScript(part, readableUri).
483 then((Script sourceScript) { 483 then((Script sourceScript) {
484 if (sourceScript == null) return; 484 if (sourceScript == null) return;
485 485
486 CompilationUnitElement unit = 486 CompilationUnitElementX unit =
487 new CompilationUnitElementX(sourceScript, library); 487 new CompilationUnitElementX(sourceScript, library);
488 compiler.withCurrentElement(unit, () { 488 compiler.withCurrentElement(unit, () {
489 compiler.scanner.scan(unit); 489 compiler.scanner.scan(unit);
490 if (unit.partTag == null && !sourceScript.isSynthesized) { 490 if (unit.partTag == null && !sourceScript.isSynthesized) {
491 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG); 491 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG);
492 } 492 }
493 }); 493 });
494 }); 494 });
495 }); 495 });
496 } 496 }
(...skipping 20 matching lines...) Expand all
517 } 517 }
518 return createLibrary(handler, library, resolvedUri, tag.uri) 518 return createLibrary(handler, library, resolvedUri, tag.uri)
519 .then((LibraryElement loadedLibrary) { 519 .then((LibraryElement loadedLibrary) {
520 if (loadedLibrary == null) return; 520 if (loadedLibrary == null) return;
521 compiler.withCurrentElement(library, () { 521 compiler.withCurrentElement(library, () {
522 handler.registerDependency(library, tag, loadedLibrary); 522 handler.registerDependency(library, tag, loadedLibrary);
523 }); 523 });
524 }); 524 });
525 } 525 }
526 526
527 /// Loads the deserialized [library] with the [handler].
528 ///
529 /// All libraries imported or exported transitively from [library] will be
530 /// loaded as well.
531 Future<LibraryElement> loadDeserializedLibrary(
532 LibraryDependencyHandler handler,
533 LibraryElement library) async {
534 compiler.onLibraryCreated(library);
535 libraryCanonicalUriMap[library.canonicalUri] = library;
536 await compiler.onLibraryScanned(library, handler);
537 for (LibraryTag tag in library.tags) {
538 LibraryElement dependency = library.getLibraryFromTag(tag);
539 await createLibrary(handler, library, dependency.canonicalUri);
540 }
541 return library;
542 }
543
527 /** 544 /**
528 * Create (or reuse) a library element for the library specified by the 545 * Create (or reuse) a library element for the library specified by the
529 * [resolvedUri]. 546 * [resolvedUri].
530 * 547 *
531 * If a new library is created, the [handler] is notified. 548 * If a new library is created, the [handler] is notified.
532 */ 549 */
533 Future<LibraryElement> createLibrary(LibraryDependencyHandler handler, 550 Future<LibraryElement> createLibrary(LibraryDependencyHandler handler,
534 LibraryElement importingLibrary, 551 LibraryElement importingLibrary,
535 Uri resolvedUri, 552 Uri resolvedUri,
536 [Node node]) { 553 [Node node]) {
537 Uri readableUri = 554 Uri readableUri =
538 compiler.translateResolvedUri(importingLibrary, resolvedUri, node); 555 compiler.translateResolvedUri(importingLibrary, resolvedUri, node);
539 LibraryElement library = libraryCanonicalUriMap[resolvedUri]; 556 LibraryElement library = libraryCanonicalUriMap[resolvedUri];
540 if (library != null) { 557 if (library != null) {
541 return new Future.value(library); 558 return new Future.value(library);
542 } 559 }
560 library = compiler.serialization.readLibrary(resolvedUri);
561 if (library != null) {
562 return loadDeserializedLibrary(handler, library);
563 }
543 var readScript = compiler.readScript; 564 var readScript = compiler.readScript;
544 if (readableUri == null) { 565 if (readableUri == null) {
545 readableUri = resolvedUri; 566 readableUri = resolvedUri;
546 readScript = compiler.synthesizeScript; 567 readScript = compiler.synthesizeScript;
547 } 568 }
548 return compiler.withCurrentElement(importingLibrary, () { 569 return compiler.withCurrentElement(importingLibrary, () {
549 return readScript(node, readableUri).then((Script script) { 570 return readScript(node, readableUri).then((Script script) {
550 if (script == null) return null; 571 if (script == null) return null;
551 LibraryElement element = 572 LibraryElement element =
552 createLibrarySync(handler, script, resolvedUri); 573 createLibrarySync(handler, script, resolvedUri);
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 } 1216 }
1196 suffixes.add(const Link<Uri>().prepend(canonicalUri)); 1217 suffixes.add(const Link<Uri>().prepend(canonicalUri));
1197 } 1218 }
1198 suffixChainMap[library] = suffixes; 1219 suffixChainMap[library] = suffixes;
1199 return; 1220 return;
1200 } 1221 }
1201 1222
1202 computeSuffixes(rootLibrary, const Link<Uri>()); 1223 computeSuffixes(rootLibrary, const Link<Uri>());
1203 } 1224 }
1204 } 1225 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/mirrors/dart2js_library_mirror.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698