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

Unified Diff: pkg/compiler/lib/src/js_emitter/class_stub_generator.dart

Issue 1913033002: dart2js: Pass type information to constructor rather than add later. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: rebase Created 4 years, 4 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..c924f044bd006c476ccacc320c57b0e3dfd1d882 100644
--- a/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
@@ -12,7 +12,7 @@ class ClassStubGenerator {
ClassStubGenerator(this.compiler, this.namer, this.backend);
jsAst.Expression generateClassConstructor(
- ClassElement classElement, Iterable<jsAst.Name> fields) {
+ ClassElement classElement, Iterable<jsAst.Name> fields, bool hasRti) {
// 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 (hasRti) {
+ String parameterName = r'$ti';
+ typeParameters = parameterName;
+ typeInits = js('this.# = #', [namer.rtiFieldName, parameterName]);
+ }
+ return js('function(#, #) { #; #; this.#();}', [
fields,
+ typeParameters,
Siggi Cherem (dart-lang) 2016/08/19 16:39:46 does js_ast remove the extra argument if typeParam
sra1 2017/02/23 23:46:41 # in most repeated contexts will spread a template
fields.map((name) => js('this.# = #', [name, name])),
+ typeInits,
namer.deferredAction
]);
}

Powered by Google App Engine
This is Rietveld 408576698