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

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

Issue 21110003: Implement MirrorUsed.targets for libraries (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r25609 and added test. Created 7 years, 5 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/js_backend/backend.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
index b266dfd435c498cb87a1d2facebf377369b6ffe5..cc7b0fbe0937b13079ff7f17111525ae316fe565 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -320,6 +320,16 @@ class JavaScriptBackend extends Backend {
/// preserved, these elements must be compiled.
final List<FunctionElement> metadataGetOfStaticFunction = <FunctionElement>[];
+ /// List of symbols that the user has requested for reflection.
+ final Set<String> symbolsUsed = new Set<String>();
+
+ /// List of elements that the user has requested for reflection.
+ final Set<Element> targetsUsed = new Set<Element>();
+
+ /// List of annotations provided by user that indicate that the annotated
+ /// element must be retained.
+ final Set<Element> metaTargetsUsed = new Set<Element>();
Johnni Winther 2013/07/30 11:15:09 Isn't this a list of the annotated elements and no
ahe 2013/07/30 12:05:45 No. This is a list of classes that can be used as
+
JavaScriptBackend(Compiler compiler, bool generateSourceMap, bool disableEval)
: namer = determineNamer(compiler),
oneShotInterceptors = new Map<String, Selector>(),
@@ -1446,6 +1456,26 @@ class JavaScriptBackend extends Backend {
metadataGetOfStaticFunction.add(element);
}
}
+
+ void registerMirrorUsage(Set<String> symbols,
+ Set<Element> targets,
+ Set<Element> metaTargets) {
+ if (symbols != null) symbolsUsed.addAll(symbols);
+ if (targets != null) {
+ for (Element element in targets) {
+ // TODO(ahe): Implement finer granularity.
+ targetsUsed.add(element.getLibrary());
+ }
+ }
+ if (metaTargets != null) metaTargetsUsed.addAll(metaTargets);
+ }
+
+ bool isNeededForReflection(Element element) {
+ // TODO(ahe): Implement this.
+ if (!metaTargetsUsed.isEmpty) return true;
+ if (targetsUsed.contains(element.getLibrary())) return true;
+ return false;
+ }
}
/// Records that [type] is used by [user.element].

Powered by Google App Engine
This is Rietveld 408576698