| 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/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 ExpressionClassifier* classifier, bool* ok); | 886 ExpressionClassifier* classifier, bool* ok); |
| 887 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, | 887 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, |
| 888 bool* ok); | 888 bool* ok); |
| 889 | 889 |
| 890 void ParseFormalParameter(FormalParameterScopeT* scope, bool is_rest, | 890 void ParseFormalParameter(FormalParameterScopeT* scope, bool is_rest, |
| 891 ExpressionClassifier* classifier, bool* ok); | 891 ExpressionClassifier* classifier, bool* ok); |
| 892 int ParseFormalParameterList(FormalParameterScopeT* scope, bool* has_rest, | 892 int ParseFormalParameterList(FormalParameterScopeT* scope, bool* has_rest, |
| 893 ExpressionClassifier* classifier, bool* ok); | 893 ExpressionClassifier* classifier, bool* ok); |
| 894 void CheckArityRestrictions( | 894 void CheckArityRestrictions( |
| 895 int param_count, FunctionLiteral::ArityRestriction arity_restriction, | 895 int param_count, FunctionLiteral::ArityRestriction arity_restriction, |
| 896 int formals_start_pos, int formals_end_pos, bool* ok); | 896 bool has_rest, int formals_start_pos, int formals_end_pos, bool* ok); |
| 897 | 897 |
| 898 // Checks if the expression is a valid reference expression (e.g., on the | 898 // Checks if the expression is a valid reference expression (e.g., on the |
| 899 // left-hand side of assignments). Although ruled out by ECMA as early errors, | 899 // left-hand side of assignments). Although ruled out by ECMA as early errors, |
| 900 // we allow calls for web compatibility and rewrite them to a runtime throw. | 900 // we allow calls for web compatibility and rewrite them to a runtime throw. |
| 901 ExpressionT CheckAndRewriteReferenceExpression( | 901 ExpressionT CheckAndRewriteReferenceExpression( |
| 902 ExpressionT expression, Scanner::Location location, | 902 ExpressionT expression, Scanner::Location location, |
| 903 MessageTemplate::Template message, bool* ok); | 903 MessageTemplate::Template message, bool* ok); |
| 904 | 904 |
| 905 // Used to validate property names in object literals and class literals | 905 // Used to validate property names in object literals and class literals |
| 906 enum PropertyKind { | 906 enum PropertyKind { |
| (...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3644 } | 3644 } |
| 3645 } | 3645 } |
| 3646 | 3646 |
| 3647 return parameter_count; | 3647 return parameter_count; |
| 3648 } | 3648 } |
| 3649 | 3649 |
| 3650 | 3650 |
| 3651 template <class Traits> | 3651 template <class Traits> |
| 3652 void ParserBase<Traits>::CheckArityRestrictions( | 3652 void ParserBase<Traits>::CheckArityRestrictions( |
| 3653 int param_count, FunctionLiteral::ArityRestriction arity_restriction, | 3653 int param_count, FunctionLiteral::ArityRestriction arity_restriction, |
| 3654 int formals_start_pos, int formals_end_pos, bool* ok) { | 3654 bool has_rest, int formals_start_pos, int formals_end_pos, bool* ok) { |
| 3655 switch (arity_restriction) { | 3655 switch (arity_restriction) { |
| 3656 case FunctionLiteral::GETTER_ARITY: | 3656 case FunctionLiteral::GETTER_ARITY: |
| 3657 if (param_count != 0) { | 3657 if (param_count != 0) { |
| 3658 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), | 3658 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), |
| 3659 MessageTemplate::kBadGetterArity); | 3659 MessageTemplate::kBadGetterArity); |
| 3660 *ok = false; | 3660 *ok = false; |
| 3661 } | 3661 } |
| 3662 break; | 3662 break; |
| 3663 case FunctionLiteral::SETTER_ARITY: | 3663 case FunctionLiteral::SETTER_ARITY: |
| 3664 if (param_count != 1) { | 3664 if (param_count != 1) { |
| 3665 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), | 3665 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), |
| 3666 MessageTemplate::kBadSetterArity); | 3666 MessageTemplate::kBadSetterArity); |
| 3667 *ok = false; | 3667 *ok = false; |
| 3668 } | 3668 } |
| 3669 if (has_rest) { |
| 3670 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), |
| 3671 MessageTemplate::kBadSetterRestParameter); |
| 3672 *ok = false; |
| 3673 } |
| 3669 break; | 3674 break; |
| 3670 default: | 3675 default: |
| 3671 break; | 3676 break; |
| 3672 } | 3677 } |
| 3673 } | 3678 } |
| 3674 | 3679 |
| 3675 | 3680 |
| 3676 template <class Traits> | 3681 template <class Traits> |
| 3677 typename ParserBase<Traits>::ExpressionT | 3682 typename ParserBase<Traits>::ExpressionT |
| 3678 ParserBase<Traits>::ParseArrowFunctionLiteral( | 3683 ParserBase<Traits>::ParseArrowFunctionLiteral( |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3955 *ok = false; | 3960 *ok = false; |
| 3956 return; | 3961 return; |
| 3957 } | 3962 } |
| 3958 has_seen_constructor_ = true; | 3963 has_seen_constructor_ = true; |
| 3959 return; | 3964 return; |
| 3960 } | 3965 } |
| 3961 } | 3966 } |
| 3962 } } // v8::internal | 3967 } } // v8::internal |
| 3963 | 3968 |
| 3964 #endif // V8_PREPARSER_H | 3969 #endif // V8_PREPARSER_H |
| OLD | NEW |