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

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: Created 5 years, 6 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 */ 475 */
476 Future scanPart(Part part, Uri resolvedUri, LibraryElement library) { 476 Future scanPart(Part part, Uri resolvedUri, LibraryElement library) {
477 if (!resolvedUri.isAbsolute) throw new ArgumentError(resolvedUri); 477 if (!resolvedUri.isAbsolute) throw new ArgumentError(resolvedUri);
478 Uri readableUri = compiler.translateResolvedUri(library, resolvedUri, part); 478 Uri readableUri = compiler.translateResolvedUri(library, resolvedUri, part);
479 if (readableUri == null) return new Future.value(); 479 if (readableUri == null) return new Future.value();
480 return compiler.withCurrentElement(library, () { 480 return compiler.withCurrentElement(library, () {
481 return compiler.readScript(part, readableUri). 481 return compiler.readScript(part, readableUri).
482 then((Script sourceScript) { 482 then((Script sourceScript) {
483 if (sourceScript == null) return; 483 if (sourceScript == null) return;
484 484
485 CompilationUnitElement unit = 485 CompilationUnitElementX unit =
486 new CompilationUnitElementX(sourceScript, library); 486 new CompilationUnitElementX(sourceScript, library);
487 compiler.withCurrentElement(unit, () { 487 compiler.withCurrentElement(unit, () {
488 compiler.scanner.scan(unit); 488 compiler.scanner.scan(unit);
489 if (unit.partTag == null && !sourceScript.isSynthesized) { 489 if (unit.partTag == null && !sourceScript.isSynthesized) {
490 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG); 490 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG);
491 } 491 }
492 }); 492 });
493 }); 493 });
494 }); 494 });
495 } 495 }
(...skipping 20 matching lines...) Expand all
516 } 516 }
517 return createLibrary(handler, library, resolvedUri, tag.uri) 517 return createLibrary(handler, library, resolvedUri, tag.uri)
518 .then((LibraryElement loadedLibrary) { 518 .then((LibraryElement loadedLibrary) {
519 if (loadedLibrary == null) return; 519 if (loadedLibrary == null) return;
520 compiler.withCurrentElement(library, () { 520 compiler.withCurrentElement(library, () {
521 handler.registerDependency(library, tag, loadedLibrary); 521 handler.registerDependency(library, tag, loadedLibrary);
522 }); 522 });
523 }); 523 });
524 } 524 }
525 525
526 Future<LibraryElement> readLibrary(LibraryDependencyHandler handler,
527 Uri resolvedUri,
528 LibraryElement library) async {
529 compiler.onLibraryCreated(library);
530 libraryCanonicalUriMap[resolvedUri] = library;
531 await compiler.onLibraryScanned(library, handler);
532 for (LibraryTag tag in library.tags) {
533 LibraryElement dependency = library.getLibraryFromTag(tag);
534 await createLibrary(handler, library, dependency.canonicalUri);
535 }
536 return library;
537 }
538
526 /** 539 /**
527 * Create (or reuse) a library element for the library specified by the 540 * Create (or reuse) a library element for the library specified by the
528 * [resolvedUri]. 541 * [resolvedUri].
529 * 542 *
530 * If a new library is created, the [handler] is notified. 543 * If a new library is created, the [handler] is notified.
531 */ 544 */
532 Future<LibraryElement> createLibrary(LibraryDependencyHandler handler, 545 Future<LibraryElement> createLibrary(LibraryDependencyHandler handler,
533 LibraryElement importingLibrary, 546 LibraryElement importingLibrary,
534 Uri resolvedUri, 547 Uri resolvedUri,
535 [Node node]) { 548 [Node node]) {
536 Uri readableUri = 549 Uri readableUri =
537 compiler.translateResolvedUri(importingLibrary, resolvedUri, node); 550 compiler.translateResolvedUri(importingLibrary, resolvedUri, node);
538 LibraryElement library = libraryCanonicalUriMap[resolvedUri]; 551 LibraryElement library = libraryCanonicalUriMap[resolvedUri];
539 if (library != null) { 552 if (library != null) {
540 return new Future.value(library); 553 return new Future.value(library);
541 } 554 }
555 library = compiler.serialization.readLibrary(resolvedUri);
floitsch 2015/06/26 20:54:04 This is confusing: we have two readLibrary, but th
Johnni Winther 2015/07/03 12:13:44 Done.
556 if (library != null) {
557 return readLibrary(handler, resolvedUri, library);
558 }
542 var readScript = compiler.readScript; 559 var readScript = compiler.readScript;
543 if (readableUri == null) { 560 if (readableUri == null) {
544 readableUri = resolvedUri; 561 readableUri = resolvedUri;
545 readScript = compiler.synthesizeScript; 562 readScript = compiler.synthesizeScript;
546 } 563 }
547 return compiler.withCurrentElement(importingLibrary, () { 564 return compiler.withCurrentElement(importingLibrary, () {
548 return readScript(node, readableUri).then((Script script) { 565 return readScript(node, readableUri).then((Script script) {
549 if (script == null) return null; 566 if (script == null) return null;
550 LibraryElement element = 567 LibraryElement element =
551 createLibrarySync(handler, script, resolvedUri); 568 createLibrarySync(handler, script, resolvedUri);
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 } 1211 }
1195 suffixes.add(const Link<Uri>().prepend(canonicalUri)); 1212 suffixes.add(const Link<Uri>().prepend(canonicalUri));
1196 } 1213 }
1197 suffixChainMap[library] = suffixes; 1214 suffixChainMap[library] = suffixes;
1198 return; 1215 return;
1199 } 1216 }
1200 1217
1201 computeSuffixes(rootLibrary, const Link<Uri>()); 1218 computeSuffixes(rootLibrary, const Link<Uri>());
1202 } 1219 }
1203 } 1220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698