| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * [CompilerTask] for loading libraries and setting up the import/export scopes. | 8 * [CompilerTask] for loading libraries and setting up the import/export scopes. |
| 9 * | 9 * |
| 10 * The library loader uses four different kinds of URIs in different parts of | 10 * The library loader uses four different kinds of URIs in different parts of |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 * Implementation class for [LibraryLoader]. The distinction between | 217 * Implementation class for [LibraryLoader]. The distinction between |
| 218 * [LibraryLoader] and [LibraryLoaderTask] is made to hide internal members from | 218 * [LibraryLoader] and [LibraryLoaderTask] is made to hide internal members from |
| 219 * the [LibraryLoader] interface. | 219 * the [LibraryLoader] interface. |
| 220 */ | 220 */ |
| 221 class LibraryLoaderTask extends LibraryLoader { | 221 class LibraryLoaderTask extends LibraryLoader { |
| 222 LibraryLoaderTask(Compiler compiler) : super(compiler); | 222 LibraryLoaderTask(Compiler compiler) : super(compiler); |
| 223 String get name => 'LibraryLoader'; | 223 String get name => 'LibraryLoader'; |
| 224 List onLibraryLoadedCallbacks = []; | 224 List onLibraryLoadedCallbacks = []; |
| 225 | 225 |
| 226 final Map<String, LibraryElement> libraryNames = | 226 final Map<String, LibraryElement> libraryNames = |
| 227 new LinkedHashMap<String, LibraryElement>(); | 227 new Map<String, LibraryElement>(); |
| 228 | 228 |
| 229 LibraryDependencyHandler currentHandler; | 229 LibraryDependencyHandler currentHandler; |
| 230 | 230 |
| 231 Future<LibraryElement> loadLibrary(Uri resolvedUri, Node node, | 231 Future<LibraryElement> loadLibrary(Uri resolvedUri, Node node, |
| 232 Uri canonicalUri) { | 232 Uri canonicalUri) { |
| 233 return measure(() { | 233 return measure(() { |
| 234 assert(currentHandler == null); | 234 assert(currentHandler == null); |
| 235 // TODO(johnniwinther): Ensure that currentHandler correctly encloses the | 235 // TODO(johnniwinther): Ensure that currentHandler correctly encloses the |
| 236 // loading of a library cluster. | 236 // loading of a library cluster. |
| 237 currentHandler = new LibraryDependencyHandler(compiler); | 237 currentHandler = new LibraryDependencyHandler(compiler); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 * A linked list of the export tags the dependent upon this node library. | 597 * A linked list of the export tags the dependent upon this node library. |
| 598 * This is used to propagate exports during the computation of export scopes. | 598 * This is used to propagate exports during the computation of export scopes. |
| 599 */ | 599 */ |
| 600 Link<ExportLink> dependencies = const Link<ExportLink>(); | 600 Link<ExportLink> dependencies = const Link<ExportLink>(); |
| 601 | 601 |
| 602 /** | 602 /** |
| 603 * The export scope for [library] which is gradually computed by the work-list | 603 * The export scope for [library] which is gradually computed by the work-list |
| 604 * computation in [LibraryDependencyHandler.computeExports]. | 604 * computation in [LibraryDependencyHandler.computeExports]. |
| 605 */ | 605 */ |
| 606 Map<SourceString, Element> exportScope = | 606 Map<SourceString, Element> exportScope = |
| 607 new LinkedHashMap<SourceString, Element>(); | 607 new Map<SourceString, Element>(); |
| 608 | 608 |
| 609 /// Map from exported elements to the export directives that exported them. | 609 /// Map from exported elements to the export directives that exported them. |
| 610 Map<Element, Link<Export>> exporters = new Map<Element, Link<Export>>(); | 610 Map<Element, Link<Export>> exporters = new Map<Element, Link<Export>>(); |
| 611 | 611 |
| 612 /** | 612 /** |
| 613 * The set of exported elements that need to be propageted to dependent | 613 * The set of exported elements that need to be propageted to dependent |
| 614 * libraries as part of the work-list computation performed in | 614 * libraries as part of the work-list computation performed in |
| 615 * [LibraryDependencyHandler.computeExports]. Each export element is mapped | 615 * [LibraryDependencyHandler.computeExports]. Each export element is mapped |
| 616 * to a list of exports directives that export it. | 616 * to a list of exports directives that export it. |
| 617 */ | 617 */ |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 class LibraryDependencyHandler { | 800 class LibraryDependencyHandler { |
| 801 final Compiler compiler; | 801 final Compiler compiler; |
| 802 | 802 |
| 803 /** | 803 /** |
| 804 * Newly loaded libraries and their corresponding node in the library | 804 * Newly loaded libraries and their corresponding node in the library |
| 805 * dependency graph. Libraries that have already been fully loaded are not | 805 * dependency graph. Libraries that have already been fully loaded are not |
| 806 * part of the dependency graph of this handler since their export scopes have | 806 * part of the dependency graph of this handler since their export scopes have |
| 807 * already been computed. | 807 * already been computed. |
| 808 */ | 808 */ |
| 809 Map<LibraryElement,LibraryDependencyNode> nodeMap = | 809 Map<LibraryElement,LibraryDependencyNode> nodeMap = |
| 810 new LinkedHashMap<LibraryElement,LibraryDependencyNode>(); | 810 new Map<LibraryElement,LibraryDependencyNode>(); |
| 811 | 811 |
| 812 LibraryDependencyHandler(Compiler this.compiler); | 812 LibraryDependencyHandler(Compiler this.compiler); |
| 813 | 813 |
| 814 /** | 814 /** |
| 815 * Performs a fixed-point computation on the export scopes of all registered | 815 * Performs a fixed-point computation on the export scopes of all registered |
| 816 * libraries and creates the import/export of the libraries based on the | 816 * libraries and creates the import/export of the libraries based on the |
| 817 * fixed-point. | 817 * fixed-point. |
| 818 */ | 818 */ |
| 819 void computeExports() { | 819 void computeExports() { |
| 820 bool changed = true; | 820 bool changed = true; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 } | 898 } |
| 899 | 899 |
| 900 /** | 900 /** |
| 901 * Registers all top-level entities of [library] as starting point for the | 901 * Registers all top-level entities of [library] as starting point for the |
| 902 * fixed-point computation of the import/export scopes. | 902 * fixed-point computation of the import/export scopes. |
| 903 */ | 903 */ |
| 904 void registerLibraryExports(LibraryElement library) { | 904 void registerLibraryExports(LibraryElement library) { |
| 905 nodeMap[library].registerInitialExports(); | 905 nodeMap[library].registerInitialExports(); |
| 906 } | 906 } |
| 907 } | 907 } |
| OLD | NEW |