Chromium Code Reviews| 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]. |