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

Side by Side Diff: tool/input_sdk/private/ddc_runtime/classes.dart

Issue 2200913002: fixes #616, statics on callable functions (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 4 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 | « test/codegen_expected/language/regress_21793_test_none_multi.js ('k') | no next file » | 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 /// function Foo { function call(...args) { ... } ... return call; }, 461 /// function Foo { function call(...args) { ... } ... return call; },
462 /// class Foo { call(x) { ... } }); 462 /// class Foo { call(x) { ... } });
463 /// ... 463 /// ...
464 /// let f = new lib.Foo(); 464 /// let f = new lib.Foo();
465 /// f(42); 465 /// f(42);
466 callableClass(callableCtor, classExpr) { 466 callableClass(callableCtor, classExpr) {
467 JS('', '#.prototype = #.prototype', callableCtor, classExpr); 467 JS('', '#.prototype = #.prototype', callableCtor, classExpr);
468 // We're not going to use the original class, so we can safely replace it to 468 // We're not going to use the original class, so we can safely replace it to
469 // point at this constructor for the runtime type information. 469 // point at this constructor for the runtime type information.
470 JS('', '#.prototype.constructor = #', callableCtor, callableCtor); 470 JS('', '#.prototype.constructor = #', callableCtor, callableCtor);
471 JS('', '#.__proto__ = #.__proto__', callableCtor, classExpr); 471 JS('', '#.__proto__ = #', callableCtor, classExpr);
472 return callableCtor; 472 return callableCtor;
473 } 473 }
474 474
475 /// Given a class and an initializer method name and a call method, creates a 475 /// Given a class and an initializer method name and a call method, creates a
476 /// constructor function with the same name. 476 /// constructor function with the same name.
477 /// 477 ///
478 /// For example it can be called with `new SomeClass.name(args)`. 478 /// For example it can be called with `new SomeClass.name(args)`.
479 /// 479 ///
480 /// The constructor 480 /// The constructor
481 defineNamedConstructorCallable(clazz, name, ctor) => JS( 481 defineNamedConstructorCallable(clazz, name, ctor) => JS(
482 '', 482 '',
483 '''(() => { 483 '''(() => {
484 ctor.prototype = $clazz.prototype; 484 ctor.prototype = $clazz.prototype;
485 // Use defineProperty so we don't hit a property defined on Function, 485 // Use defineProperty so we don't hit a property defined on Function,
486 // like `caller` and `arguments`. 486 // like `caller` and `arguments`.
487 $defineProperty($clazz, $name, { value: ctor, configurable: true }); 487 $defineProperty($clazz, $name, { value: ctor, configurable: true });
488 })()'''); 488 })()''');
OLDNEW
« no previous file with comments | « test/codegen_expected/language/regress_21793_test_none_multi.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698