Chromium Code Reviews| 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/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
| 10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
| (...skipping 3658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3669 // } | 3669 // } |
| 3670 // let x; // for TDZ | 3670 // let x; // for TDZ |
| 3671 // } | 3671 // } |
| 3672 | 3672 |
| 3673 Variable* temp = | 3673 Variable* temp = |
| 3674 scope_->NewTemporary(ast_value_factory()->dot_for_string()); | 3674 scope_->NewTemporary(ast_value_factory()->dot_for_string()); |
| 3675 ForEachStatement* loop = | 3675 ForEachStatement* loop = |
| 3676 factory()->NewForEachStatement(mode, labels, stmt_pos); | 3676 factory()->NewForEachStatement(mode, labels, stmt_pos); |
| 3677 Target target(&this->target_stack_, loop); | 3677 Target target(&this->target_stack_, loop); |
| 3678 | 3678 |
| 3679 Expression* enumerable = ParseExpression(true, CHECK_OK); | 3679 Expression* enumerable; |
| 3680 if (mode == ForEachStatement::ITERATE) { | |
| 3681 ExpressionClassifier classifier; | |
| 3682 enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK); | |
| 3683 ParserTraits::RewriteNonPattern(enumerable, &classifier, CHECK_OK); | |
|
adamk
2016/01/20 00:35:57
I think the calling convention here is to assign i
mike3
2016/01/20 17:55:40
Acknowledged.
| |
| 3684 } else { | |
| 3685 enumerable = ParseExpression(true, CHECK_OK); | |
| 3686 } | |
| 3680 | 3687 |
| 3681 Expect(Token::RPAREN, CHECK_OK); | 3688 Expect(Token::RPAREN, CHECK_OK); |
| 3682 | 3689 |
| 3683 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); | 3690 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); |
| 3684 body_scope->set_start_position(scanner()->location().beg_pos); | 3691 body_scope->set_start_position(scanner()->location().beg_pos); |
| 3685 | 3692 |
| 3686 Block* body_block = | 3693 Block* body_block = |
| 3687 factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition); | 3694 factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition); |
| 3688 | 3695 |
| 3689 { | 3696 { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3784 if (!is_destructuring) { | 3791 if (!is_destructuring) { |
| 3785 expression = this->CheckAndRewriteReferenceExpression( | 3792 expression = this->CheckAndRewriteReferenceExpression( |
| 3786 expression, lhs_beg_pos, lhs_end_pos, | 3793 expression, lhs_beg_pos, lhs_end_pos, |
| 3787 MessageTemplate::kInvalidLhsInFor, kSyntaxError, CHECK_OK); | 3794 MessageTemplate::kInvalidLhsInFor, kSyntaxError, CHECK_OK); |
| 3788 } | 3795 } |
| 3789 | 3796 |
| 3790 ForEachStatement* loop = | 3797 ForEachStatement* loop = |
| 3791 factory()->NewForEachStatement(mode, labels, stmt_pos); | 3798 factory()->NewForEachStatement(mode, labels, stmt_pos); |
| 3792 Target target(&this->target_stack_, loop); | 3799 Target target(&this->target_stack_, loop); |
| 3793 | 3800 |
| 3794 Expression* enumerable = ParseExpression(true, CHECK_OK); | 3801 Expression* enumerable; |
| 3802 if (mode == ForEachStatement::ITERATE) { | |
| 3803 ExpressionClassifier classifier; | |
| 3804 enumerable = ParseAssignmentExpression(true, &classifier, CHECK_OK); | |
| 3805 ParserTraits::RewriteNonPattern(enumerable, &classifier, CHECK_OK); | |
|
adamk
2016/01/20 00:35:57
Same note here.
mike3
2016/01/20 17:55:40
Acknowledged.
| |
| 3806 } else { | |
| 3807 enumerable = ParseExpression(true, CHECK_OK); | |
| 3808 } | |
| 3809 | |
| 3795 Expect(Token::RPAREN, CHECK_OK); | 3810 Expect(Token::RPAREN, CHECK_OK); |
| 3796 | 3811 |
| 3797 // Make a block around the statement in case a lexical binding | 3812 // Make a block around the statement in case a lexical binding |
| 3798 // is introduced, e.g. by a FunctionDeclaration. | 3813 // is introduced, e.g. by a FunctionDeclaration. |
| 3799 // This block must not use for_scope as its scope because if a | 3814 // This block must not use for_scope as its scope because if a |
| 3800 // lexical binding is introduced which overlaps with the for-in/of, | 3815 // lexical binding is introduced which overlaps with the for-in/of, |
| 3801 // expressions in head of the loop should actually have variables | 3816 // expressions in head of the loop should actually have variables |
| 3802 // resolved in the outer scope. | 3817 // resolved in the outer scope. |
| 3803 Scope* body_scope = NewScope(for_scope, BLOCK_SCOPE); | 3818 Scope* body_scope = NewScope(for_scope, BLOCK_SCOPE); |
| 3804 BlockState block_state(&scope_, body_scope); | 3819 BlockState block_state(&scope_, body_scope); |
| (...skipping 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5736 auto class_literal = value->AsClassLiteral(); | 5751 auto class_literal = value->AsClassLiteral(); |
| 5737 if (class_literal->raw_name() == nullptr) { | 5752 if (class_literal->raw_name() == nullptr) { |
| 5738 class_literal->set_raw_name(name); | 5753 class_literal->set_raw_name(name); |
| 5739 } | 5754 } |
| 5740 } | 5755 } |
| 5741 } | 5756 } |
| 5742 | 5757 |
| 5743 | 5758 |
| 5744 } // namespace internal | 5759 } // namespace internal |
| 5745 } // namespace v8 | 5760 } // namespace v8 |
| OLD | NEW |