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

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

Issue 2711253004: When metadata is not requested, elide unneeded signatures (Closed)
Patch Set: Rebase Created 3 years, 9 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/codegen_expected/varargs.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Run base initializer. 43 // Run base initializer.
44 $base.prototype.new.apply(this, args); 44 $base.prototype.new.apply(this, args);
45 }; 45 };
46 46
47 // Set the signature of the Mixin class to be the composition 47 // Set the signature of the Mixin class to be the composition
48 // of the signatures of the mixins. 48 // of the signatures of the mixins.
49 $setSignature(Mixin, { 49 $setSignature(Mixin, {
50 methods: () => { 50 methods: () => {
51 let s = {}; 51 let s = {};
52 for (let m of $mixins) { 52 for (let m of $mixins) {
53 $copyProperties(s, m[$_methodSig]); 53 if (m[$_methodSig]) $copyProperties(s, m[$_methodSig]);
54 } 54 }
55 return s; 55 return s;
56 }, 56 },
57 fields: () => { 57 fields: () => {
58 let s = {}; 58 let s = {};
59 for (let m of $mixins) { 59 for (let m of $mixins) {
60 $copyProperties(s, m[$_fieldSig]); 60 if (m[$_fieldSig]) $copyProperties(s, m[$_fieldSig]);
61 } 61 }
62 return s; 62 return s;
63 }, 63 },
64 getters: () => { 64 getters: () => {
65 let s = {}; 65 let s = {};
66 for (let m of $mixins) { 66 for (let m of $mixins) {
67 $copyProperties(s, m[$_getterSig]); 67 if (m[$_getterSig]) $copyProperties(s, m[$_getterSig]);
68 } 68 }
69 return s; 69 return s;
70 }, 70 },
71 setters: () => { 71 setters: () => {
72 let s = {}; 72 let s = {};
73 for (let m of $mixins) { 73 for (let m of $mixins) {
74 $copyProperties(s, m[$_setterSig]); 74 if (m[$_setterSig]) $copyProperties(s, m[$_setterSig]);
75 } 75 }
76 return s; 76 return s;
77 } 77 }
78 }); 78 });
79 79
80 // Save mixins for reflection 80 // Save mixins for reflection
81 Mixin[$_mixins] = $mixins; 81 Mixin[$_mixins] = $mixins;
82 return Mixin; 82 return Mixin;
83 })()'''); 83 })()''');
84 84
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 let jsProto = $jsType.prototype; 493 let jsProto = $jsType.prototype;
494 494
495 // TODO(vsm): This sometimes doesn't exist on FF. These types will be 495 // TODO(vsm): This sometimes doesn't exist on FF. These types will be
496 // broken. 496 // broken.
497 if (!jsProto) return; 497 if (!jsProto) return;
498 498
499 // Mark the JS type's instances so we can easily check for extensions. 499 // Mark the JS type's instances so we can easily check for extensions.
500 jsProto[$_extensionType] = $dartExtType; 500 jsProto[$_extensionType] = $dartExtType;
501 $_installProperties(jsProto, extProto); 501 $_installProperties(jsProto, extProto);
502 function updateSig(sigF) { 502 function updateSig(sigF) {
503 let originalSigFn = $getOwnPropertyDescriptor($dartExtType, sigF).get; 503 let originalDesc = $getOwnPropertyDescriptor($dartExtType, sigF);
504 if (originalDesc === void 0) return;
505 let originalSigFn = originalDesc.get;
504 $assert_(originalSigFn); 506 $assert_(originalSigFn);
505 $defineMemoizedGetter($jsType, sigF, originalSigFn); 507 $defineMemoizedGetter($jsType, sigF, originalSigFn);
506 } 508 }
507 updateSig($_methodSig); 509 updateSig($_methodSig);
508 updateSig($_fieldSig); 510 updateSig($_fieldSig);
509 updateSig($_getterSig); 511 updateSig($_getterSig);
510 updateSig($_setterSig); 512 updateSig($_setterSig);
511 })()'''); 513 })()''');
512 514
513 /// 515 ///
(...skipping 24 matching lines...) Expand all
538 $defineProperty(proto, $getExtensionSymbol(name), method); 540 $defineProperty(proto, $getExtensionSymbol(name), method);
539 } 541 }
540 // Ensure the signature is available too. 542 // Ensure the signature is available too.
541 // TODO(jmesserly): not sure if we can do this in a cleaner way. Essentially 543 // TODO(jmesserly): not sure if we can do this in a cleaner way. Essentially
542 // we need to copy the signature (and in the future, other data like 544 // we need to copy the signature (and in the future, other data like
543 // annotations) any time we copy a method as part of our metaprogramming. 545 // annotations) any time we copy a method as part of our metaprogramming.
544 // It might be more friendly to JS metaprogramming if we include this info 546 // It might be more friendly to JS metaprogramming if we include this info
545 // on the function. 547 // on the function.
546 548
547 function upgradeSig(sigF) { 549 function upgradeSig(sigF) {
548 let originalSigFn = $getOwnPropertyDescriptor($type, sigF).get; 550 let originalSigDesc = $getOwnPropertyDescriptor($type, sigF);
551 if (originalSigDesc === void 0) return;
552 let originalSigFn = originalSigDesc.get;
549 $defineMemoizedGetter(type, sigF, function() { 553 $defineMemoizedGetter(type, sigF, function() {
550 let sig = originalSigFn(); 554 let sig = originalSigFn();
551 let propertyNames = Object.getOwnPropertyNames(sig); 555 let propertyNames = Object.getOwnPropertyNames(sig);
552 for (let name of methodNames) { 556 for (let name of methodNames) {
553 if (name in sig) { 557 if (name in sig) {
554 sig[$getExtensionSymbol(name)] = sig[name]; 558 sig[$getExtensionSymbol(name)] = sig[name];
555 } 559 }
556 } 560 }
557 return sig; 561 return sig;
558 }); 562 });
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 '''(() => { 638 '''(() => {
635 let values = []; 639 let values = [];
636 for (var i = 0; i < $names.length; i++) { 640 for (var i = 0; i < $names.length; i++) {
637 let value = $const_(new $enumClass(i)); 641 let value = $const_(new $enumClass(i));
638 values.push(value); 642 values.push(value);
639 Object.defineProperty($enumClass, $names[i], 643 Object.defineProperty($enumClass, $names[i],
640 { value: value, configurable: true }); 644 { value: value, configurable: true });
641 } 645 }
642 $enumClass.values = $constList(values, $enumClass); 646 $enumClass.values = $constList(values, $enumClass);
643 })()'''); 647 })()''');
OLDNEW
« no previous file with comments | « pkg/dev_compiler/test/codegen_expected/varargs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698