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

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

Issue 15026006: Support for extending native classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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 c4b8f5200f6512093be2971a7b227e3a4b72e4f3..fabb2757930a074497df9420fa52bda5154c1469 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -201,6 +201,14 @@ class JavaScriptBackend extends Backend {
Element getInterceptorMethod;
Element interceptedNames;
+ /**
+ * This element is a top-level variable (in generated output) that the
+ * compiler initializes to a datastructure used to map from a Type to the
+ * interceptor. See declaration of `mapTypeToInterceptor` in
+ * `interceptors.dart`.
+ */
+ Element mapTypeToInterceptor;
+
HType stringType;
HType indexablePrimitiveType;
HType readableArrayType;
@@ -356,7 +364,7 @@ class JavaScriptBackend extends Backend {
bool isInterceptorClass(ClassElement element) {
if (element == null) return false;
- if (element.isNative()) return true;
+ if (Elements.isNativeOrExtendsNative(element)) return true;
if (interceptedClasses.contains(element)) return true;
if (classesMixedIntoNativeClasses.contains(element)) return true;
return false;
@@ -412,7 +420,7 @@ class JavaScriptBackend extends Backend {
Set<ClassElement> result = new Set<ClassElement>();
for (Element element in intercepted) {
ClassElement classElement = element.getEnclosingClass();
- if (classElement.isNative()
+ if (Elements.isNativeOrExtendsNative(classElement)
|| interceptedClasses.contains(classElement)) {
result.add(classElement);
}
@@ -454,6 +462,8 @@ class JavaScriptBackend extends Backend {
compiler.findInterceptor(const SourceString('getInterceptor'));
interceptedNames =
compiler.findInterceptor(const SourceString('interceptedNames'));
+ mapTypeToInterceptor =
+ compiler.findInterceptor(const SourceString('mapTypeToInterceptor'));
dispatchPropertyName =
compiler.findInterceptor(const SourceString('dispatchPropertyName'));
getDispatchPropertyMethod =
@@ -594,7 +604,7 @@ class JavaScriptBackend extends Backend {
member.name, () => new Set<Element>());
set.add(member);
if (classElement == jsInterceptorClass) return;
- if (!classElement.isNative()) {
+ if (classElement.isMixinApplication) {
MixinApplicationElement mixinApplication = classElement;
assert(member.getEnclosingClass() == mixinApplication.mixin);
classesMixedIntoNativeClasses.add(mixinApplication.mixin);
@@ -703,7 +713,7 @@ class JavaScriptBackend extends Backend {
addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, elements);
} else if (cls == jsUnknownJavaScriptObjectClass) {
addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, elements);
- } else if (cls.isNative()) {
+ } else if (Elements.isNativeOrExtendsNative(cls)) {
addInterceptorsForNativeClassMembers(cls, enqueuer);
}
}

Powered by Google App Engine
This is Rietveld 408576698