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 import 'dart2jslib.dart' | 8 import 'dart2jslib.dart' |
9 show Compiler, | 9 show Compiler, |
10 CompilerTask, | 10 CompilerTask, |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 // TODO(johnniwinther): Create erroneous library elements for missing | 491 // TODO(johnniwinther): Create erroneous library elements for missing |
492 // libraries. | 492 // libraries. |
493 Uri readableUri = | 493 Uri readableUri = |
494 compiler.translateResolvedUri(importingLibrary, resolvedUri, node); | 494 compiler.translateResolvedUri(importingLibrary, resolvedUri, node); |
495 if (readableUri == null) return new Future.value(); | 495 if (readableUri == null) return new Future.value(); |
496 LibraryElement library = libraryCanonicalUriMap[resolvedUri]; | 496 LibraryElement library = libraryCanonicalUriMap[resolvedUri]; |
497 if (library != null) { | 497 if (library != null) { |
498 return new Future.value(library); | 498 return new Future.value(library); |
499 } | 499 } |
500 return compiler.withCurrentElement(importingLibrary, () { | 500 return compiler.withCurrentElement(importingLibrary, () { |
501 return compiler.readScript(node, readableUri) | 501 return compiler.readScript(node, readableUri).then((Script script) { |
502 .then((Script script) { | 502 if (script == null) return null; |
503 if (script == null) return null; | 503 LibraryElement element = |
504 LibraryElement element = new LibraryElementX(script, resolvedUri); | 504 createLibrarySync(handler, script, resolvedUri); |
505 compiler.withCurrentElement(element, () { | |
506 handler.registerNewLibrary(element); | |
507 native.maybeEnableNative(compiler, element); | |
508 libraryCanonicalUriMap[resolvedUri] = element; | |
509 compiler.scanner.scanLibrary(element); | |
510 }); | |
511 return processLibraryTags(handler, element).then((_) { | 505 return processLibraryTags(handler, element).then((_) { |
Johnni Winther
2014/08/26 12:31:03
This should be de-indented.
ahe
2014/08/26 13:01:33
Done.
| |
512 compiler.withCurrentElement(element, () { | 506 compiler.withCurrentElement(element, () { |
513 handler.registerLibraryExports(element); | 507 handler.registerLibraryExports(element); |
514 }); | 508 }); |
515 return element; | 509 return element; |
516 }); | 510 }); |
517 }); | 511 |
512 }); | |
513 }); | |
514 } | |
515 | |
516 LibraryElement createLibrarySync( | |
517 LibraryDependencyHandler handler, | |
518 Script script, | |
519 Uri resolvedUri) { | |
520 LibraryElement element = new LibraryElementX(script, resolvedUri); | |
521 return compiler.withCurrentElement(element, () { | |
522 if (handler != null) { | |
523 handler.registerNewLibrary(element); | |
524 libraryCanonicalUriMap[resolvedUri] = element; | |
525 } | |
526 native.maybeEnableNative(compiler, element); | |
527 compiler.scanner.scanLibrary(element); | |
528 return element; | |
518 }); | 529 }); |
519 } | 530 } |
520 } | 531 } |
521 | 532 |
522 | 533 |
523 /** | 534 /** |
524 * The fields of this class models a state machine for checking script | 535 * The fields of this class models a state machine for checking script |
525 * tags come in the correct order. | 536 * tags come in the correct order. |
526 */ | 537 */ |
527 class TagState { | 538 class TagState { |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
955 * fixed-point computation of the import/export scopes. | 966 * fixed-point computation of the import/export scopes. |
956 */ | 967 */ |
957 void registerLibraryExports(LibraryElement library) { | 968 void registerLibraryExports(LibraryElement library) { |
958 nodeMap[library].registerInitialExports(); | 969 nodeMap[library].registerInitialExports(); |
959 } | 970 } |
960 | 971 |
961 Future processLibraryTags(LibraryElement library) { | 972 Future processLibraryTags(LibraryElement library) { |
962 return task.processLibraryTags(this, library); | 973 return task.processLibraryTags(this, library); |
963 } | 974 } |
964 } | 975 } |
OLD | NEW |