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

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: Use dart.bind instead of dart.tearoff 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_runtime.js ('k') | test/codegen/expect/functions.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 f2079e67273218503a72c8bb17eef636c714b6e7..1808bf3a1e50ad3dd4710dcfaa2d84b77efaee76 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -1124,10 +1124,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.bind(this, #)' : 'this.#';
return js.call(code, member);
}
@@ -2003,14 +2001,12 @@ 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)]);
- }
code = 'dart.bind(#, #)';
} else if (_requiresStaticDispatch(target, memberId.name)) {
return js.call('dart.#(#)', [name, _visit(target)]);
« no previous file with comments | « lib/runtime/dart_runtime.js ('k') | test/codegen/expect/functions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698