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:uri' | |
8 show Uri; | |
9 | |
10 import 'dart:collection' | 7 import 'dart:collection' |
11 show LinkedHashMap, | 8 show LinkedHashMap, |
12 LinkedHashSet; | 9 LinkedHashSet; |
13 | 10 |
14 import 'dart2jslib.dart' | 11 import 'dart2jslib.dart' |
15 show Compiler, | 12 show Compiler, |
16 CompilerTask, | 13 CompilerTask, |
17 ConstructedConstant, | 14 ConstructedConstant, |
18 MessageKind, | 15 MessageKind, |
19 SourceString, | 16 SourceString, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 55 |
59 /// DeferredLibrary from dart:async | 56 /// DeferredLibrary from dart:async |
60 ClassElement get deferredLibraryClass { | 57 ClassElement get deferredLibraryClass { |
61 if (cachedDeferredLibraryClass == null) { | 58 if (cachedDeferredLibraryClass == null) { |
62 cachedDeferredLibraryClass = findDeferredLibraryClass(); | 59 cachedDeferredLibraryClass = findDeferredLibraryClass(); |
63 } | 60 } |
64 return cachedDeferredLibraryClass; | 61 return cachedDeferredLibraryClass; |
65 } | 62 } |
66 | 63 |
67 ClassElement findDeferredLibraryClass() { | 64 ClassElement findDeferredLibraryClass() { |
68 var uri = new Uri.fromComponents(scheme: 'dart', path: 'async'); | 65 var uri = new Uri(scheme: 'dart', path: 'async'); |
69 LibraryElement asyncLibrary = | 66 LibraryElement asyncLibrary = |
70 compiler.libraryLoader.loadLibrary(uri, null, uri); | 67 compiler.libraryLoader.loadLibrary(uri, null, uri); |
71 var element = asyncLibrary.find(const SourceString('DeferredLibrary')); | 68 var element = asyncLibrary.find(const SourceString('DeferredLibrary')); |
72 if (element == null) { | 69 if (element == null) { |
73 compiler.internalErrorOnElement( | 70 compiler.internalErrorOnElement( |
74 asyncLibrary, | 71 asyncLibrary, |
75 'dart:async library does not contain required class: ' | 72 'dart:async library does not contain required class: ' |
76 'DeferredLibrary'); | 73 'DeferredLibrary'); |
77 } | 74 } |
78 return element; | 75 return element; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 TreeElements elements = | 256 TreeElements elements = |
260 compiler.enqueuer.resolution.getCachedElements(element); | 257 compiler.enqueuer.resolution.getCachedElements(element); |
261 if (elements == null) return new LinkedHashSet<Element>(); | 258 if (elements == null) return new LinkedHashSet<Element>(); |
262 Node node = element.parseNode(compiler); | 259 Node node = element.parseNode(compiler); |
263 var collector = new DependencyCollector(elements, compiler); | 260 var collector = new DependencyCollector(elements, compiler); |
264 node.accept(collector); | 261 node.accept(collector); |
265 collector.dependencies.addAll(elements.otherDependencies); | 262 collector.dependencies.addAll(elements.otherDependencies); |
266 return collector.dependencies; | 263 return collector.dependencies; |
267 } | 264 } |
268 } | 265 } |
OLD | NEW |