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

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

Issue 2779063002: One more minor mixin fix (Closed)
Patch Set: Created 3 years, 8 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 | « pkg/dev_compiler/test/browser/language_tests.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 11 matching lines...) Expand all
22 /// superclass (prototype). 22 /// superclass (prototype).
23 /// 23 ///
24 mixin(base, @rest mixins) => JS( 24 mixin(base, @rest mixins) => JS(
25 '', 25 '',
26 '''(() => { 26 '''(() => {
27 // Create an initializer for the mixin, so when derived constructor calls 27 // Create an initializer for the mixin, so when derived constructor calls
28 // super, we can correctly initialize base and mixins. 28 // super, we can correctly initialize base and mixins.
29 29
30 // Create a class that will hold all of the mixin methods. 30 // Create a class that will hold all of the mixin methods.
31 class Mixin extends $base {} 31 class Mixin extends $base {}
32 // Save the original constructor. For ClassTypeAlias definitions, this
33 // is the concrete type. We embed metadata (e.g., implemented interfaces)
34 // on this constructor and need to access that from runtime instances.
35 var constructor = Mixin.prototype.constructor;
32 // Copy each mixin's methods, with later ones overwriting earlier entries. 36 // Copy each mixin's methods, with later ones overwriting earlier entries.
33 for (let m of $mixins) { 37 for (let m of $mixins) {
34 $copyProperties(Mixin.prototype, m.prototype); 38 $copyProperties(Mixin.prototype, m.prototype);
Jennifer Messerly 2017/03/28 20:47:48 hmm, maybe just skip "constructor" when copying pr
35 } 39 }
40 // Restore original Mixin constructor.
41 Mixin.prototype.constructor = constructor;
36 // Initializer method: run mixin initializers, then the base. 42 // Initializer method: run mixin initializers, then the base.
37 Mixin.prototype.new = function(...args) { 43 Mixin.prototype.new = function(...args) {
38 // Run mixin initializers. They cannot have arguments. 44 // Run mixin initializers. They cannot have arguments.
39 // Run them backwards so most-derived mixin is initialized first. 45 // Run them backwards so most-derived mixin is initialized first.
40 for (let i = $mixins.length - 1; i >= 0; i--) { 46 for (let i = $mixins.length - 1; i >= 0; i--) {
41 $mixins[i].prototype.new.call(this); 47 $mixins[i].prototype.new.call(this);
42 } 48 }
43 // Run base initializer. 49 // Run base initializer.
44 $base.prototype.new.apply(this, args); 50 $base.prototype.new.apply(this, args);
45 }; 51 };
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 '''(() => { 644 '''(() => {
639 let values = []; 645 let values = [];
640 for (var i = 0; i < $names.length; i++) { 646 for (var i = 0; i < $names.length; i++) {
641 let value = $const_(new $enumClass(i)); 647 let value = $const_(new $enumClass(i));
642 values.push(value); 648 values.push(value);
643 Object.defineProperty($enumClass, $names[i], 649 Object.defineProperty($enumClass, $names[i],
644 { value: value, configurable: true }); 650 { value: value, configurable: true });
645 } 651 }
646 $enumClass.values = $constList(values, $enumClass); 652 $enumClass.values = $constList(values, $enumClass);
647 })()'''); 653 })()''');
OLDNEW
« no previous file with comments | « pkg/dev_compiler/test/browser/language_tests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698