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

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

Issue 11348129: Add JSNumber, JSInt and JSDouble for the new interceptor scheme. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (revision 15076)
+++ sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (working copy)
@@ -648,8 +648,12 @@
ClassElement jsStringClass;
ClassElement jsArrayClass;
+ ClassElement jsNumberClass;
+ ClassElement jsIntClass;
+ ClassElement jsDoubleClass;
ClassElement objectInterceptorClass;
Element getInterceptorMethod;
+ bool _interceptorsAreInitialized = false;
final Namer namer;
@@ -717,7 +721,11 @@
bool isInterceptorClass(Element element) {
if (element == null) return false;
- return element == jsStringClass || element == jsArrayClass;
+ return element == jsStringClass
+ || element == jsArrayClass
+ || element == jsIntClass
+ || element == jsDoubleClass
+ || element == jsNumberClass;
}
void addInterceptedSelector(Selector selector) {
@@ -738,35 +746,47 @@
compiler.findInterceptor(const SourceString('ObjectInterceptor'));
getInterceptorMethod =
compiler.findInterceptor(const SourceString('getInterceptor'));
+ jsStringClass =
+ compiler.findInterceptor(const SourceString('JSString'));
+ jsArrayClass =
+ compiler.findInterceptor(const SourceString('JSArray'));
+ jsNumberClass =
+ compiler.findInterceptor(const SourceString('JSNumber'));
+ jsIntClass =
+ compiler.findInterceptor(const SourceString('JSInt'));
+ jsDoubleClass =
+ compiler.findInterceptor(const SourceString('JSDouble'));
}
+ void addInterceptors(ClassElement cls) {
+ cls.ensureResolved(compiler);
+ cls.forEachMember((ClassElement classElement, Element member) {
+ // TODO(ngeoffray): Support interceptors on Object methods.
+ if (classElement == compiler.objectClass) return;
+ List<Element> list = interceptedElements.putIfAbsent(
+ member.name, () => new List<Element>());
+ list.add(member);
+ }, includeSuperMembers: true);
+ }
void registerInstantiatedClass(ClassElement cls, Enqueuer enqueuer) {
ClassElement result = null;
+ if (!_interceptorsAreInitialized) {
+ initializeInterceptorElements();
+ _interceptorsAreInitialized = true;
+ }
if (cls == compiler.stringClass) {
- if (jsStringClass == null) {
- jsStringClass =
- compiler.findInterceptor(const SourceString('JSString'));
- initializeInterceptorElements();
- }
result = jsStringClass;
} else if (cls == compiler.listClass) {
- if (jsArrayClass == null) {
- jsArrayClass =
- compiler.findInterceptor(const SourceString('JSArray'));
- initializeInterceptorElements();
- }
result = jsArrayClass;
+ } else if (cls == compiler.intClass) {
+ result = jsIntClass;
+ } else if (cls == compiler.doubleClass) {
+ result = jsDoubleClass;
}
if (result == null) return;
-
- result.forEachMember((_, Element member) {
- List<Element> list = interceptedElements.putIfAbsent(
- member.name, () => new List<Element>());
- list.add(member);
- });
-
+ if (enqueuer.isResolutionQueue) addInterceptors(result);
enqueuer.registerInstantiatedClass(result);
}

Powered by Google App Engine
This is Rietveld 408576698