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

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

Issue 2310573002: dart2js: Pass type information to constructor rather than add later. (Closed)
Patch Set: Filter out type info pseudofield when parsing fieldspec for mirrors 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
index 12245c7003099b09a48977e6ad5879d0eca5d63f..222b1c6293fa443506a3f82cc851627a9864d6fd 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
@@ -629,19 +629,29 @@ class FragmentEmitter {
///
/// The constructor is statically built.
js.Expression emitConstructor(Class cls) {
- List<js.Name> fieldNames = const <js.Name>[];
-
+ js.Name name = cls.name;
// If the class is not directly instantiated we only need it for inheritance
// or RTI. In either case we don't need its fields.
- if (cls.isDirectlyInstantiated && !cls.isNative) {
- fieldNames = cls.fields.map((Field field) => field.name).toList();
+ if (cls.isNative || !cls.isDirectlyInstantiated) {
+ return js.js('function #() { }', name);
+ }
+
+ List<js.Name> fieldNames =
+ cls.fields.map((Field field) => field.name).toList();
+ if (cls.hasRtiField) {
+ fieldNames.add(namer.rtiFieldName);
}
- js.Name name = cls.name;
Iterable<js.Name> assignments = fieldNames.map((js.Name field) {
return js.js("this.#field = #field", {"field": field});
});
+ // TODO(sra): Cache 'this' in a one-character local for 4 or more uses of
+ // 'this'. i.e. "var _=this;_.a=a;_.b=b;..."
+
+ // TODO(sra): Separate field and field initializer parameter names so the
+ // latter may be fully minified.
+
return js.js('function #(#) { # }', [name, fieldNames, assignments]);
}
« 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