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

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

Issue 23996002: Use interceptors to handle runtime types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
index 3118874217d4d8cebfdf1478105c9cb3c626cab5..a951b0a565a515463eb1352b4f0fd29017ca8f89 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
@@ -3159,11 +3159,23 @@ class CodeEmitterTask extends CompilerTask {
block.statements.add(buildInterceptorCheck(backend.jsArrayClass));
}
+ // TODO(ahe): Work with sra@ to integrate this with native interceptors,
+ // and potentially initialize the dispatch object during finishClasses.
ngeoffray 2013/09/06 06:54:06 Please add a comment on what this is for, and what
ahe 2013/09/09 11:26:29 Done.
+ block.statements.add(
+ js.if_(r'typeof receiver == "function" && "builtin$cls" in receiver',
+ buildReturnInterceptor(backend.jsRuntimeType)));
+
+ // TODO(ahe): This should be a constant and we should be able to remove
+ // this test (so I'm keeping the redundant "object" test).
ngeoffray 2013/09/06 06:54:06 Ditto for having "func"
ahe 2013/09/09 11:26:29 Done.
+ block.statements.add(
+ js.if_(r'typeof receiver == "object"'
+ ' && receiver.constructor === Object'
ngeoffray 2013/09/06 06:54:06 Add a comment on why this constructor check?
ahe 2013/09/09 11:26:29 Done.
+ ' && "func" in receiver',
+ buildReturnInterceptor(backend.jsFunctionType)));
+
if (hasNative) {
block.statements.add(
- js.if_(
- js('(typeof receiver) != "object"'),
- js.return_(js('receiver'))));
+ js.if_('typeof receiver != "object"', js.return_('receiver')));
// if (receiver instanceof $.Object) return receiver;
// return $.getNativeInterceptor(receiver);

Powered by Google App Engine
This is Rietveld 408576698