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

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

Issue 72643002: Make native implementation classes for classes that are used as targets in @MirrorsUsed available f… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 1 month 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/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 91537ca0f93c9c6a7e6cfc60524f06e2290b9013..21e7d697022ddc43fc2aba3918cd30ce88deb3db 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -231,6 +231,8 @@ class JavaScriptBackend extends Backend {
TypeMask extendableArrayType;
TypeMask nonNullType;
+ /// Maps special classes to their implementation (JSXxx) class.
+ Map<ClassElement, ClassElement> implementationClasses;
Element getNativeInterceptorMethod;
bool needToInitializeDispatchProperty = false;
@@ -578,6 +580,14 @@ class JavaScriptBackend extends Backend {
compiler.findInterceptor('UnknownJavaScriptObject'),
];
+ implementationClasses = <ClassElement, ClassElement>{};
+ implementationClasses[compiler.intClass] = jsIntClass;
+ implementationClasses[compiler.boolClass] = jsBoolClass;
+ implementationClasses[compiler.numClass] = jsNumberClass;
+ implementationClasses[compiler.doubleClass] = jsDoubleClass;
+ implementationClasses[compiler.stringClass] = jsStringClass;
+ implementationClasses[compiler.listClass] = jsArrayClass;
+
jsIndexableClass = compiler.findInterceptor('JSIndexable');
jsMutableIndexableClass = compiler.findInterceptor('JSMutableIndexable');
@@ -1294,22 +1304,22 @@ class JavaScriptBackend extends Backend {
}
}
+ Element getDartClass(Element element) {
+ for (ClassElement dartClass in implementationClasses.keys) {
+ if (element == implementationClasses[dartClass]) {
+ return dartClass;
+ }
+ }
+ return element;
+ }
+
Element getImplementationClass(Element element) {
- if (element == compiler.intClass) {
- return jsIntClass;
- } else if (element == compiler.boolClass) {
- return jsBoolClass;
- } else if (element == compiler.numClass) {
- return jsNumberClass;
- } else if (element == compiler.doubleClass) {
- return jsDoubleClass;
- } else if (element == compiler.stringClass) {
- return jsStringClass;
- } else if (element == compiler.listClass) {
- return jsArrayClass;
- } else {
- return element;
+ for (ClassElement dartClass in implementationClasses.keys) {
+ if (element == dartClass) {
+ return implementationClasses[dartClass];
+ }
}
+ return element;
}
/**
@@ -1737,6 +1747,7 @@ class JavaScriptBackend extends Backend {
* need to access it.
*/
bool isNeededForReflection(Element element) {
+ element = getDartClass(element);
if (hasInsufficientMirrorsUsed) return isTreeShakingDisabled;
/// Record the name of [element] in [symbolsUsed]. Return true for
/// convenience.
« no previous file with comments | « samples/third_party/angular_todo/main.dart ('k') | tests/compiler/dart2js_extra/mirrors_used_native_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698