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

Side by Side Diff: lib/runtime/_classes.js

Issue 1310513013: fixes #314, super method tear offs (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: add test Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /* This library defines the operations that define and manipulate Dart 5 /* This library defines the operations that define and manipulate Dart
6 * classes. Included in this are: 6 * classes. Included in this are:
7 * - Generics 7 * - Generics
8 * - Class metadata 8 * - Class metadata
9 * - Extension methods 9 * - Extension methods
10 */ 10 */
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 let parts = sigCtor[name]; 186 let parts = sigCtor[name];
187 if (parts === void 0) return void 0; 187 if (parts === void 0) return void 0;
188 return types.definiteFunctionType.apply(null, parts); 188 return types.definiteFunctionType.apply(null, parts);
189 } 189 }
190 exports.classGetConstructorType = _getConstructorType; 190 exports.classGetConstructorType = _getConstructorType;
191 191
192 /// Given an object and a method name, tear off the method. 192 /// Given an object and a method name, tear off the method.
193 /// Sets the runtime type of the torn off method appropriately, 193 /// Sets the runtime type of the torn off method appropriately,
194 /// and also binds the object. 194 /// and also binds the object.
195 /// TODO(leafp): Consider caching the tearoff on the object? 195 /// TODO(leafp): Consider caching the tearoff on the object?
196 function bind(obj, name) { 196 function bind(obj, name, f) {
Leaf 2015/09/10 17:42:41 Update the comment to describe the role of f?
Jennifer Messerly 2015/09/10 19:23:08 Nice catch! Done!
197 let f = obj[name].bind(obj); 197 if (f === void 0) f = obj[name];
198 f = f.bind(obj);
199 // TODO(jmesserly): track the function's signature on the function, instead
200 // of having to go back to the class?
198 let sig = _getMethodType(obj, name); 201 let sig = _getMethodType(obj, name);
199 assert(sig); 202 assert(sig);
200 rtti.tag(f, sig); 203 rtti.tag(f, sig);
201 return f; 204 return f;
202 } 205 }
203 exports.bind = bind; 206 exports.bind = bind;
204 207
205 // Set up the method signature field on the constructor 208 // Set up the method signature field on the constructor
206 function _setMethodSignature(f, sigF) { 209 function _setMethodSignature(f, sigF) {
207 defineMemoizedGetter(f, _methodSig, () => { 210 defineMemoizedGetter(f, _methodSig, () => {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 405 }
403 exports.list = list; 406 exports.list = list;
404 407
405 function setBaseClass(derived, base) { 408 function setBaseClass(derived, base) {
406 // Link the extension to the type it's extending as a base class. 409 // Link the extension to the type it's extending as a base class.
407 derived.prototype.__proto__ = base.prototype; 410 derived.prototype.__proto__ = base.prototype;
408 } 411 }
409 exports.setBaseClass = setBaseClass; 412 exports.setBaseClass = setBaseClass;
410 413
411 }); 414 });
OLDNEW
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698