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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1216593002: dart2js cps: Translate synthesized mixin constructors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update status file Created 5 years, 6 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
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
index f5e5cc9f744477517193dcd9b6a7560f48e8a101..673f8c9f37822b2877aa67e5ab191d3ba6c89ba7 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
@@ -2528,6 +2528,14 @@ class JsIrBuilderVisitor extends IrBuilderVisitor {
}
});
}
+ // If this is a mixin constructor, it does not have its own parameter list
+ // or initializer list. Directly forward to the super constructor.
+ // Note that the declaration-site initializers originating from the
+ // mixed-in class were handled above.
+ if (enclosingClass.isMixinApplication) {
+ forwardSynthesizedMixinConstructor(constructor, supers, fieldValues);
+ return;
+ }
// Evaluate initializing parameters, e.g. `Foo(this.x)`.
constructor.functionSignature.orderedForEachParameter(
(ParameterElement parameter) {
@@ -2594,12 +2602,32 @@ class JsIrBuilderVisitor extends IrBuilderVisitor {
List<ConstructorElement> supers,
Map<FieldElement, ir.Primitive> fieldValues) {
JsIrBuilderVisitor visitor = makeVisitorForContext(target);
- return visitor.withBuilder(irBuilder, () {
+ visitor.withBuilder(irBuilder, () {
visitor.loadArguments(target, call, arguments);
visitor.evaluateConstructorFieldInitializers(target, supers, fieldValues);
});
}
+ /// Evaluate the implicit super call in the given mixin constructor.
+ void forwardSynthesizedMixinConstructor(
+ ConstructorElement constructor,
+ List<ConstructorElement> supers,
+ Map<FieldElement, ir.Primitive> fieldValues) {
+ assert(constructor.enclosingClass.implementation.isMixinApplication);
+ assert(constructor.isSynthesized);
+ ConstructorElement target =
+ constructor.definingConstructor.implementation;
+ // The resolver gives us the exact same FunctionSignature for the two
+ // constructors. The parameters for the synthesized constructor
+ // are already in the environment, so the target constructor's parameters
+ // are also in the environment since their elements are the same.
+ assert(constructor.functionSignature == target.functionSignature);
+ JsIrBuilderVisitor visitor = makeVisitorForContext(target);
+ visitor.withBuilder(irBuilder, () {
+ visitor.evaluateConstructorFieldInitializers(target, supers, fieldValues);
+ });
+ }
+
/// Loads the type variables for all super classes of [superClass] into the
/// IR builder's environment with their corresponding values.
///
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698