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

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 3009803003: dart2js kernel: Handle ir.LocalInitializer (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 141cda07f84eb7513b3400d8727bf9e2ba0c4030..01509afcd9bc2aef35989dc49d245012d5e5e3b8 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -96,6 +96,7 @@ class KernelSsaGraphBuilder extends ir.Visitor
final NativeEmitter nativeEmitter;
+ // [ir.Let] and [ir.LocalInitializer] bindings.
final Map<ir.VariableDeclaration, HInstruction> letBindings =
<ir.VariableDeclaration, HInstruction>{};
@@ -494,7 +495,6 @@ class KernelSsaGraphBuilder extends ir.Visitor
'Expected ${localsMap.currentMember} '
'but found ${_elementMap.getConstructor(constructor)}.'));
constructorChain.add(constructor);
-
var foundSuperOrRedirectCall = false;
for (var initializer in constructor.initializers) {
if (initializer is ir.FieldInitializer) {
@@ -511,7 +511,14 @@ class KernelSsaGraphBuilder extends ir.Visitor
_inlineRedirectingInitializer(
initializer, constructorChain, fieldValues, constructor);
} else if (initializer is ir.LocalInitializer) {
- assert(false, 'ir.LocalInitializer not handled');
+ // LocalInitializer is like a let-expression that is in scope for the
+ // rest of the initializers.
+ ir.VariableDeclaration variable = initializer.variable;
+ assert(variable.isFinal);
+ variable.initializer.accept(this);
+ HInstruction value = pop();
+ // TODO(sra): Apply inferred type information.
+ letBindings[variable] = value;
} else if (initializer is ir.InvalidInitializer) {
assert(false, 'ir.InvalidInitializer not handled');
}
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698