Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index 816849748869720029796504e4d282dc6ca1bb2e..4e7333986da84969be8011181dcdfe05968065a8 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -3222,7 +3222,10 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( |
| // let/const x = i; |
| // temp_x = x; |
| // first = 1; |
| + // undefined; |
| // outer: for (;;) { |
| + // { // Nothing inside this block can affect the normal completion value. |
|
rossberg
2015/06/18 05:43:21
Nit: adjust indentation. Also, the comment seems a
conradw
2015/06/18 10:53:32
rewritten
|
| + // // No new lexical scope is introduced. |
| // let/const x = temp_x; |
| // if (first == 1) { |
| // first = 0; |
| @@ -3230,6 +3233,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( |
| // next; |
| // } |
| // flag = 1; |
| + // } |
| // labels: for (; flag == 1; flag = 0, temp_x = x) { |
| // if (cond) { |
| // body |
| @@ -3282,6 +3286,13 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( |
| outer_block->AddStatement(assignment_statement, zone()); |
| } |
| + // make statement: undefined; |
| + outer_block->AddStatement( |
| + factory()->NewExpressionStatement( |
| + factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), |
| + RelocInfo::kNoPosition), |
| + zone()); |
| + |
| // Make statement: outer: for (;;) |
| // Note that we don't actually create the label, or set this loop up as an |
| // explicit break target, instead handing it directly to those nodes that |
| @@ -3294,8 +3305,10 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( |
| outer_block->set_scope(for_scope); |
| scope_ = inner_scope; |
| - Block* inner_block = factory()->NewBlock(NULL, names->length() + 4, false, |
| - RelocInfo::kNoPosition); |
| + Block* inner_block = |
| + factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition); |
| + Block* ignore_completion_block = factory()->NewBlock( |
| + NULL, names->length() + 2, true, RelocInfo::kNoPosition); |
| ZoneList<Variable*> inner_vars(names->length(), zone()); |
| // For each let variable x: |
| // make statement: let/const x = temp_x. |
| @@ -3314,7 +3327,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( |
| factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
| DCHECK(init->position() != RelocInfo::kNoPosition); |
| proxy->var()->set_initializer_position(init->position()); |
| - inner_block->AddStatement(assignment_statement, zone()); |
| + ignore_completion_block->AddStatement(assignment_statement, zone()); |
| } |
| // Make statement: if (first == 1) { first = 0; } else { next; } |
| @@ -3340,7 +3353,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( |
| } |
| Statement* clear_first_or_next = factory()->NewIfStatement( |
| compare, clear_first, next, RelocInfo::kNoPosition); |
| - inner_block->AddStatement(clear_first_or_next, zone()); |
| + ignore_completion_block->AddStatement(clear_first_or_next, zone()); |
| } |
| Variable* flag = scope_->DeclarationScope()->NewTemporary(temp_name); |
| @@ -3352,9 +3365,9 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( |
| Token::ASSIGN, flag_proxy, const1, RelocInfo::kNoPosition); |
| Statement* assignment_statement = |
| factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
| - inner_block->AddStatement(assignment_statement, zone()); |
| + ignore_completion_block->AddStatement(assignment_statement, zone()); |
| } |
| - |
| + inner_block->AddStatement(ignore_completion_block, zone()); |
| // Make cond expression for main loop: flag == 1. |
| Expression* flag_cond = NULL; |
| { |
| @@ -3402,7 +3415,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( |
| } |
| // Make statement: labels: for (; flag == 1; flag = 0, temp_x = x) |
| - // Note that we re-use the original loop node, which retains it labels |
| + // Note that we re-use the original loop node, which retains its labels |
| // and ensures that any break or continue statements in body point to |
| // the right place. |
| loop->Initialize(NULL, flag_cond, compound_next_statement, body_or_stop); |