| 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_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
| 6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
| 7 | 7 |
| 8 #include "src/bailout-reason.h" | 8 #include "src/bailout-reason.h" |
| 9 #include "src/expression-classifier.h" | 9 #include "src/expression-classifier.h" |
| 10 #include "src/func-name-inferrer.h" | 10 #include "src/func-name-inferrer.h" |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 ExpressionT ParseUnaryExpression(ExpressionClassifier* classifier, bool* ok); | 707 ExpressionT ParseUnaryExpression(ExpressionClassifier* classifier, bool* ok); |
| 708 ExpressionT ParsePostfixExpression(ExpressionClassifier* classifier, | 708 ExpressionT ParsePostfixExpression(ExpressionClassifier* classifier, |
| 709 bool* ok); | 709 bool* ok); |
| 710 ExpressionT ParseLeftHandSideExpression(ExpressionClassifier* classifier, | 710 ExpressionT ParseLeftHandSideExpression(ExpressionClassifier* classifier, |
| 711 bool* ok); | 711 bool* ok); |
| 712 ExpressionT ParseMemberWithNewPrefixesExpression( | 712 ExpressionT ParseMemberWithNewPrefixesExpression( |
| 713 ExpressionClassifier* classifier, bool* ok); | 713 ExpressionClassifier* classifier, bool* ok); |
| 714 ExpressionT ParseMemberExpression(ExpressionClassifier* classifier, bool* ok); | 714 ExpressionT ParseMemberExpression(ExpressionClassifier* classifier, bool* ok); |
| 715 ExpressionT ParseMemberExpressionContinuation( | 715 ExpressionT ParseMemberExpressionContinuation( |
| 716 ExpressionT expression, ExpressionClassifier* classifier, bool* ok); | 716 ExpressionT expression, ExpressionClassifier* classifier, bool* ok); |
| 717 ExpressionT ParseArrowFunctionLiteral( | 717 ExpressionT ParseArrowFunctionLiteral(bool accept_IN, |
| 718 const FormalParametersT& parameters, | 718 const FormalParametersT& parameters, |
| 719 const ExpressionClassifier& classifier, bool* ok); | 719 const ExpressionClassifier& classifier, |
| 720 bool* ok); |
| 720 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, | 721 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, |
| 721 ExpressionClassifier* classifier, bool* ok); | 722 ExpressionClassifier* classifier, bool* ok); |
| 722 void AddTemplateExpression(ExpressionT); | 723 void AddTemplateExpression(ExpressionT); |
| 723 ExpressionT ParseSuperExpression(bool is_new, | 724 ExpressionT ParseSuperExpression(bool is_new, |
| 724 ExpressionClassifier* classifier, bool* ok); | 725 ExpressionClassifier* classifier, bool* ok); |
| 725 ExpressionT ParseNewTargetExpression(bool* ok); | 726 ExpressionT ParseNewTargetExpression(bool* ok); |
| 726 ExpressionT ParseStrongInitializationExpression( | 727 ExpressionT ParseStrongInitializationExpression( |
| 727 ExpressionClassifier* classifier, bool* ok); | 728 ExpressionClassifier* classifier, bool* ok); |
| 728 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, | 729 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, |
| 729 bool* ok); | 730 bool* ok); |
| (...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2939 &duplicate_loc, CHECK_OK); | 2940 &duplicate_loc, CHECK_OK); |
| 2940 | 2941 |
| 2941 checkpoint.Restore(¶meters.materialized_literals_count); | 2942 checkpoint.Restore(¶meters.materialized_literals_count); |
| 2942 | 2943 |
| 2943 scope->set_start_position(lhs_beg_pos); | 2944 scope->set_start_position(lhs_beg_pos); |
| 2944 if (duplicate_loc.IsValid()) { | 2945 if (duplicate_loc.IsValid()) { |
| 2945 arrow_formals_classifier.RecordDuplicateFormalParameterError( | 2946 arrow_formals_classifier.RecordDuplicateFormalParameterError( |
| 2946 duplicate_loc); | 2947 duplicate_loc); |
| 2947 } | 2948 } |
| 2948 expression = this->ParseArrowFunctionLiteral( | 2949 expression = this->ParseArrowFunctionLiteral( |
| 2949 parameters, arrow_formals_classifier, CHECK_OK); | 2950 accept_IN, parameters, arrow_formals_classifier, CHECK_OK); |
| 2950 return expression; | 2951 return expression; |
| 2951 } | 2952 } |
| 2952 | 2953 |
| 2953 // "expression" was not itself an arrow function parameter list, but it might | 2954 // "expression" was not itself an arrow function parameter list, but it might |
| 2954 // form part of one. Propagate speculative formal parameter error locations. | 2955 // form part of one. Propagate speculative formal parameter error locations. |
| 2955 classifier->Accumulate(arrow_formals_classifier, | 2956 classifier->Accumulate(arrow_formals_classifier, |
| 2956 ExpressionClassifier::StandardProductions | | 2957 ExpressionClassifier::StandardProductions | |
| 2957 ExpressionClassifier::FormalParametersProductions); | 2958 ExpressionClassifier::FormalParametersProductions); |
| 2958 | 2959 |
| 2959 if (!Token::IsAssignmentOp(peek())) { | 2960 if (!Token::IsAssignmentOp(peek())) { |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3875 return true; | 3876 return true; |
| 3876 default: | 3877 default: |
| 3877 return false; | 3878 return false; |
| 3878 } | 3879 } |
| 3879 } | 3880 } |
| 3880 | 3881 |
| 3881 | 3882 |
| 3882 template <class Traits> | 3883 template <class Traits> |
| 3883 typename ParserBase<Traits>::ExpressionT | 3884 typename ParserBase<Traits>::ExpressionT |
| 3884 ParserBase<Traits>::ParseArrowFunctionLiteral( | 3885 ParserBase<Traits>::ParseArrowFunctionLiteral( |
| 3885 const FormalParametersT& formal_parameters, | 3886 bool accept_IN, const FormalParametersT& formal_parameters, |
| 3886 const ExpressionClassifier& formals_classifier, bool* ok) { | 3887 const ExpressionClassifier& formals_classifier, bool* ok) { |
| 3887 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { | 3888 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { |
| 3888 // ASI inserts `;` after arrow parameters if a line terminator is found. | 3889 // ASI inserts `;` after arrow parameters if a line terminator is found. |
| 3889 // `=> ...` is never a valid expression, so report as syntax error. | 3890 // `=> ...` is never a valid expression, so report as syntax error. |
| 3890 // If next token is not `=>`, it's a syntax error anyways. | 3891 // If next token is not `=>`, it's a syntax error anyways. |
| 3891 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); | 3892 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); |
| 3892 *ok = false; | 3893 *ok = false; |
| 3893 return this->EmptyExpression(); | 3894 return this->EmptyExpression(); |
| 3894 } | 3895 } |
| 3895 | 3896 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3933 materialized_literal_count = | 3934 materialized_literal_count = |
| 3934 function_state.materialized_literal_count(); | 3935 function_state.materialized_literal_count(); |
| 3935 expected_property_count = function_state.expected_property_count(); | 3936 expected_property_count = function_state.expected_property_count(); |
| 3936 } | 3937 } |
| 3937 } else { | 3938 } else { |
| 3938 // Single-expression body | 3939 // Single-expression body |
| 3939 int pos = position(); | 3940 int pos = position(); |
| 3940 parenthesized_function_ = false; | 3941 parenthesized_function_ = false; |
| 3941 ExpressionClassifier classifier; | 3942 ExpressionClassifier classifier; |
| 3942 ExpressionT expression = | 3943 ExpressionT expression = |
| 3943 ParseAssignmentExpression(true, &classifier, CHECK_OK); | 3944 ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK); |
| 3944 ValidateExpression(&classifier, CHECK_OK); | 3945 ValidateExpression(&classifier, CHECK_OK); |
| 3945 body = this->NewStatementList(1, zone()); | 3946 body = this->NewStatementList(1, zone()); |
| 3946 this->AddParameterInitializationBlock(formal_parameters, body, CHECK_OK); | 3947 this->AddParameterInitializationBlock(formal_parameters, body, CHECK_OK); |
| 3947 body->Add(factory()->NewReturnStatement(expression, pos), zone()); | 3948 body->Add(factory()->NewReturnStatement(expression, pos), zone()); |
| 3948 materialized_literal_count = function_state.materialized_literal_count(); | 3949 materialized_literal_count = function_state.materialized_literal_count(); |
| 3949 expected_property_count = function_state.expected_property_count(); | 3950 expected_property_count = function_state.expected_property_count(); |
| 3950 } | 3951 } |
| 3951 super_loc = function_state.super_location(); | 3952 super_loc = function_state.super_location(); |
| 3952 | 3953 |
| 3953 formal_parameters.scope->set_end_position(scanner()->location().end_pos); | 3954 formal_parameters.scope->set_end_position(scanner()->location().end_pos); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4186 return; | 4187 return; |
| 4187 } | 4188 } |
| 4188 has_seen_constructor_ = true; | 4189 has_seen_constructor_ = true; |
| 4189 return; | 4190 return; |
| 4190 } | 4191 } |
| 4191 } | 4192 } |
| 4192 } // namespace internal | 4193 } // namespace internal |
| 4193 } // namespace v8 | 4194 } // namespace v8 |
| 4194 | 4195 |
| 4195 #endif // V8_PREPARSER_H | 4196 #endif // V8_PREPARSER_H |
| OLD | NEW |