| 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 'dart2jslib.dart' show | 9 import 'dart2jslib.dart' show |
| 10 Compiler, | 10 Compiler, |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 if (readableUri == null) return new Future.value(); | 481 if (readableUri == null) return new Future.value(); |
| 482 return compiler.withCurrentElement(library, () { | 482 return compiler.withCurrentElement(library, () { |
| 483 return compiler.readScript(part, readableUri). | 483 return compiler.readScript(part, readableUri). |
| 484 then((Script sourceScript) { | 484 then((Script sourceScript) { |
| 485 if (sourceScript == null) return; | 485 if (sourceScript == null) return; |
| 486 | 486 |
| 487 CompilationUnitElement unit = | 487 CompilationUnitElement unit = |
| 488 new CompilationUnitElementX(sourceScript, library); | 488 new CompilationUnitElementX(sourceScript, library); |
| 489 compiler.withCurrentElement(unit, () { | 489 compiler.withCurrentElement(unit, () { |
| 490 compiler.scanner.scan(unit); | 490 compiler.scanner.scan(unit); |
| 491 if (unit.partTag == null) { | 491 if (unit.partTag == null && !sourceScript.isSynthesized) { |
| 492 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG); | 492 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG); |
| 493 } | 493 } |
| 494 }); | 494 }); |
| 495 }); | 495 }); |
| 496 }); | 496 }); |
| 497 } | 497 } |
| 498 | 498 |
| 499 /** | 499 /** |
| 500 * Handle an import/export tag by loading the referenced library and | 500 * Handle an import/export tag by loading the referenced library and |
| 501 * registering its dependency in [handler] for the computation of the import/ | 501 * registering its dependency in [handler] for the computation of the import/ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 518 /** | 518 /** |
| 519 * Create (or reuse) a library element for the library specified by the | 519 * Create (or reuse) a library element for the library specified by the |
| 520 * [resolvedUri]. | 520 * [resolvedUri]. |
| 521 * | 521 * |
| 522 * If a new library is created, the [handler] is notified. | 522 * If a new library is created, the [handler] is notified. |
| 523 */ | 523 */ |
| 524 Future<LibraryElement> createLibrary(LibraryDependencyHandler handler, | 524 Future<LibraryElement> createLibrary(LibraryDependencyHandler handler, |
| 525 LibraryElement importingLibrary, | 525 LibraryElement importingLibrary, |
| 526 Uri resolvedUri, | 526 Uri resolvedUri, |
| 527 [Node node]) { | 527 [Node node]) { |
| 528 // TODO(johnniwinther): Create erroneous library elements for missing | |
| 529 // libraries. | |
| 530 Uri readableUri = | 528 Uri readableUri = |
| 531 compiler.translateResolvedUri(importingLibrary, resolvedUri, node); | 529 compiler.translateResolvedUri(importingLibrary, resolvedUri, node); |
| 532 if (readableUri == null) return new Future.value(); | |
| 533 LibraryElement library = libraryCanonicalUriMap[resolvedUri]; | 530 LibraryElement library = libraryCanonicalUriMap[resolvedUri]; |
| 534 if (library != null) { | 531 if (library != null) { |
| 535 return new Future.value(library); | 532 return new Future.value(library); |
| 536 } | 533 } |
| 534 var readScript = compiler.readScript; |
| 535 if (readableUri == null) { |
| 536 readableUri = resolvedUri; |
| 537 readScript = compiler.synthesizeScript; |
| 538 } |
| 537 return compiler.withCurrentElement(importingLibrary, () { | 539 return compiler.withCurrentElement(importingLibrary, () { |
| 538 return compiler.readScript(node, readableUri).then((Script script) { | 540 return readScript(node, readableUri).then((Script script) { |
| 539 if (script == null) return null; | 541 if (script == null) return null; |
| 540 LibraryElement element = | 542 LibraryElement element = |
| 541 createLibrarySync(handler, script, resolvedUri); | 543 createLibrarySync(handler, script, resolvedUri); |
| 542 return processLibraryTags(handler, element).then((_) { | 544 return processLibraryTags(handler, element).then((_) { |
| 543 compiler.withCurrentElement(element, () { | 545 compiler.withCurrentElement(element, () { |
| 544 handler.registerLibraryExports(element); | 546 handler.registerLibraryExports(element); |
| 545 }); | 547 }); |
| 546 return element; | 548 return element; |
| 547 }); | 549 }); |
| 548 }); | 550 }); |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 } | 1186 } |
| 1185 suffixes.add(const Link<Uri>().prepend(canonicalUri)); | 1187 suffixes.add(const Link<Uri>().prepend(canonicalUri)); |
| 1186 } | 1188 } |
| 1187 suffixChainMap[library] = suffixes; | 1189 suffixChainMap[library] = suffixes; |
| 1188 return; | 1190 return; |
| 1189 } | 1191 } |
| 1190 | 1192 |
| 1191 computeSuffixes(rootLibrary, const Link<Uri>()); | 1193 computeSuffixes(rootLibrary, const Link<Uri>()); |
| 1192 } | 1194 } |
| 1193 } | 1195 } |
| OLD | NEW |