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

Unified Diff: pkg/compiler/lib/src/js_emitter/class_stub_generator.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/class_stub_generator.dart
diff --git a/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
index 447710dca781f2ef0320f282ad342a15fc5cd94f..d07c36fa1a4623f14139c6894447e0edd2a5c8ec 100644
--- a/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
@@ -11,8 +11,8 @@ class ClassStubGenerator {
ClassStubGenerator(this.compiler, this.namer, this.backend);
- jsAst.Expression generateClassConstructor(
- ClassElement classElement, Iterable<jsAst.Name> fields) {
+ jsAst.Expression generateClassConstructor(ClassElement classElement,
+ Iterable<jsAst.Name> fields, bool hasRtiField) {
// TODO(sra): Implement placeholders in VariableDeclaration position:
//
// String constructorName = namer.getNameOfClass(classElement);
@@ -20,9 +20,18 @@ class ClassStubGenerator {
// [ constructorName, fields,
// fields.map(
// (name) => js('this.# = #', [name, name]))]));
- return js('function(#) { #; this.#();}', [
+ var typeParameters = const <jsAst.Parameter>[];
+ var typeInits = const <jsAst.Expression>[];
+ if (hasRtiField) {
+ String parameterName = r'$ti';
+ typeParameters = parameterName;
+ typeInits = js('this.# = #', [namer.rtiFieldName, parameterName]);
+ }
+ return js('function(#, #) { #; #; this.#();}', [
fields,
+ typeParameters,
fields.map((name) => js('this.# = #', [name, name])),
+ typeInits,
namer.deferredAction
]);
}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/constant_emitter.dart ('k') | pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698