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 3507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3518 Expect(Token::LPAREN, CHECK_OK); | 3518 Expect(Token::LPAREN, CHECK_OK); |
3519 for_scope->set_start_position(scanner()->location().beg_pos); | 3519 for_scope->set_start_position(scanner()->location().beg_pos); |
3520 bool is_let_identifier_expression = false; | 3520 bool is_let_identifier_expression = false; |
3521 DeclarationParsingResult parsing_result; | 3521 DeclarationParsingResult parsing_result; |
3522 if (peek() != Token::SEMICOLON) { | 3522 if (peek() != Token::SEMICOLON) { |
3523 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) || | 3523 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) || |
3524 (peek() == Token::LET && IsNextLetKeyword())) { | 3524 (peek() == Token::LET && IsNextLetKeyword())) { |
3525 ParseVariableDeclarations(kForStatement, &parsing_result, nullptr, | 3525 ParseVariableDeclarations(kForStatement, &parsing_result, nullptr, |
3526 CHECK_OK); | 3526 CHECK_OK); |
3527 | 3527 |
3528 ForEachStatement::VisitMode mode; | 3528 ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE; |
3529 int each_beg_pos = scanner()->location().beg_pos; | 3529 int each_beg_pos = scanner()->location().beg_pos; |
3530 int each_end_pos = scanner()->location().end_pos; | 3530 int each_end_pos = scanner()->location().end_pos; |
3531 | 3531 |
3532 if (CheckInOrOf(&mode, ok)) { | 3532 if (CheckInOrOf(&mode, ok)) { |
3533 if (!*ok) return nullptr; | 3533 if (!*ok) return nullptr; |
3534 if (parsing_result.declarations.length() != 1) { | 3534 if (parsing_result.declarations.length() != 1) { |
3535 ParserTraits::ReportMessageAt( | 3535 ParserTraits::ReportMessageAt( |
3536 parsing_result.bindings_loc, | 3536 parsing_result.bindings_loc, |
3537 MessageTemplate::kForInOfLoopMultiBindings, | 3537 MessageTemplate::kForInOfLoopMultiBindings, |
3538 ForEachStatement::VisitModeString(mode)); | 3538 ForEachStatement::VisitModeString(mode)); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3685 IsLexicalVariableMode(parsing_result.descriptor.mode) | 3685 IsLexicalVariableMode(parsing_result.descriptor.mode) |
3686 ? &lexical_bindings | 3686 ? &lexical_bindings |
3687 : nullptr, | 3687 : nullptr, |
3688 CHECK_OK); | 3688 CHECK_OK); |
3689 } | 3689 } |
3690 } else { | 3690 } else { |
3691 int lhs_beg_pos = peek_position(); | 3691 int lhs_beg_pos = peek_position(); |
3692 ExpressionClassifier classifier(this); | 3692 ExpressionClassifier classifier(this); |
3693 Expression* expression = ParseExpression(false, &classifier, CHECK_OK); | 3693 Expression* expression = ParseExpression(false, &classifier, CHECK_OK); |
3694 int lhs_end_pos = scanner()->location().end_pos; | 3694 int lhs_end_pos = scanner()->location().end_pos; |
3695 ForEachStatement::VisitMode mode; | 3695 ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE; |
3696 is_let_identifier_expression = | 3696 is_let_identifier_expression = |
3697 expression->IsVariableProxy() && | 3697 expression->IsVariableProxy() && |
3698 expression->AsVariableProxy()->raw_name() == | 3698 expression->AsVariableProxy()->raw_name() == |
3699 ast_value_factory()->let_string(); | 3699 ast_value_factory()->let_string(); |
3700 | 3700 |
3701 bool is_for_each = CheckInOrOf(&mode, ok); | 3701 bool is_for_each = CheckInOrOf(&mode, ok); |
3702 if (!*ok) return nullptr; | 3702 if (!*ok) return nullptr; |
3703 bool is_destructuring = | 3703 bool is_destructuring = |
3704 is_for_each && allow_harmony_destructuring_assignment() && | 3704 is_for_each && allow_harmony_destructuring_assignment() && |
3705 (expression->IsArrayLiteral() || expression->IsObjectLiteral()); | 3705 (expression->IsArrayLiteral() || expression->IsObjectLiteral()); |
(...skipping 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6805 try_block, target); | 6805 try_block, target); |
6806 final_loop = target; | 6806 final_loop = target; |
6807 } | 6807 } |
6808 | 6808 |
6809 return final_loop; | 6809 return final_loop; |
6810 } | 6810 } |
6811 | 6811 |
6812 | 6812 |
6813 } // namespace internal | 6813 } // namespace internal |
6814 } // namespace v8 | 6814 } // namespace v8 |
OLD | NEW |