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

Unified Diff: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart

Issue 980853002: dart2dart: Bugfix in copy propagator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 5 years, 9 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/tree_ir/tree_ir_builder.dart
diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
index 2e8ace867f7ec4f812dbee52c451901a559df761..8017ba65f47139a2866f32c6084ffe7b5592055c 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart
@@ -82,9 +82,7 @@ class Builder implements cps_ir.Visitor<Node> {
Variable phiTempVar;
Variable addMutableVariable(cps_ir.MutableVariable irVariable) {
- if (irVariable.host != currentElement) {
- return parent.addMutableVariable(irVariable);
- }
+ assert(irVariable.host == currentElement);
assert(!local2mutable.containsKey(irVariable));
Variable variable = new Variable(currentElement, irVariable.hint);
local2mutable[irVariable] = variable;
@@ -93,7 +91,7 @@ class Builder implements cps_ir.Visitor<Node> {
Variable getMutableVariable(cps_ir.MutableVariable mutableVariable) {
if (mutableVariable.host != currentElement) {
- return parent.getMutableVariable(mutableVariable);
+ return parent.getMutableVariable(mutableVariable)..isCaptured = true;
}
return local2mutable[mutableVariable];
}
@@ -480,7 +478,11 @@ class Builder implements cps_ir.Visitor<Node> {
Statement visitLetMutable(cps_ir.LetMutable node) {
Variable variable = addMutableVariable(node.variable);
Expression value = getVariableUse(node.value);
- return new Assign(variable, value, visit(node.body), isDeclaration: true);
+ Statement body = visit(node.body);
+ // If the variable was captured by an inner function in the body, this
+ // must be declared here so we assign to a fresh copy of the variable.
+ bool needsDeclaration = variable.isCaptured;
+ return new Assign(variable, value, body, isDeclaration: needsDeclaration);
}
Expression visitGetMutableVariable(cps_ir.GetMutableVariable node) {
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698