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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1142293002: Use dart.tearoff helper at tearoff sites (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Clean up conditional Created 5 years, 7 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 | « lib/runtime/dart/core.js ('k') | test/codegen/expect/methods.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index 2a85f77cae73b54bea1a75ceb03ebe27cbfcd755..8be77619d4e130972254cabc9a4d17babfb36048 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -1114,10 +1114,8 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
// For instance members, we add implicit-this.
// For method tear-offs, we ensure it's a bound method.
- var code = 'this.#';
- if (element is MethodElement && !inInvocationContext(node)) {
- code += '.bind(this)';
- }
+ var tearOff = element is MethodElement && !inInvocationContext(node);
+ var code = (tearOff) ? 'dart.tearoff(this, #)' : 'this.#';
Jennifer Messerly 2015/05/20 16:05:17 I don't think we should call this "tearoff" in gen
Leaf 2015/05/20 16:35:17 So you're saying change dart.bind to both bind the
Jennifer Messerly 2015/05/20 16:50:30 err, I think so :). What do we still use "dart.bin
Leaf 2015/05/20 17:05:56 Apparently nothing. Made the switch.
return js.call(code, member);
}
@@ -1989,15 +1987,13 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
}
String code;
- if (member != null && member is MethodElement) {
+ if (member != null && member is MethodElement && !isStatic) {
// Tear-off methods: explicitly bind it.
+ // TODO(leafp): Attach runtime types to these static tearoffs
if (_requiresStaticDispatch(target, memberId.name)) {
return js.call('dart.#.bind(#)', [name, _visit(target)]);
}
- if (isStateless(target, target)) {
- return js.call('#.#.bind(#)', [_visit(target), name, _visit(target)]);
Jennifer Messerly 2015/05/20 16:05:17 this makes me a little sad, as we never generate "
Leaf 2015/05/20 16:35:17 Hmm. I actually kind of felt like it was often an
Jennifer Messerly 2015/05/20 16:50:30 yeah, exactly ... in JS it's not something you'd t
- }
- code = 'dart.bind(#, #)';
+ code = 'dart.tearoff(#, #)';
} else if (_requiresStaticDispatch(target, memberId.name)) {
return js.call('dart.#(#)', [name, _visit(target)]);
} else {
« no previous file with comments | « lib/runtime/dart/core.js ('k') | test/codegen/expect/methods.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698