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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart

Issue 2319863002: Revert "dart2js: Pass type information to constructor rather than add later." (Closed)
Patch Set: Created 4 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
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 part of dart2js.js_emitter.startup_emitter.model_emitter; 5 part of dart2js.js_emitter.startup_emitter.model_emitter;
6 6
7 /// The name of the property that stores the tear-off getter on a static 7 /// The name of the property that stores the tear-off getter on a static
8 /// function. 8 /// function.
9 /// 9 ///
10 /// This property is only used when isolates are used. 10 /// This property is only used when isolates are used.
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 }); 622 });
623 jsMethods[method.name] = method.code; 623 jsMethods[method.name] = method.code;
624 624
625 return jsMethods; 625 return jsMethods;
626 } 626 }
627 627
628 /// Emits a constructor for the given class [cls]. 628 /// Emits a constructor for the given class [cls].
629 /// 629 ///
630 /// The constructor is statically built. 630 /// The constructor is statically built.
631 js.Expression emitConstructor(Class cls) { 631 js.Expression emitConstructor(Class cls) {
632 js.Name name = cls.name; 632 List<js.Name> fieldNames = const <js.Name>[];
633
633 // If the class is not directly instantiated we only need it for inheritance 634 // If the class is not directly instantiated we only need it for inheritance
634 // or RTI. In either case we don't need its fields. 635 // or RTI. In either case we don't need its fields.
635 if (cls.isNative || !cls.isDirectlyInstantiated) { 636 if (cls.isDirectlyInstantiated && !cls.isNative) {
636 return js.js('function #() { }', name); 637 fieldNames = cls.fields.map((Field field) => field.name).toList();
637 } 638 }
638 639 js.Name name = cls.name;
639 List<js.Name> fieldNames =
640 cls.fields.map((Field field) => field.name).toList();
641 if (cls.hasRtiField) {
642 fieldNames.add(namer.rtiFieldName);
643 }
644 640
645 Iterable<js.Name> assignments = fieldNames.map((js.Name field) { 641 Iterable<js.Name> assignments = fieldNames.map((js.Name field) {
646 return js.js("this.#field = #field", {"field": field}); 642 return js.js("this.#field = #field", {"field": field});
647 }); 643 });
648 644
649 // TODO(sra): Cache 'this' in a one-character local for 4 or more uses of
650 // 'this'. i.e. "var _=this;_.a=a;_.b=b;..."
651
652 // TODO(sra): Separate field and field initializer parameter names so the
653 // latter may be fully minified.
654
655 return js.js('function #(#) { # }', [name, fieldNames, assignments]); 645 return js.js('function #(#) { # }', [name, fieldNames, assignments]);
656 } 646 }
657 647
658 /// Emits the prototype-section of the fragment. 648 /// Emits the prototype-section of the fragment.
659 /// 649 ///
660 /// This section updates the prototype-property of all constructors in the 650 /// This section updates the prototype-property of all constructors in the
661 /// global holders. 651 /// global holders.
662 js.Statement emitPrototypes(Fragment fragment) { 652 js.Statement emitPrototypes(Fragment fragment) {
663 List<js.Statement> assignments = fragment.libraries 653 List<js.Statement> assignments = fragment.libraries
664 .expand((Library library) => library.classes) 654 .expand((Library library) => library.classes)
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 } 1349 }
1360 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", 1350 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);",
1361 js.objectLiteral(interceptorsByTag))); 1351 js.objectLiteral(interceptorsByTag)));
1362 statements.add( 1352 statements.add(
1363 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags))); 1353 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags)));
1364 statements.add(subclassAssignment); 1354 statements.add(subclassAssignment);
1365 1355
1366 return new js.Block(statements); 1356 return new js.Block(statements);
1367 } 1357 }
1368 } 1358 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698