| 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 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
| 6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
| 7 | 7 |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 bool for_promise_reject; | 666 bool for_promise_reject; |
| 667 ZoneList<const AstRawString*> bound_names; | 667 ZoneList<const AstRawString*> bound_names; |
| 668 TailCallExpressionList tail_call_expressions; | 668 TailCallExpressionList tail_call_expressions; |
| 669 }; | 669 }; |
| 670 | 670 |
| 671 struct ForInfo { | 671 struct ForInfo { |
| 672 public: | 672 public: |
| 673 explicit ForInfo(ParserBase* parser) | 673 explicit ForInfo(ParserBase* parser) |
| 674 : bound_names(1, parser->zone()), | 674 : bound_names(1, parser->zone()), |
| 675 mode(ForEachStatement::ENUMERATE), | 675 mode(ForEachStatement::ENUMERATE), |
| 676 each_loc(), | 676 position(kNoSourcePosition), |
| 677 parsing_result() {} | 677 parsing_result() {} |
| 678 ZoneList<const AstRawString*> bound_names; | 678 ZoneList<const AstRawString*> bound_names; |
| 679 ForEachStatement::VisitMode mode; | 679 ForEachStatement::VisitMode mode; |
| 680 Scanner::Location each_loc; | 680 int position; |
| 681 DeclarationParsingResult parsing_result; | 681 DeclarationParsingResult parsing_result; |
| 682 }; | 682 }; |
| 683 | 683 |
| 684 struct ClassInfo { | 684 struct ClassInfo { |
| 685 public: | 685 public: |
| 686 explicit ClassInfo(ParserBase* parser) | 686 explicit ClassInfo(ParserBase* parser) |
| 687 : proxy(nullptr), | 687 : proxy(nullptr), |
| 688 extends(parser->impl()->EmptyExpression()), | 688 extends(parser->impl()->EmptyExpression()), |
| 689 properties(parser->impl()->NewClassPropertyList(4)), | 689 properties(parser->impl()->NewClassPropertyList(4)), |
| 690 instance_field_initializers(parser->impl()->NewExpressionList(0)), | 690 instance_field_initializers(parser->impl()->NewExpressionList(0)), |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 /* falls through */ | 1763 /* falls through */ |
| 1764 case Token::IDENTIFIER: | 1764 case Token::IDENTIFIER: |
| 1765 case Token::LET: | 1765 case Token::LET: |
| 1766 case Token::STATIC: | 1766 case Token::STATIC: |
| 1767 case Token::YIELD: | 1767 case Token::YIELD: |
| 1768 case Token::AWAIT: | 1768 case Token::AWAIT: |
| 1769 case Token::ESCAPED_STRICT_RESERVED_WORD: | 1769 case Token::ESCAPED_STRICT_RESERVED_WORD: |
| 1770 case Token::FUTURE_STRICT_RESERVED_WORD: { | 1770 case Token::FUTURE_STRICT_RESERVED_WORD: { |
| 1771 // Using eval or arguments in this context is OK even in strict mode. | 1771 // Using eval or arguments in this context is OK even in strict mode. |
| 1772 IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK); | 1772 IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK); |
| 1773 return impl()->ExpressionFromIdentifier(name, beg_pos, | 1773 return impl()->ExpressionFromIdentifier(name, beg_pos); |
| 1774 scanner()->location().end_pos); | |
| 1775 } | 1774 } |
| 1776 | 1775 |
| 1777 case Token::STRING: { | 1776 case Token::STRING: { |
| 1778 BindingPatternUnexpectedToken(); | 1777 BindingPatternUnexpectedToken(); |
| 1779 Consume(Token::STRING); | 1778 Consume(Token::STRING); |
| 1780 return impl()->ExpressionFromString(beg_pos); | 1779 return impl()->ExpressionFromString(beg_pos); |
| 1781 } | 1780 } |
| 1782 | 1781 |
| 1783 case Token::ASSIGN_DIV: | 1782 case Token::ASSIGN_DIV: |
| 1784 case Token::DIV: | 1783 case Token::DIV: |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2385 if (name_token == Token::LET) { | 2384 if (name_token == Token::LET) { |
| 2386 classifier()->RecordLetPatternError( | 2385 classifier()->RecordLetPatternError( |
| 2387 scanner()->location(), MessageTemplate::kLetInLexicalBinding); | 2386 scanner()->location(), MessageTemplate::kLetInLexicalBinding); |
| 2388 } | 2387 } |
| 2389 if (name_token == Token::AWAIT) { | 2388 if (name_token == Token::AWAIT) { |
| 2390 DCHECK(!is_async_function()); | 2389 DCHECK(!is_async_function()); |
| 2391 classifier()->RecordAsyncArrowFormalParametersError( | 2390 classifier()->RecordAsyncArrowFormalParametersError( |
| 2392 Scanner::Location(next_beg_pos, next_end_pos), | 2391 Scanner::Location(next_beg_pos, next_end_pos), |
| 2393 MessageTemplate::kAwaitBindingIdentifier); | 2392 MessageTemplate::kAwaitBindingIdentifier); |
| 2394 } | 2393 } |
| 2395 ExpressionT lhs = | 2394 ExpressionT lhs = impl()->ExpressionFromIdentifier(name, next_beg_pos); |
| 2396 impl()->ExpressionFromIdentifier(name, next_beg_pos, next_end_pos); | |
| 2397 CheckDestructuringElement(lhs, next_beg_pos, next_end_pos); | 2395 CheckDestructuringElement(lhs, next_beg_pos, next_end_pos); |
| 2398 | 2396 |
| 2399 ExpressionT value; | 2397 ExpressionT value; |
| 2400 if (peek() == Token::ASSIGN) { | 2398 if (peek() == Token::ASSIGN) { |
| 2401 Consume(Token::ASSIGN); | 2399 Consume(Token::ASSIGN); |
| 2402 ExpressionClassifier rhs_classifier(this); | 2400 ExpressionClassifier rhs_classifier(this); |
| 2403 ExpressionT rhs = ParseAssignmentExpression( | 2401 ExpressionT rhs = ParseAssignmentExpression( |
| 2404 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2402 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2405 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2403 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2406 impl()->AccumulateFormalParameterContainmentErrors(); | 2404 impl()->AccumulateFormalParameterContainmentErrors(); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 if (IsTrivialExpression()) { | 2651 if (IsTrivialExpression()) { |
| 2654 expression = ParsePrimaryExpression(&is_async, CHECK_OK); | 2652 expression = ParsePrimaryExpression(&is_async, CHECK_OK); |
| 2655 } else { | 2653 } else { |
| 2656 expression = ParseConditionalExpression(accept_IN, CHECK_OK); | 2654 expression = ParseConditionalExpression(accept_IN, CHECK_OK); |
| 2657 } | 2655 } |
| 2658 | 2656 |
| 2659 if (is_async && impl()->IsIdentifier(expression) && peek_any_identifier() && | 2657 if (is_async && impl()->IsIdentifier(expression) && peek_any_identifier() && |
| 2660 PeekAhead() == Token::ARROW) { | 2658 PeekAhead() == Token::ARROW) { |
| 2661 // async Identifier => AsyncConciseBody | 2659 // async Identifier => AsyncConciseBody |
| 2662 IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK); | 2660 IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK); |
| 2663 expression = impl()->ExpressionFromIdentifier( | 2661 expression = |
| 2664 name, position(), scanner()->location().end_pos, InferName::kNo); | 2662 impl()->ExpressionFromIdentifier(name, position(), InferName::kNo); |
| 2665 if (fni_) { | 2663 if (fni_) { |
| 2666 // Remove `async` keyword from inferred name stack. | 2664 // Remove `async` keyword from inferred name stack. |
| 2667 fni_->RemoveAsyncKeywordFromEnd(); | 2665 fni_->RemoveAsyncKeywordFromEnd(); |
| 2668 } | 2666 } |
| 2669 } | 2667 } |
| 2670 | 2668 |
| 2671 if (peek() == Token::ARROW) { | 2669 if (peek() == Token::ARROW) { |
| 2672 Scanner::Location arrow_loc = scanner()->peek_location(); | 2670 Scanner::Location arrow_loc = scanner()->peek_location(); |
| 2673 ValidateArrowFormalParameters(expression, parenthesized_formals, is_async, | 2671 ValidateArrowFormalParameters(expression, parenthesized_formals, is_async, |
| 2674 CHECK_OK); | 2672 CHECK_OK); |
| (...skipping 2496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5171 StatementT init = impl()->NullStatement(); | 5169 StatementT init = impl()->NullStatement(); |
| 5172 if (peek() != Token::SEMICOLON) { | 5170 if (peek() != Token::SEMICOLON) { |
| 5173 // An initializer is present. | 5171 // An initializer is present. |
| 5174 if (peek() == Token::VAR || peek() == Token::CONST || | 5172 if (peek() == Token::VAR || peek() == Token::CONST || |
| 5175 (peek() == Token::LET && IsNextLetKeyword())) { | 5173 (peek() == Token::LET && IsNextLetKeyword())) { |
| 5176 // The initializer contains declarations. | 5174 // The initializer contains declarations. |
| 5177 ParseVariableDeclarations(kForStatement, &for_info.parsing_result, | 5175 ParseVariableDeclarations(kForStatement, &for_info.parsing_result, |
| 5178 nullptr, CHECK_OK); | 5176 nullptr, CHECK_OK); |
| 5179 bound_names_are_lexical = | 5177 bound_names_are_lexical = |
| 5180 IsLexicalVariableMode(for_info.parsing_result.descriptor.mode); | 5178 IsLexicalVariableMode(for_info.parsing_result.descriptor.mode); |
| 5181 for_info.each_loc = scanner()->location(); | 5179 for_info.position = scanner()->location().beg_pos; |
| 5182 | 5180 |
| 5183 if (CheckInOrOf(&for_info.mode)) { | 5181 if (CheckInOrOf(&for_info.mode)) { |
| 5184 // Just one declaration followed by in/of. | 5182 // Just one declaration followed by in/of. |
| 5185 if (for_info.parsing_result.declarations.length() != 1) { | 5183 if (for_info.parsing_result.declarations.length() != 1) { |
| 5186 impl()->ReportMessageAt( | 5184 impl()->ReportMessageAt( |
| 5187 for_info.parsing_result.bindings_loc, | 5185 for_info.parsing_result.bindings_loc, |
| 5188 MessageTemplate::kForInOfLoopMultiBindings, | 5186 MessageTemplate::kForInOfLoopMultiBindings, |
| 5189 ForEachStatement::VisitModeString(for_info.mode)); | 5187 ForEachStatement::VisitModeString(for_info.mode)); |
| 5190 *ok = false; | 5188 *ok = false; |
| 5191 return impl()->NullStatement(); | 5189 return impl()->NullStatement(); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5463 has_seen_constructor_ = true; | 5461 has_seen_constructor_ = true; |
| 5464 return; | 5462 return; |
| 5465 } | 5463 } |
| 5466 } | 5464 } |
| 5467 | 5465 |
| 5468 | 5466 |
| 5469 } // namespace internal | 5467 } // namespace internal |
| 5470 } // namespace v8 | 5468 } // namespace v8 |
| 5471 | 5469 |
| 5472 #endif // V8_PARSING_PARSER_BASE_H | 5470 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |