OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 deferred_load; | 5 library deferred_load; |
6 | 6 |
7 import 'dart2jslib.dart' show | 7 import 'dart2jslib.dart' show |
8 Backend, | 8 Backend, |
9 Compiler, | 9 Compiler, |
10 CompilerTask, | 10 CompilerTask, |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 // import "lib2.dart" deferred as a; | 679 // import "lib2.dart" deferred as a; |
680 // 4. | 680 // 4. |
681 // import "lib.dart" as a; | 681 // import "lib.dart" as a; |
682 // import "lib2.dart" as a; | 682 // import "lib2.dart" as a; |
683 // We must be able to signal error for case 1, 2, 3, but accept case 4. | 683 // We must be able to signal error for case 1, 2, 3, but accept case 4. |
684 | 684 |
685 // The prefixes that have been used by any imports in this library. | 685 // The prefixes that have been used by any imports in this library. |
686 Setlet<String> usedPrefixes = new Setlet<String>(); | 686 Setlet<String> usedPrefixes = new Setlet<String>(); |
687 // The last deferred import we saw with a given prefix (if any). | 687 // The last deferred import we saw with a given prefix (if any). |
688 Map<String, Import> prefixDeferredImport = new Map<String, Import>(); | 688 Map<String, Import> prefixDeferredImport = new Map<String, Import>(); |
689 for (LibraryElement library in compiler.libraries.values) { | 689 for (LibraryElement library in compiler.libraryLoader.libraries) { |
690 compiler.withCurrentElement(library, () { | 690 compiler.withCurrentElement(library, () { |
691 prefixDeferredImport.clear(); | 691 prefixDeferredImport.clear(); |
692 usedPrefixes.clear(); | 692 usedPrefixes.clear(); |
693 // TODO(sigurdm): Make helper getLibraryImportTags when tags is a List | 693 // TODO(sigurdm): Make helper getLibraryImportTags when tags is a List |
694 // instead of a Link. | 694 // instead of a Link. |
695 for (LibraryTag tag in library.tags) { | 695 for (LibraryTag tag in library.tags) { |
696 if (tag is! Import) continue; | 696 if (tag is! Import) continue; |
697 Import import = tag; | 697 Import import = tag; |
698 _markIfDeferred(import, library); | 698 _markIfDeferred(import, library); |
699 String prefix = (import.prefix != null) | 699 String prefix = (import.prefix != null) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 Element maybePrefix = elements[identifier]; | 788 Element maybePrefix = elements[identifier]; |
789 if (maybePrefix != null && maybePrefix.isPrefix) { | 789 if (maybePrefix != null && maybePrefix.isPrefix) { |
790 PrefixElement prefixElement = maybePrefix; | 790 PrefixElement prefixElement = maybePrefix; |
791 if (prefixElement.isDeferred) { | 791 if (prefixElement.isDeferred) { |
792 return prefixElement; | 792 return prefixElement; |
793 } | 793 } |
794 } | 794 } |
795 return null; | 795 return null; |
796 } | 796 } |
797 } | 797 } |
OLD | NEW |