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

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..56d26b4c078bc172a13894361cfbd07ff47e9e53 100644
--- a/sdk/lib/_internal/compiler/implementation/deferred_load.dart
+++ b/sdk/lib/_internal/compiler/implementation/deferred_load.dart
@@ -26,7 +26,8 @@ import 'elements/elements.dart' show
MetadataAnnotation,
ScopeContainerElement,
PrefixElement,
- ClosureContainer;
+ ClosureContainer,
+ STATE_DONE;
import 'util/util.dart' show
Link;
@@ -303,6 +304,7 @@ class DeferredLoadTask extends CompilerTask {
void _collectAllElementsAndConstantsResolvedFrom(Element element,
Set<Element> elements,
Set<Constant> constants) {
+ // TODO(sigurdm): How is metadata on a patch-class handled?
element = element.implementation;
Johnni Winther 2014/04/01 13:20:00 Remove this line.
sigurdm 2014/04/01 13:57:44 Done.
for (MetadataAnnotation metadata in element.metadata) {
if (metadata.value != null) {
@@ -442,10 +444,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.isClass() &&
karlklose 2014/04/01 13:48:18 Consider using an is-test here, as you expect a su
sigurdm 2014/04/01 13:57:44 Done.
+ (element as ClassElement).resolutionState != STATE_DONE) {
Johnni Winther 2014/04/01 13:20:00 Use `!isResolved` instead of `resolutionState != S
sigurdm 2014/04/01 13:57:44 Done.
+ 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 +502,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);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698