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

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

Issue 23045004: Throw when reflecting on elements not covered by a `MirrorsUsed` annotation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Nicolas' comments. Created 7 years, 4 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
index 8b6f8725ad2f945ae4b9170ad68dae3e29f9da01..fc6113c2fd942542566d89c60be11426b0a98e24 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -1555,6 +1555,25 @@ class JavaScriptBackend extends Backend {
if (metaTargets != null) metaTargetsUsed.addAll(metaTargets);
}
+ /**
+ * Returns `true` if [element] can be accessed through reflection, that is,
+ * is in the set of elements covered by a `MirrorsUsed` annotation.
+ *
+ * This property is used to tag emitted elements with a marker which is
+ * checked by the runtime system to throw an exception if an element is
+ * accessed (invoked, get, set) that is not accessible for the reflective
+ * system.
+ */
+ bool isAccessibleByReflection(Element element) {
+ if (hasInsufficientMirrorsUsed) return true;
+ return isNeededForReflection(element);
+ }
+
+ /**
+ * Returns `true` if the emitter must emit the element even though there
+ * is no direct use in the program, but because the reflective system may
+ * need to access it.
+ */
bool isNeededForReflection(Element element) {
if (hasInsufficientMirrorsUsed) return isTreeShakingDisabled;
/// Record the name of [element] in [symbolsUsed]. Return true for
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698