Chromium Code Reviews| Index: pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart |
| diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart |
| index 8f0e85666c0f69773ef1daf68001d334d27bb93c..1113cccd360e21f765dd769f57a63c6bdb3e3d32 100644 |
| --- a/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart |
| +++ b/pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart |
| @@ -496,8 +496,10 @@ class WhileTrue extends Loop { |
| } |
| /** |
| - * A while loop with a condition. If the condition is false, control resumes |
| - * at the [next] statement. |
| + * A loop with a condition and update expressions. If there are any update |
| + * expressions, this generates a for loop, otherwise a while loop. |
| + * |
| + * When the condition is false, control resumes at the [next] statement. |
| * |
| * It is NOT valid to target this statement with a [Break]. |
| * The only way to reach [next] is for the condition to evaluate to false. |
| @@ -508,10 +510,14 @@ class WhileTrue extends Loop { |
| class WhileCondition extends Loop { |
|
Kevin Millikin (Google)
2015/08/13 11:32:47
Strange that While has updates. Maybe we call it
asgerf
2015/08/13 12:06:42
Renamed.
|
| final Label label; |
| Expression condition; |
| + List<Expression> updates; |
| Statement body; |
| Statement next; |
| - WhileCondition(this.label, this.condition, this.body, |
| + WhileCondition(this.label, |
| + this.condition, |
| + this.updates, |
| + this.body, |
| this.next) { |
| assert(label.binding == null); |
| label.binding = this; |
| @@ -1142,6 +1148,7 @@ abstract class RecursiveVisitor implements StatementVisitor, ExpressionVisitor { |
| visitWhileCondition(WhileCondition node) { |
| visitExpression(node.condition); |
| + node.updates.forEach(visitExpression); |
| visitStatement(node.body); |
| visitStatement(node.next); |
| } |
| @@ -1373,6 +1380,7 @@ class RecursiveTransformer extends Transformer { |
| visitWhileCondition(WhileCondition node) { |
| node.condition = visitExpression(node.condition); |
| + _replaceExpressions(node.updates); |
| node.body = visitStatement(node.body); |
| node.next = visitStatement(node.next); |
| return node; |