| Index: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
|
| diff --git a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
|
| index 922da2b97c80c80994494ab509a2707d0284bccf..11ec061cd722eac598402d4ef56c87bb0e32bbf6 100644
|
| --- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
|
| +++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
|
| @@ -415,8 +415,8 @@ class AstBuilder extends ScopeListener {
|
| debugEvent("WhileStatement");
|
| Statement body = pop();
|
| ParenthesizedExpression condition = pop();
|
| - pop(); // continue target
|
| - pop(); // break target
|
| + exitContinueTarget();
|
| + exitBreakTarget();
|
| push(ast.whileStatement(
|
| toAnalyzerToken(whileKeyword),
|
| condition.leftParenthesis,
|
| @@ -475,25 +475,43 @@ class AstBuilder extends ScopeListener {
|
| toAnalyzerToken(beginToken), statements, toAnalyzerToken(endToken)));
|
| }
|
|
|
| - void endForStatement(
|
| - int updateExpressionCount, Token beginToken, Token endToken) {
|
| + void endForStatement(Token forKeyword, Token leftSeparator,
|
| + int updateExpressionCount, Token endToken) {
|
| debugEvent("ForStatement");
|
| Statement body = pop();
|
| List<Expression> updates = popList(updateExpressionCount);
|
| - ExpressionStatement condition = pop();
|
| - VariableDeclarationStatement variables = pop();
|
| + Statement conditionStatement = pop();
|
| + Object initializerPart = pop();
|
| + exitLocalScope();
|
| exitContinueTarget();
|
| exitBreakTarget();
|
| - exitLocalScope();
|
| - BeginGroupToken leftParenthesis = beginToken.next;
|
| + BeginGroupToken leftParenthesis = forKeyword.next;
|
| +
|
| + VariableDeclarationList variableList;
|
| + Expression initializer;
|
| + if (initializerPart is VariableDeclarationStatement) {
|
| + variableList = initializerPart.variables;
|
| + } else {
|
| + initializer = initializerPart as Expression;
|
| + }
|
| +
|
| + Expression condition;
|
| + analyzer.Token rightSeparator;
|
| + if (conditionStatement is ExpressionStatement) {
|
| + condition = conditionStatement.expression;
|
| + rightSeparator = conditionStatement.semicolon;
|
| + } else {
|
| + rightSeparator = (conditionStatement as EmptyStatement).semicolon;
|
| + }
|
| +
|
| push(ast.forStatement(
|
| - toAnalyzerToken(beginToken),
|
| + toAnalyzerToken(forKeyword),
|
| toAnalyzerToken(leftParenthesis),
|
| - variables?.variables,
|
| - null, // initialization.
|
| - variables?.semicolon,
|
| - condition.expression,
|
| - condition.semicolon,
|
| + variableList,
|
| + initializer,
|
| + toAnalyzerToken(leftSeparator),
|
| + condition,
|
| + rightSeparator,
|
| updates,
|
| toAnalyzerToken(leftParenthesis.endGroup),
|
| body));
|
| @@ -701,9 +719,9 @@ class AstBuilder extends ScopeListener {
|
| Statement body = pop();
|
| Expression iterator = pop();
|
| Object variableOrDeclaration = pop();
|
| - pop(); // local scope
|
| - pop(); // continue target
|
| - pop(); // break target
|
| + exitLocalScope();
|
| + exitContinueTarget();
|
| + exitBreakTarget();
|
| if (variableOrDeclaration is SimpleIdentifier) {
|
| push(ast.forEachStatementWithReference(
|
| toAnalyzerToken(awaitToken),
|
| @@ -1068,8 +1086,8 @@ class AstBuilder extends ScopeListener {
|
| debugEvent("DoWhileStatement");
|
| ParenthesizedExpression condition = pop();
|
| Statement body = pop();
|
| - pop(); // continue target
|
| - pop(); // break target
|
| + exitContinueTarget();
|
| + exitBreakTarget();
|
| push(ast.doStatement(
|
| toAnalyzerToken(doKeyword),
|
| body,
|
|
|