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

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

Issue 16101007: Implement LibraryMirror.metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix issues found during testing. Created 7 years, 7 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: dart/sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/compiler.dart b/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
index f14543f3dcae2b23c108967dfbc57f81277b579e..a83f00b0ff86137500ef4063b3cd1a0f71d801c6 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -643,6 +643,7 @@ abstract class Compiler implements DiagnosticListener {
}
if (uri == Uri.parse('dart:mirrors')) {
mirrorSystemClass = library.find(const SourceString('MirrorSystem'));
+ metadataHandler = constantHandler;
} else if (uri == Uri.parse('dart:_collection-dev')) {
symbolImplementationClass = library.find(const SourceString('Symbol'));
}
@@ -822,6 +823,7 @@ abstract class Compiler implements DiagnosticListener {
// Elements required by enqueueHelpers are global dependencies
// that are not pulled in by a particular element.
backend.enqueueHelpers(enqueuer.resolution, globalDependencies);
+ resolveReflectiveDataIfNeeded();
processQueue(enqueuer.resolution, main);
enqueuer.resolution.logSummary(log);
@@ -864,6 +866,17 @@ abstract class Compiler implements DiagnosticListener {
checkQueues();
}
+ void resolveReflectiveDataIfNeeded() {
+ // Only need reflective data when dart:mirrors is loaded.
+ if (mirrorSystemClass == null) return;
+
+ for (LibraryElement library in libraries.values) {
+ for (Link link = library.metadata; !link.isEmpty; link = link.tail) {
+ link.head.ensureResolved(this);
+ }
+ }
+ }
+
void fullyEnqueueLibrary(LibraryElement library) {
library.forEachLocalMember(fullyEnqueueTopLevelElement);
}
@@ -948,7 +961,8 @@ abstract class Compiler implements DiagnosticListener {
TreeElements analyzeElement(Element element) {
assert(invariant(element, element.isDeclaration));
assert(!element.isForwardingConstructor);
- TreeElements elements = enqueuer.resolution.getCachedElements(element);
+ ResolutionEnqueuer world = enqueuer.resolution;
+ TreeElements elements = world.getCachedElements(element);
if (elements != null) return elements;
assert(parser != null);
Node tree = parser.parse(element);
@@ -958,6 +972,7 @@ abstract class Compiler implements DiagnosticListener {
// Only analyze nodes with a corresponding [TreeElements].
checker.check(tree, elements);
}
+ world.resolvedElements[element] = elements;
return elements;
}
@@ -978,8 +993,6 @@ abstract class Compiler implements DiagnosticListener {
TreeElements result = world.getCachedElements(element);
if (result != null) return result;
result = analyzeElement(element);
- assert(invariant(element, element.isDeclaration));
- world.resolvedElements[element] = result;
return result;
}

Powered by Google App Engine
This is Rietveld 408576698