| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // typedef Factory; | 59 // typedef Factory; |
| 60 // }; | 60 // }; |
| 61 // // ... | 61 // // ... |
| 62 // }; | 62 // }; |
| 63 | 63 |
| 64 template <typename Traits> | 64 template <typename Traits> |
| 65 class ParserBase : public Traits { | 65 class ParserBase : public Traits { |
| 66 public: | 66 public: |
| 67 // Shorten type names defined by Traits. | 67 // Shorten type names defined by Traits. |
| 68 typedef typename Traits::Type::Expression ExpressionT; | 68 typedef typename Traits::Type::Expression ExpressionT; |
| 69 typedef typename Traits::Type::ExpressionList ExpressionListT; |
| 69 typedef typename Traits::Type::Identifier IdentifierT; | 70 typedef typename Traits::Type::Identifier IdentifierT; |
| 70 typedef typename Traits::Type::FormalParameter FormalParameterT; | 71 typedef typename Traits::Type::FormalParameter FormalParameterT; |
| 71 typedef typename Traits::Type::FormalParameterScope FormalParameterScopeT; | 72 typedef typename Traits::Type::FormalParameterScope FormalParameterScopeT; |
| 72 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; | 73 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; |
| 73 typedef typename Traits::Type::Literal LiteralT; | 74 typedef typename Traits::Type::Literal LiteralT; |
| 74 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; | 75 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; |
| 75 | 76 |
| 76 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, | 77 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, |
| 77 v8::Extension* extension, AstValueFactory* ast_value_factory, | 78 v8::Extension* extension, AstValueFactory* ast_value_factory, |
| 78 ParserRecorder* log, typename Traits::Type::Parser this_object) | 79 ParserRecorder* log, typename Traits::Type::Parser this_object) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 scanner_(scanner), | 91 scanner_(scanner), |
| 91 stack_overflow_(false), | 92 stack_overflow_(false), |
| 92 allow_lazy_(false), | 93 allow_lazy_(false), |
| 93 allow_natives_(false), | 94 allow_natives_(false), |
| 94 allow_harmony_arrow_functions_(false), | 95 allow_harmony_arrow_functions_(false), |
| 95 allow_harmony_object_literals_(false), | 96 allow_harmony_object_literals_(false), |
| 96 allow_harmony_sloppy_(false), | 97 allow_harmony_sloppy_(false), |
| 97 allow_harmony_computed_property_names_(false), | 98 allow_harmony_computed_property_names_(false), |
| 98 allow_harmony_rest_params_(false), | 99 allow_harmony_rest_params_(false), |
| 99 allow_harmony_spreadcalls_(false), | 100 allow_harmony_spreadcalls_(false), |
| 101 allow_harmony_default_parameters_(false), |
| 100 allow_strong_mode_(false) {} | 102 allow_strong_mode_(false) {} |
| 101 | 103 |
| 102 // Getters that indicate whether certain syntactical constructs are | 104 // Getters that indicate whether certain syntactical constructs are |
| 103 // allowed to be parsed by this instance of the parser. | 105 // allowed to be parsed by this instance of the parser. |
| 104 bool allow_lazy() const { return allow_lazy_; } | 106 bool allow_lazy() const { return allow_lazy_; } |
| 105 bool allow_natives() const { return allow_natives_; } | 107 bool allow_natives() const { return allow_natives_; } |
| 106 bool allow_harmony_arrow_functions() const { | 108 bool allow_harmony_arrow_functions() const { |
| 107 return allow_harmony_arrow_functions_; | 109 return allow_harmony_arrow_functions_; |
| 108 } | 110 } |
| 109 bool allow_harmony_modules() const { return scanner()->HarmonyModules(); } | 111 bool allow_harmony_modules() const { return scanner()->HarmonyModules(); } |
| 110 bool allow_harmony_classes() const { return scanner()->HarmonyClasses(); } | 112 bool allow_harmony_classes() const { return scanner()->HarmonyClasses(); } |
| 111 bool allow_harmony_object_literals() const { | 113 bool allow_harmony_object_literals() const { |
| 112 return allow_harmony_object_literals_; | 114 return allow_harmony_object_literals_; |
| 113 } | 115 } |
| 114 bool allow_harmony_sloppy() const { return allow_harmony_sloppy_; } | 116 bool allow_harmony_sloppy() const { return allow_harmony_sloppy_; } |
| 115 bool allow_harmony_unicode() const { return scanner()->HarmonyUnicode(); } | 117 bool allow_harmony_unicode() const { return scanner()->HarmonyUnicode(); } |
| 116 bool allow_harmony_computed_property_names() const { | 118 bool allow_harmony_computed_property_names() const { |
| 117 return allow_harmony_computed_property_names_; | 119 return allow_harmony_computed_property_names_; |
| 118 } | 120 } |
| 119 bool allow_harmony_rest_params() const { | 121 bool allow_harmony_rest_params() const { |
| 120 return allow_harmony_rest_params_; | 122 return allow_harmony_rest_params_; |
| 121 } | 123 } |
| 122 bool allow_harmony_spreadcalls() const { return allow_harmony_spreadcalls_; } | 124 bool allow_harmony_spreadcalls() const { return allow_harmony_spreadcalls_; } |
| 123 bool allow_harmony_destructuring() const { | 125 bool allow_harmony_destructuring() const { |
| 124 return allow_harmony_destructuring_; | 126 return allow_harmony_destructuring_; |
| 125 } | 127 } |
| 128 bool allow_harmony_default_parameters() const { |
| 129 return allow_harmony_default_parameters_; |
| 130 } |
| 126 | 131 |
| 127 bool allow_strong_mode() const { return allow_strong_mode_; } | 132 bool allow_strong_mode() const { return allow_strong_mode_; } |
| 128 | 133 |
| 129 // Setters that determine whether certain syntactical constructs are | 134 // Setters that determine whether certain syntactical constructs are |
| 130 // allowed to be parsed by this instance of the parser. | 135 // allowed to be parsed by this instance of the parser. |
| 131 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } | 136 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } |
| 132 void set_allow_natives(bool allow) { allow_natives_ = allow; } | 137 void set_allow_natives(bool allow) { allow_natives_ = allow; } |
| 133 void set_allow_harmony_arrow_functions(bool allow) { | 138 void set_allow_harmony_arrow_functions(bool allow) { |
| 134 allow_harmony_arrow_functions_ = allow; | 139 allow_harmony_arrow_functions_ = allow; |
| 135 } | 140 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 154 void set_allow_harmony_rest_params(bool allow) { | 159 void set_allow_harmony_rest_params(bool allow) { |
| 155 allow_harmony_rest_params_ = allow; | 160 allow_harmony_rest_params_ = allow; |
| 156 } | 161 } |
| 157 void set_allow_harmony_spreadcalls(bool allow) { | 162 void set_allow_harmony_spreadcalls(bool allow) { |
| 158 allow_harmony_spreadcalls_ = allow; | 163 allow_harmony_spreadcalls_ = allow; |
| 159 } | 164 } |
| 160 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; } | 165 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; } |
| 161 void set_allow_harmony_destructuring(bool allow) { | 166 void set_allow_harmony_destructuring(bool allow) { |
| 162 allow_harmony_destructuring_ = allow; | 167 allow_harmony_destructuring_ = allow; |
| 163 } | 168 } |
| 169 void set_allow_harmony_default_parameters(bool allow) { |
| 170 allow_harmony_default_parameters_ = allow; |
| 171 } |
| 164 | 172 |
| 165 | 173 |
| 166 protected: | 174 protected: |
| 167 enum AllowRestrictedIdentifiers { | 175 enum AllowRestrictedIdentifiers { |
| 168 kAllowRestrictedIdentifiers, | 176 kAllowRestrictedIdentifiers, |
| 169 kDontAllowRestrictedIdentifiers | 177 kDontAllowRestrictedIdentifiers |
| 170 }; | 178 }; |
| 171 | 179 |
| 172 enum Mode { | 180 enum Mode { |
| 173 PARSE_LAZILY, | 181 PARSE_LAZILY, |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 void AddTemplateExpression(ExpressionT); | 910 void AddTemplateExpression(ExpressionT); |
| 903 ExpressionT ParseSuperExpression(bool is_new, | 911 ExpressionT ParseSuperExpression(bool is_new, |
| 904 ExpressionClassifier* classifier, bool* ok); | 912 ExpressionClassifier* classifier, bool* ok); |
| 905 ExpressionT ParseStrongInitializationExpression( | 913 ExpressionT ParseStrongInitializationExpression( |
| 906 ExpressionClassifier* classifier, bool* ok); | 914 ExpressionClassifier* classifier, bool* ok); |
| 907 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, | 915 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, |
| 908 bool* ok); | 916 bool* ok); |
| 909 | 917 |
| 910 void ParseFormalParameter(FormalParameterScopeT* scope, bool is_rest, | 918 void ParseFormalParameter(FormalParameterScopeT* scope, bool is_rest, |
| 911 ExpressionClassifier* classifier, bool* ok); | 919 ExpressionClassifier* classifier, bool* ok); |
| 912 int ParseFormalParameterList(FormalParameterScopeT* scope, bool* has_rest, | 920 int ParseFormalParameterList(FormalParameterScopeT* scope, |
| 921 ExpressionListT initializers, |
| 922 bool* hasParameterExpressions, bool* has_rest, |
| 913 ExpressionClassifier* classifier, bool* ok); | 923 ExpressionClassifier* classifier, bool* ok); |
| 914 void CheckArityRestrictions( | 924 void CheckArityRestrictions( |
| 915 int param_count, FunctionLiteral::ArityRestriction arity_restriction, | 925 int param_count, FunctionLiteral::ArityRestriction arity_restriction, |
| 916 bool has_rest, int formals_start_pos, int formals_end_pos, bool* ok); | 926 bool has_rest, int formals_start_pos, int formals_end_pos, bool* ok); |
| 917 | 927 |
| 918 // Checks if the expression is a valid reference expression (e.g., on the | 928 // Checks if the expression is a valid reference expression (e.g., on the |
| 919 // left-hand side of assignments). Although ruled out by ECMA as early errors, | 929 // left-hand side of assignments). Although ruled out by ECMA as early errors, |
| 920 // we allow calls for web compatibility and rewrite them to a runtime throw. | 930 // we allow calls for web compatibility and rewrite them to a runtime throw. |
| 921 ExpressionT CheckAndRewriteReferenceExpression( | 931 ExpressionT CheckAndRewriteReferenceExpression( |
| 922 ExpressionT expression, Scanner::Location location, | 932 ExpressionT expression, Scanner::Location location, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 | 1014 |
| 1005 bool allow_lazy_; | 1015 bool allow_lazy_; |
| 1006 bool allow_natives_; | 1016 bool allow_natives_; |
| 1007 bool allow_harmony_arrow_functions_; | 1017 bool allow_harmony_arrow_functions_; |
| 1008 bool allow_harmony_object_literals_; | 1018 bool allow_harmony_object_literals_; |
| 1009 bool allow_harmony_sloppy_; | 1019 bool allow_harmony_sloppy_; |
| 1010 bool allow_harmony_computed_property_names_; | 1020 bool allow_harmony_computed_property_names_; |
| 1011 bool allow_harmony_rest_params_; | 1021 bool allow_harmony_rest_params_; |
| 1012 bool allow_harmony_spreadcalls_; | 1022 bool allow_harmony_spreadcalls_; |
| 1013 bool allow_harmony_destructuring_; | 1023 bool allow_harmony_destructuring_; |
| 1024 bool allow_harmony_default_parameters_; |
| 1014 bool allow_strong_mode_; | 1025 bool allow_strong_mode_; |
| 1015 }; | 1026 }; |
| 1016 | 1027 |
| 1017 | 1028 |
| 1018 class PreParserIdentifier { | 1029 class PreParserIdentifier { |
| 1019 public: | 1030 public: |
| 1020 PreParserIdentifier() : type_(kUnknownIdentifier) {} | 1031 PreParserIdentifier() : type_(kUnknownIdentifier) {} |
| 1021 static PreParserIdentifier Default() { | 1032 static PreParserIdentifier Default() { |
| 1022 return PreParserIdentifier(kUnknownIdentifier); | 1033 return PreParserIdentifier(kUnknownIdentifier); |
| 1023 } | 1034 } |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 } | 1791 } |
| 1781 inline void MaterializeTemplateCallsiteLiterals(); | 1792 inline void MaterializeTemplateCallsiteLiterals(); |
| 1782 PreParserExpression NoTemplateTag() { | 1793 PreParserExpression NoTemplateTag() { |
| 1783 return PreParserExpression::NoTemplateTag(); | 1794 return PreParserExpression::NoTemplateTag(); |
| 1784 } | 1795 } |
| 1785 static bool IsTaggedTemplate(const PreParserExpression tag) { | 1796 static bool IsTaggedTemplate(const PreParserExpression tag) { |
| 1786 return !tag.IsNoTemplateTag(); | 1797 return !tag.IsNoTemplateTag(); |
| 1787 } | 1798 } |
| 1788 | 1799 |
| 1789 V8_INLINE bool DeclareFormalParameter(DuplicateFinder* scope, | 1800 V8_INLINE bool DeclareFormalParameter(DuplicateFinder* scope, |
| 1790 PreParserIdentifier param, | 1801 PreParserIdentifier param, bool is_rest, |
| 1791 bool is_rest); | 1802 int pos); |
| 1792 | 1803 |
| 1793 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} | 1804 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} |
| 1794 | 1805 |
| 1795 // Temporary glue; these functions will move to ParserBase. | 1806 // Temporary glue; these functions will move to ParserBase. |
| 1796 PreParserExpression ParseV8Intrinsic(bool* ok); | 1807 PreParserExpression ParseV8Intrinsic(bool* ok); |
| 1797 PreParserExpression ParseFunctionLiteral( | 1808 PreParserExpression ParseFunctionLiteral( |
| 1798 PreParserIdentifier name, Scanner::Location function_name_location, | 1809 PreParserIdentifier name, Scanner::Location function_name_location, |
| 1799 bool name_is_strict_reserved, FunctionKind kind, | 1810 bool name_is_strict_reserved, FunctionKind kind, |
| 1800 int function_token_position, FunctionLiteral::FunctionType type, | 1811 int function_token_position, FunctionLiteral::FunctionType type, |
| 1801 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1812 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 | 1988 |
| 1978 PreParserExpression PreParserTraits::SpreadCallNew(PreParserExpression function, | 1989 PreParserExpression PreParserTraits::SpreadCallNew(PreParserExpression function, |
| 1979 PreParserExpressionList args, | 1990 PreParserExpressionList args, |
| 1980 int pos) { | 1991 int pos) { |
| 1981 return pre_parser_->factory()->NewCallNew(function, args, pos); | 1992 return pre_parser_->factory()->NewCallNew(function, args, pos); |
| 1982 } | 1993 } |
| 1983 | 1994 |
| 1984 | 1995 |
| 1985 bool PreParserTraits::DeclareFormalParameter( | 1996 bool PreParserTraits::DeclareFormalParameter( |
| 1986 DuplicateFinder* duplicate_finder, PreParserIdentifier current_identifier, | 1997 DuplicateFinder* duplicate_finder, PreParserIdentifier current_identifier, |
| 1987 bool is_rest) { | 1998 bool is_rest, int pos) { |
| 1988 return pre_parser_->scanner()->FindSymbol(duplicate_finder, 1) != 0; | 1999 return pre_parser_->scanner()->FindSymbol(duplicate_finder, 1) != 0; |
| 1989 } | 2000 } |
| 1990 | 2001 |
| 1991 | 2002 |
| 1992 void PreParserTraits::ParseArrowFunctionFormalParameters( | 2003 void PreParserTraits::ParseArrowFunctionFormalParameters( |
| 1993 Scope* scope, PreParserExpression params, | 2004 Scope* scope, PreParserExpression params, |
| 1994 const Scanner::Location& params_loc, bool* is_rest, | 2005 const Scanner::Location& params_loc, bool* is_rest, |
| 1995 Scanner::Location* duplicate_loc, bool* ok) { | 2006 Scanner::Location* duplicate_loc, bool* ok) { |
| 1996 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter | 2007 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter |
| 1997 // lists that are too long. | 2008 // lists that are too long. |
| (...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3634 } | 3645 } |
| 3635 | 3646 |
| 3636 | 3647 |
| 3637 template <class Traits> | 3648 template <class Traits> |
| 3638 void ParserBase<Traits>::ParseFormalParameter(FormalParameterScopeT* scope, | 3649 void ParserBase<Traits>::ParseFormalParameter(FormalParameterScopeT* scope, |
| 3639 bool is_rest, | 3650 bool is_rest, |
| 3640 ExpressionClassifier* classifier, | 3651 ExpressionClassifier* classifier, |
| 3641 bool* ok) { | 3652 bool* ok) { |
| 3642 // FormalParameter[Yield,GeneratorParameter] : | 3653 // FormalParameter[Yield,GeneratorParameter] : |
| 3643 // BindingElement[?Yield, ?GeneratorParameter] | 3654 // BindingElement[?Yield, ?GeneratorParameter] |
| 3655 int pos = peek_position(); |
| 3644 IdentifierT name = ParseAndClassifyIdentifier(classifier, ok); | 3656 IdentifierT name = ParseAndClassifyIdentifier(classifier, ok); |
| 3645 if (!*ok) return; | 3657 if (!*ok) return; |
| 3646 | 3658 |
| 3647 bool was_declared = Traits::DeclareFormalParameter(scope, name, is_rest); | 3659 bool was_declared = Traits::DeclareFormalParameter(scope, name, is_rest, pos); |
| 3648 if (was_declared) { | 3660 if (was_declared) { |
| 3649 classifier->RecordDuplicateFormalParameterError(scanner()->location()); | 3661 classifier->RecordDuplicateFormalParameterError(scanner()->location()); |
| 3650 } | 3662 } |
| 3651 } | 3663 } |
| 3652 | 3664 |
| 3653 | 3665 |
| 3654 template <class Traits> | 3666 template <class Traits> |
| 3655 int ParserBase<Traits>::ParseFormalParameterList( | 3667 int ParserBase<Traits>::ParseFormalParameterList( |
| 3656 FormalParameterScopeT* scope, bool* is_rest, | 3668 FormalParameterScopeT* scope, ExpressionListT initializers, |
| 3669 bool* hasParameterExpressions, bool* is_rest, |
| 3657 ExpressionClassifier* classifier, bool* ok) { | 3670 ExpressionClassifier* classifier, bool* ok) { |
| 3658 // FormalParameters[Yield,GeneratorParameter] : | 3671 // FormalParameters[Yield,GeneratorParameter] : |
| 3659 // [empty] | 3672 // [empty] |
| 3660 // FormalParameterList[?Yield, ?GeneratorParameter] | 3673 // FormalParameterList[?Yield, ?GeneratorParameter] |
| 3661 // | 3674 // |
| 3662 // FormalParameterList[Yield,GeneratorParameter] : | 3675 // FormalParameterList[Yield,GeneratorParameter] : |
| 3663 // FunctionRestParameter[?Yield] | 3676 // FunctionRestParameter[?Yield] |
| 3664 // FormalsList[?Yield, ?GeneratorParameter] | 3677 // FormalsList[?Yield, ?GeneratorParameter] |
| 3665 // FormalsList[?Yield, ?GeneratorParameter] , FunctionRestParameter[?Yield] | 3678 // FormalsList[?Yield, ?GeneratorParameter] , FunctionRestParameter[?Yield] |
| 3666 // | 3679 // |
| 3667 // FormalsList[Yield,GeneratorParameter] : | 3680 // FormalsList[Yield,GeneratorParameter] : |
| 3668 // FormalParameter[?Yield, ?GeneratorParameter] | 3681 // FormalParameter[?Yield, ?GeneratorParameter] |
| 3669 // FormalsList[?Yield, ?GeneratorParameter] , | 3682 // FormalsList[?Yield, ?GeneratorParameter] , |
| 3670 // FormalParameter[?Yield,?GeneratorParameter] | 3683 // FormalParameter[?Yield,?GeneratorParameter] |
| 3671 | 3684 |
| 3672 int parameter_count = 0; | 3685 int parameter_count = 0; |
| 3673 | 3686 |
| 3674 if (peek() != Token::RPAREN) { | 3687 if (peek() != Token::RPAREN) { |
| 3675 do { | 3688 do { |
| 3689 Scope* param_scope = NewScope(scope_, BLOCK_SCOPE); |
| 3690 BlockState param_state(&scope_, param_scope); |
| 3676 if (++parameter_count > Code::kMaxArguments) { | 3691 if (++parameter_count > Code::kMaxArguments) { |
| 3677 ReportMessage(MessageTemplate::kTooManyParameters); | 3692 ReportMessage(MessageTemplate::kTooManyParameters); |
| 3678 *ok = false; | 3693 *ok = false; |
| 3679 return -1; | 3694 return -1; |
| 3680 } | 3695 } |
| 3696 |
| 3697 int start_pos = peek_position(); |
| 3681 *is_rest = allow_harmony_rest_params() && Check(Token::ELLIPSIS); | 3698 *is_rest = allow_harmony_rest_params() && Check(Token::ELLIPSIS); |
| 3682 ParseFormalParameter(scope, *is_rest, classifier, ok); | 3699 ParseFormalParameter(scope, *is_rest, classifier, ok); |
| 3683 if (!*ok) return -1; | 3700 if (!*ok) return -1; |
| 3701 |
| 3702 // TODO(caitp, dslomov): set *hasParameterExpressions to true if |
| 3703 // formal parameter is an ObjectBindingPattern containing computed |
| 3704 // property keys |
| 3705 |
| 3706 ExpressionT initializer = this->EmptyExpression(); |
| 3707 if (allow_harmony_default_parameters() && Check(Token::ASSIGN)) { |
| 3708 // Default parameter initializer |
| 3709 static const bool accept_IN = true; |
| 3710 ExpressionClassifier classifier; |
| 3711 initializer = ParseAssignmentExpression(accept_IN, &classifier, ok); |
| 3712 if (!*ok) return -1; |
| 3713 *hasParameterExpressions = true; |
| 3714 |
| 3715 // A rest parameter cannot be initialized. |
| 3716 if (*is_rest) { |
| 3717 Scanner::Location loc(start_pos, scanner()->location().end_pos); |
| 3718 ReportMessageAt(loc, MessageTemplate::kBadRestParameterInitializer); |
| 3719 *ok = false; |
| 3720 return -1; |
| 3721 } |
| 3722 } |
| 3723 initializers->Add(initializer, zone()); |
| 3684 } while (!*is_rest && Check(Token::COMMA)); | 3724 } while (!*is_rest && Check(Token::COMMA)); |
| 3685 | 3725 |
| 3686 if (*is_rest && peek() == Token::COMMA) { | 3726 if (*is_rest && peek() == Token::COMMA) { |
| 3687 ReportMessageAt(scanner()->peek_location(), | 3727 ReportMessageAt(scanner()->peek_location(), |
| 3688 MessageTemplate::kParamAfterRest); | 3728 MessageTemplate::kParamAfterRest); |
| 3689 *ok = false; | 3729 *ok = false; |
| 3690 return -1; | 3730 return -1; |
| 3691 } | 3731 } |
| 3692 } | 3732 } |
| 3693 | 3733 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4007 *ok = false; | 4047 *ok = false; |
| 4008 return; | 4048 return; |
| 4009 } | 4049 } |
| 4010 has_seen_constructor_ = true; | 4050 has_seen_constructor_ = true; |
| 4011 return; | 4051 return; |
| 4012 } | 4052 } |
| 4013 } | 4053 } |
| 4014 } } // v8::internal | 4054 } } // v8::internal |
| 4015 | 4055 |
| 4016 #endif // V8_PREPARSER_H | 4056 #endif // V8_PREPARSER_H |
| OLD | NEW |