OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/parser.h" | 5 #include "src/parser.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/ast-literal-reindexer.h" | 9 #include "src/ast-literal-reindexer.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 3776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3787 | 3787 |
3788 ForEachStatement* loop = | 3788 ForEachStatement* loop = |
3789 factory()->NewForEachStatement(mode, labels, stmt_pos); | 3789 factory()->NewForEachStatement(mode, labels, stmt_pos); |
3790 Target target(&this->target_stack_, loop); | 3790 Target target(&this->target_stack_, loop); |
3791 | 3791 |
3792 Expression* enumerable = ParseExpression(true, CHECK_OK); | 3792 Expression* enumerable = ParseExpression(true, CHECK_OK); |
3793 Expect(Token::RPAREN, CHECK_OK); | 3793 Expect(Token::RPAREN, CHECK_OK); |
3794 | 3794 |
3795 // Make a block around the statement in case a lexical binding | 3795 // Make a block around the statement in case a lexical binding |
3796 // is introduced, e.g. by a FunctionDeclaration. | 3796 // is introduced, e.g. by a FunctionDeclaration. |
3797 // This block must not be based on for_scope because if a lexical | |
rossberg
2015/10/13 10:52:04
What does "be based on" mean?
Dan Ehrenberg
2015/10/13 14:58:40
Clarified wording
| |
3798 // binding is introduced which overlaps with the for-in/of, the | |
3799 // top level should actually point to the outer scope. | |
3800 Scope* body_scope = NewScope(for_scope, BLOCK_SCOPE); | |
3801 scope_ = body_scope; | |
3797 Block* block = | 3802 Block* block = |
3798 factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition); | 3803 factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition); |
3799 Statement* body = ParseSubStatement(NULL, CHECK_OK); | 3804 Statement* body = ParseSubStatement(NULL, CHECK_OK); |
3800 block->statements()->Add(body, zone()); | 3805 block->statements()->Add(body, zone()); |
3801 InitializeForEachStatement(loop, expression, enumerable, block); | 3806 InitializeForEachStatement(loop, expression, enumerable, block); |
3802 scope_ = saved_scope; | 3807 scope_ = saved_scope; |
3808 body_scope->set_end_position(scanner()->location().end_pos); | |
3809 body_scope = body_scope->FinalizeBlockScope(); | |
3810 if (body_scope != nullptr) { | |
3811 block->set_scope(body_scope); | |
3812 } | |
3803 for_scope->set_end_position(scanner()->location().end_pos); | 3813 for_scope->set_end_position(scanner()->location().end_pos); |
3804 for_scope = for_scope->FinalizeBlockScope(); | 3814 for_scope = for_scope->FinalizeBlockScope(); |
3805 if (for_scope != nullptr) { | 3815 DCHECK(for_scope == nullptr); |
3806 block->set_scope(for_scope); | |
3807 } | |
3808 // Parsed for-in loop. | 3816 // Parsed for-in loop. |
3809 return loop; | 3817 return loop; |
3810 | 3818 |
3811 } else { | 3819 } else { |
3812 init = factory()->NewExpressionStatement(expression, lhs_beg_pos); | 3820 init = factory()->NewExpressionStatement(expression, lhs_beg_pos); |
3813 } | 3821 } |
3814 } | 3822 } |
3815 } | 3823 } |
3816 | 3824 |
3817 // Standard 'for' loop | 3825 // Standard 'for' loop |
(...skipping 2524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6342 | 6350 |
6343 Expression* Parser::SpreadCallNew(Expression* function, | 6351 Expression* Parser::SpreadCallNew(Expression* function, |
6344 ZoneList<v8::internal::Expression*>* args, | 6352 ZoneList<v8::internal::Expression*>* args, |
6345 int pos) { | 6353 int pos) { |
6346 args->InsertAt(0, function, zone()); | 6354 args->InsertAt(0, function, zone()); |
6347 | 6355 |
6348 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); | 6356 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); |
6349 } | 6357 } |
6350 } // namespace internal | 6358 } // namespace internal |
6351 } // namespace v8 | 6359 } // namespace v8 |
OLD | NEW |