| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 'dart:collection' | 7 import 'dart:collection' |
| 8 show LinkedHashMap, | 8 show LinkedHashMap, |
| 9 LinkedHashSet; | 9 LinkedHashSet; |
| 10 | 10 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 if (closure.contains(current)) continue; | 187 if (closure.contains(current)) continue; |
| 188 workSet.addAll(allElementsResolvedFrom(current)); | 188 workSet.addAll(allElementsResolvedFrom(current)); |
| 189 closure.add(current); | 189 closure.add(current); |
| 190 } | 190 } |
| 191 elements.addAll(closure); | 191 elements.addAll(closure); |
| 192 } | 192 } |
| 193 | 193 |
| 194 Link<LibraryElement> findDeferredLibraries(LibraryElement library) { | 194 Link<LibraryElement> findDeferredLibraries(LibraryElement library) { |
| 195 Link<LibraryElement> link = const Link<LibraryElement>(); | 195 Link<LibraryElement> link = const Link<LibraryElement>(); |
| 196 for (LibraryTag tag in library.tags) { | 196 for (LibraryTag tag in library.tags) { |
| 197 // TODO(ahe): This iterates over parts and exports as well, but should |
| 198 // only iterate over imports. |
| 197 Link<MetadataAnnotation> metadata = tag.metadata; | 199 Link<MetadataAnnotation> metadata = tag.metadata; |
| 198 if (metadata == null) continue; | 200 if (metadata == null) continue; |
| 199 for (MetadataAnnotation metadata in tag.metadata) { | 201 for (MetadataAnnotation metadata in tag.metadata) { |
| 200 metadata.ensureResolved(compiler); | 202 metadata.ensureResolved(compiler); |
| 201 Element element = metadata.value.computeType(compiler).element; | 203 Element element = metadata.value.computeType(compiler).element; |
| 202 if (element == deferredLibraryClass) { | 204 if (element == deferredLibraryClass) { |
| 203 ConstructedConstant value = metadata.value; | 205 ConstructedConstant value = metadata.value; |
| 204 StringConstant nameField = value.fields[0]; | 206 StringConstant nameField = value.fields[0]; |
| 205 SourceString expectedName = nameField.toDartString().source; | 207 SourceString expectedName = nameField.toDartString().source; |
| 206 LibraryElement deferredLibrary = library.getLibraryFromTag(tag); | 208 LibraryElement deferredLibrary = library.getLibraryFromTag(tag); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 compiler.enqueuer.resolution.getCachedElements(element); | 242 compiler.enqueuer.resolution.getCachedElements(element); |
| 241 if (elements == null) return new LinkedHashSet<Element>(); | 243 if (elements == null) return new LinkedHashSet<Element>(); |
| 242 Node node = element.parseNode(compiler); | 244 Node node = element.parseNode(compiler); |
| 243 if (node == null) return new LinkedHashSet<Element>(); | 245 if (node == null) return new LinkedHashSet<Element>(); |
| 244 var collector = new DependencyCollector(elements, compiler); | 246 var collector = new DependencyCollector(elements, compiler); |
| 245 node.accept(collector); | 247 node.accept(collector); |
| 246 collector.dependencies.addAll(elements.otherDependencies); | 248 collector.dependencies.addAll(elements.otherDependencies); |
| 247 return collector.dependencies; | 249 return collector.dependencies; |
| 248 } | 250 } |
| 249 } | 251 } |
| OLD | NEW |