Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1184)

Unified Diff: sdk/lib/_internal/compiler/implementation/deferred_load.dart

Issue 220203004: Improve the mirror support for deferred loading. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/deferred_load.dart
diff --git a/sdk/lib/_internal/compiler/implementation/deferred_load.dart b/sdk/lib/_internal/compiler/implementation/deferred_load.dart
index 298c7204bec55f56319c2b2e547f2051b9386842..8585c4825134d354927f55558c5f9eff19717d6f 100644
--- a/sdk/lib/_internal/compiler/implementation/deferred_load.dart
+++ b/sdk/lib/_internal/compiler/implementation/deferred_load.dart
@@ -303,7 +303,7 @@ class DeferredLoadTask extends CompilerTask {
void _collectAllElementsAndConstantsResolvedFrom(Element element,
Set<Element> elements,
Set<Constant> constants) {
- element = element.implementation;
+ // TODO(sigurdm): How is metadata on a patch-class handled?
for (MetadataAnnotation metadata in element.metadata) {
if (metadata.value != null) {
constants.add(metadata.value);
@@ -442,10 +442,26 @@ class DeferredLoadTask extends CompilerTask {
// things to the output units for the library.
List<MirrorUsage> mirrorUsages = mirrorsResult[library];
if (mirrorUsages == null) continue;
+
+ void mapDependenciesIfResolved(Element element) {
+ // If there is a target for this class, but no use of mirrors the
+ // class will not be resolved. We just skip it.
+ if (element is ClassElement &&
+ !(element as ClassElement).isResolved) {
+ return;
+ }
+ _mapDependencies(element, deferredImport);
+ }
+
for (MirrorUsage usage in mirrorUsages) {
if (usage.targets != null) {
for (Element dependency in usage.targets) {
- _mapDependencies(dependency, deferredImport);
+ if (dependency.isLibrary()) {
+ LibraryElement library = dependency;
+ library.forEachLocalMember(mapDependenciesIfResolved);
+ } else {
+ mapDependenciesIfResolved(dependency);
+ }
}
}
if (usage.metaTargets != null) {
@@ -484,10 +500,14 @@ class DeferredLoadTask extends CompilerTask {
}
}
if (usesMirrors) {
- for (Link link in compiler.enqueuer.allElementsByName.values) {
- for (Element dependency in link) {
- _mapDependencies(dependency, deferredImport);
- }
+ // Add all resolved elements to the output unit.
+ for (Element element in
+ compiler.enqueuer.resolution.resolvedElements.keys) {
+ _mapDependencies(element, deferredImport);
+ }
+ for (Element element in
+ compiler.mirrorDependencies.otherDependencies) {
+ _mapDependencies(element, deferredImport);
}
}
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | sdk/lib/_internal/compiler/implementation/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698