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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 ExpressionClassifier* classifier, bool* ok); | 874 ExpressionClassifier* classifier, bool* ok); |
875 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, | 875 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, |
876 bool* ok); | 876 bool* ok); |
877 | 877 |
878 void ParseFormalParameter(FormalParameterScopeT* scope, bool is_rest, | 878 void ParseFormalParameter(FormalParameterScopeT* scope, bool is_rest, |
879 ExpressionClassifier* classifier, bool* ok); | 879 ExpressionClassifier* classifier, bool* ok); |
880 int ParseFormalParameterList(FormalParameterScopeT* scope, bool* has_rest, | 880 int ParseFormalParameterList(FormalParameterScopeT* scope, bool* has_rest, |
881 ExpressionClassifier* classifier, bool* ok); | 881 ExpressionClassifier* classifier, bool* ok); |
882 void CheckArityRestrictions( | 882 void CheckArityRestrictions( |
883 int param_count, FunctionLiteral::ArityRestriction arity_restriction, | 883 int param_count, FunctionLiteral::ArityRestriction arity_restriction, |
884 int formals_start_pos, int formals_end_pos, bool* ok); | 884 bool has_rest, int formals_start_pos, int formals_end_pos, bool* ok); |
885 | 885 |
886 // Checks if the expression is a valid reference expression (e.g., on the | 886 // Checks if the expression is a valid reference expression (e.g., on the |
887 // left-hand side of assignments). Although ruled out by ECMA as early errors, | 887 // left-hand side of assignments). Although ruled out by ECMA as early errors, |
888 // we allow calls for web compatibility and rewrite them to a runtime throw. | 888 // we allow calls for web compatibility and rewrite them to a runtime throw. |
889 ExpressionT CheckAndRewriteReferenceExpression( | 889 ExpressionT CheckAndRewriteReferenceExpression( |
890 ExpressionT expression, | 890 ExpressionT expression, |
891 Scanner::Location location, const char* message, bool* ok); | 891 Scanner::Location location, const char* message, bool* ok); |
892 | 892 |
893 // Used to validate property names in object literals and class literals | 893 // Used to validate property names in object literals and class literals |
894 enum PropertyKind { | 894 enum PropertyKind { |
(...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3616 } | 3616 } |
3617 } | 3617 } |
3618 | 3618 |
3619 return parameter_count; | 3619 return parameter_count; |
3620 } | 3620 } |
3621 | 3621 |
3622 | 3622 |
3623 template <class Traits> | 3623 template <class Traits> |
3624 void ParserBase<Traits>::CheckArityRestrictions( | 3624 void ParserBase<Traits>::CheckArityRestrictions( |
3625 int param_count, FunctionLiteral::ArityRestriction arity_restriction, | 3625 int param_count, FunctionLiteral::ArityRestriction arity_restriction, |
3626 int formals_start_pos, int formals_end_pos, bool* ok) { | 3626 bool has_rest, int formals_start_pos, int formals_end_pos, bool* ok) { |
3627 switch (arity_restriction) { | 3627 switch (arity_restriction) { |
3628 case FunctionLiteral::GETTER_ARITY: | 3628 case FunctionLiteral::GETTER_ARITY: |
3629 if (param_count != 0) { | 3629 if (param_count != 0) { |
3630 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), | 3630 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), |
3631 "bad_getter_arity"); | 3631 "bad_getter_arity"); |
3632 *ok = false; | 3632 *ok = false; |
3633 } | 3633 } |
3634 break; | 3634 break; |
3635 case FunctionLiteral::SETTER_ARITY: | 3635 case FunctionLiteral::SETTER_ARITY: |
3636 if (param_count != 1) { | 3636 if (param_count != 1) { |
3637 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), | 3637 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), |
3638 "bad_setter_arity"); | 3638 "bad_setter_arity"); |
3639 *ok = false; | 3639 *ok = false; |
3640 } | 3640 } |
| 3641 if (has_rest) { |
| 3642 ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), |
| 3643 "setter_rest_param"); |
| 3644 *ok = false; |
| 3645 } |
3641 break; | 3646 break; |
3642 default: | 3647 default: |
3643 break; | 3648 break; |
3644 } | 3649 } |
3645 } | 3650 } |
3646 | 3651 |
3647 | 3652 |
3648 template <class Traits> | 3653 template <class Traits> |
3649 typename ParserBase<Traits>::ExpressionT | 3654 typename ParserBase<Traits>::ExpressionT |
3650 ParserBase<Traits>::ParseArrowFunctionLiteral( | 3655 ParserBase<Traits>::ParseArrowFunctionLiteral( |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3923 *ok = false; | 3928 *ok = false; |
3924 return; | 3929 return; |
3925 } | 3930 } |
3926 has_seen_constructor_ = true; | 3931 has_seen_constructor_ = true; |
3927 return; | 3932 return; |
3928 } | 3933 } |
3929 } | 3934 } |
3930 } } // v8::internal | 3935 } } // v8::internal |
3931 | 3936 |
3932 #endif // V8_PREPARSER_H | 3937 #endif // V8_PREPARSER_H |
OLD | NEW |