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

Unified Diff: lib/runtime/dart_runtime.js

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/core.js ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart_runtime.js
diff --git a/lib/runtime/dart_runtime.js b/lib/runtime/dart_runtime.js
index 9343f9fec3cfb886e480a9396409886243be435b..a05cf97c6ec91917cc29848966028ef72a6183e8 100644
--- a/lib/runtime/dart_runtime.js
+++ b/lib/runtime/dart_runtime.js
@@ -44,7 +44,7 @@ var dart, _js_helper, _js_primitives;
function dload(obj, field) {
field = _canonicalFieldName(obj, field);
if (_getMethodType(obj, field) !== void 0) {
- return dart.tearoff(obj, field);
+ return dart.bind(obj, field);
}
// TODO(vsm): Implement NSM robustly. An 'in' check breaks on certain
// types. hasOwnProperty doesn't chase the proto chain.
@@ -154,17 +154,6 @@ var dart, _js_helper, _js_primitives;
}
dart.dsetindex = dsetindex;
- /**
- * Returns bound `method`.
- * This helper function avoids needing a temp for `obj`.
- */
- function bind(obj, method) {
- // This is a static bind (dynamic would use `dload`) so no need to check
- // if `method` is really there on `obj`.`
- return obj[method].bind(obj);
- }
- dart.bind = bind;
-
function typeToString(type) {
if (typeof(type) == "function") {
var name = type.name;
@@ -1021,14 +1010,14 @@ var dart, _js_helper, _js_primitives;
/// Sets the runtime type of the torn off method appropriately,
/// and also binds the object.
/// TODO(leafp): Consider caching the tearoff on the object?
- function tearoff(obj, name) {
+ function bind(obj, name) {
let f = obj[name].bind(obj);
let sig = _getMethodType(obj, name)
assert(sig);
setRuntimeType(f, sig);
return f;
}
- dart.tearoff = tearoff;
+ dart.bind = bind;
// Set up the method signature field on the constructor
function _setMethodSignature(f, sigF) {
« no previous file with comments | « lib/runtime/dart/core.js ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698