| 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; | |
| 70 typedef typename Traits::Type::Identifier IdentifierT; | 69 typedef typename Traits::Type::Identifier IdentifierT; |
| 71 typedef typename Traits::Type::FormalParameter FormalParameterT; | 70 typedef typename Traits::Type::FormalParameter FormalParameterT; |
| 72 typedef typename Traits::Type::FormalParameterScope FormalParameterScopeT; | 71 typedef typename Traits::Type::FormalParameterScope FormalParameterScopeT; |
| 73 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; | 72 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; |
| 74 typedef typename Traits::Type::Literal LiteralT; | 73 typedef typename Traits::Type::Literal LiteralT; |
| 75 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; | 74 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; |
| 76 | 75 |
| 77 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, | 76 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, |
| 78 v8::Extension* extension, AstValueFactory* ast_value_factory, | 77 v8::Extension* extension, AstValueFactory* ast_value_factory, |
| 79 ParserRecorder* log, typename Traits::Type::Parser this_object) | 78 ParserRecorder* log, typename Traits::Type::Parser this_object) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 91 scanner_(scanner), | 90 scanner_(scanner), |
| 92 stack_overflow_(false), | 91 stack_overflow_(false), |
| 93 allow_lazy_(false), | 92 allow_lazy_(false), |
| 94 allow_natives_(false), | 93 allow_natives_(false), |
| 95 allow_harmony_arrow_functions_(false), | 94 allow_harmony_arrow_functions_(false), |
| 96 allow_harmony_object_literals_(false), | 95 allow_harmony_object_literals_(false), |
| 97 allow_harmony_sloppy_(false), | 96 allow_harmony_sloppy_(false), |
| 98 allow_harmony_computed_property_names_(false), | 97 allow_harmony_computed_property_names_(false), |
| 99 allow_harmony_rest_params_(false), | 98 allow_harmony_rest_params_(false), |
| 100 allow_harmony_spreadcalls_(false), | 99 allow_harmony_spreadcalls_(false), |
| 101 allow_harmony_default_parameters_(false), | |
| 102 allow_strong_mode_(false) {} | 100 allow_strong_mode_(false) {} |
| 103 | 101 |
| 104 // Getters that indicate whether certain syntactical constructs are | 102 // Getters that indicate whether certain syntactical constructs are |
| 105 // allowed to be parsed by this instance of the parser. | 103 // allowed to be parsed by this instance of the parser. |
| 106 bool allow_lazy() const { return allow_lazy_; } | 104 bool allow_lazy() const { return allow_lazy_; } |
| 107 bool allow_natives() const { return allow_natives_; } | 105 bool allow_natives() const { return allow_natives_; } |
| 108 bool allow_harmony_arrow_functions() const { | 106 bool allow_harmony_arrow_functions() const { |
| 109 return allow_harmony_arrow_functions_; | 107 return allow_harmony_arrow_functions_; |
| 110 } | 108 } |
| 111 bool allow_harmony_modules() const { return scanner()->HarmonyModules(); } | 109 bool allow_harmony_modules() const { return scanner()->HarmonyModules(); } |
| 112 bool allow_harmony_classes() const { return scanner()->HarmonyClasses(); } | 110 bool allow_harmony_classes() const { return scanner()->HarmonyClasses(); } |
| 113 bool allow_harmony_object_literals() const { | 111 bool allow_harmony_object_literals() const { |
| 114 return allow_harmony_object_literals_; | 112 return allow_harmony_object_literals_; |
| 115 } | 113 } |
| 116 bool allow_harmony_sloppy() const { return allow_harmony_sloppy_; } | 114 bool allow_harmony_sloppy() const { return allow_harmony_sloppy_; } |
| 117 bool allow_harmony_unicode() const { return scanner()->HarmonyUnicode(); } | 115 bool allow_harmony_unicode() const { return scanner()->HarmonyUnicode(); } |
| 118 bool allow_harmony_computed_property_names() const { | 116 bool allow_harmony_computed_property_names() const { |
| 119 return allow_harmony_computed_property_names_; | 117 return allow_harmony_computed_property_names_; |
| 120 } | 118 } |
| 121 bool allow_harmony_rest_params() const { | 119 bool allow_harmony_rest_params() const { |
| 122 return allow_harmony_rest_params_; | 120 return allow_harmony_rest_params_; |
| 123 } | 121 } |
| 124 bool allow_harmony_spreadcalls() const { return allow_harmony_spreadcalls_; } | 122 bool allow_harmony_spreadcalls() const { return allow_harmony_spreadcalls_; } |
| 125 bool allow_harmony_destructuring() const { | 123 bool allow_harmony_destructuring() const { |
| 126 return allow_harmony_destructuring_; | 124 return allow_harmony_destructuring_; |
| 127 } | 125 } |
| 128 bool allow_harmony_spread_arrays() const { | 126 bool allow_harmony_spread_arrays() const { |
| 129 return allow_harmony_spread_arrays_; | 127 return allow_harmony_spread_arrays_; |
| 130 } | 128 } |
| 131 bool allow_harmony_default_parameters() const { | |
| 132 return allow_harmony_default_parameters_; | |
| 133 } | |
| 134 | 129 |
| 135 bool allow_strong_mode() const { return allow_strong_mode_; } | 130 bool allow_strong_mode() const { return allow_strong_mode_; } |
| 136 | 131 |
| 137 // Setters that determine whether certain syntactical constructs are | 132 // Setters that determine whether certain syntactical constructs are |
| 138 // allowed to be parsed by this instance of the parser. | 133 // allowed to be parsed by this instance of the parser. |
| 139 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } | 134 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } |
| 140 void set_allow_natives(bool allow) { allow_natives_ = allow; } | 135 void set_allow_natives(bool allow) { allow_natives_ = allow; } |
| 141 void set_allow_harmony_arrow_functions(bool allow) { | 136 void set_allow_harmony_arrow_functions(bool allow) { |
| 142 allow_harmony_arrow_functions_ = allow; | 137 allow_harmony_arrow_functions_ = allow; |
| 143 } | 138 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 165 void set_allow_harmony_spreadcalls(bool allow) { | 160 void set_allow_harmony_spreadcalls(bool allow) { |
| 166 allow_harmony_spreadcalls_ = allow; | 161 allow_harmony_spreadcalls_ = allow; |
| 167 } | 162 } |
| 168 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; } | 163 void set_allow_strong_mode(bool allow) { allow_strong_mode_ = allow; } |
| 169 void set_allow_harmony_destructuring(bool allow) { | 164 void set_allow_harmony_destructuring(bool allow) { |
| 170 allow_harmony_destructuring_ = allow; | 165 allow_harmony_destructuring_ = allow; |
| 171 } | 166 } |
| 172 void set_allow_harmony_spread_arrays(bool allow) { | 167 void set_allow_harmony_spread_arrays(bool allow) { |
| 173 allow_harmony_spread_arrays_ = allow; | 168 allow_harmony_spread_arrays_ = allow; |
| 174 } | 169 } |
| 175 void set_allow_harmony_default_parameters(bool allow) { | |
| 176 allow_harmony_default_parameters_ = allow; | |
| 177 } | |
| 178 | |
| 179 | 170 |
| 180 protected: | 171 protected: |
| 181 enum AllowRestrictedIdentifiers { | 172 enum AllowRestrictedIdentifiers { |
| 182 kAllowRestrictedIdentifiers, | 173 kAllowRestrictedIdentifiers, |
| 183 kDontAllowRestrictedIdentifiers | 174 kDontAllowRestrictedIdentifiers |
| 184 }; | 175 }; |
| 185 | 176 |
| 186 enum Mode { | 177 enum Mode { |
| 187 PARSE_LAZILY, | 178 PARSE_LAZILY, |
| 188 PARSE_EAGERLY | 179 PARSE_EAGERLY |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 void AddTemplateExpression(ExpressionT); | 912 void AddTemplateExpression(ExpressionT); |
| 922 ExpressionT ParseSuperExpression(bool is_new, | 913 ExpressionT ParseSuperExpression(bool is_new, |
| 923 ExpressionClassifier* classifier, bool* ok); | 914 ExpressionClassifier* classifier, bool* ok); |
| 924 ExpressionT ParseStrongInitializationExpression( | 915 ExpressionT ParseStrongInitializationExpression( |
| 925 ExpressionClassifier* classifier, bool* ok); | 916 ExpressionClassifier* classifier, bool* ok); |
| 926 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, | 917 ExpressionT ParseStrongSuperCallExpression(ExpressionClassifier* classifier, |
| 927 bool* ok); | 918 bool* ok); |
| 928 | 919 |
| 929 void ParseFormalParameter(FormalParameterScopeT* scope, bool is_rest, | 920 void ParseFormalParameter(FormalParameterScopeT* scope, bool is_rest, |
| 930 ExpressionClassifier* classifier, bool* ok); | 921 ExpressionClassifier* classifier, bool* ok); |
| 931 int ParseFormalParameterList(FormalParameterScopeT* scope, | 922 int ParseFormalParameterList(FormalParameterScopeT* scope, bool* has_rest, |
| 932 ExpressionListT initializers, | |
| 933 bool* has_parameter_expressions, bool* has_rest, | |
| 934 ExpressionClassifier* classifier, bool* ok); | 923 ExpressionClassifier* classifier, bool* ok); |
| 935 void CheckArityRestrictions( | 924 void CheckArityRestrictions( |
| 936 int param_count, FunctionLiteral::ArityRestriction arity_restriction, | 925 int param_count, FunctionLiteral::ArityRestriction arity_restriction, |
| 937 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); |
| 938 | 927 |
| 939 // 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 |
| 940 // 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, |
| 941 // 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. |
| 942 ExpressionT CheckAndRewriteReferenceExpression( | 931 ExpressionT CheckAndRewriteReferenceExpression( |
| 943 ExpressionT expression, Scanner::Location location, | 932 ExpressionT expression, Scanner::Location location, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 bool allow_lazy_; | 1015 bool allow_lazy_; |
| 1027 bool allow_natives_; | 1016 bool allow_natives_; |
| 1028 bool allow_harmony_arrow_functions_; | 1017 bool allow_harmony_arrow_functions_; |
| 1029 bool allow_harmony_object_literals_; | 1018 bool allow_harmony_object_literals_; |
| 1030 bool allow_harmony_sloppy_; | 1019 bool allow_harmony_sloppy_; |
| 1031 bool allow_harmony_computed_property_names_; | 1020 bool allow_harmony_computed_property_names_; |
| 1032 bool allow_harmony_rest_params_; | 1021 bool allow_harmony_rest_params_; |
| 1033 bool allow_harmony_spreadcalls_; | 1022 bool allow_harmony_spreadcalls_; |
| 1034 bool allow_harmony_destructuring_; | 1023 bool allow_harmony_destructuring_; |
| 1035 bool allow_harmony_spread_arrays_; | 1024 bool allow_harmony_spread_arrays_; |
| 1036 bool allow_harmony_default_parameters_; | |
| 1037 bool allow_strong_mode_; | 1025 bool allow_strong_mode_; |
| 1038 }; | 1026 }; |
| 1039 | 1027 |
| 1040 | 1028 |
| 1041 class PreParserIdentifier { | 1029 class PreParserIdentifier { |
| 1042 public: | 1030 public: |
| 1043 PreParserIdentifier() : type_(kUnknownIdentifier) {} | 1031 PreParserIdentifier() : type_(kUnknownIdentifier) {} |
| 1044 static PreParserIdentifier Default() { | 1032 static PreParserIdentifier Default() { |
| 1045 return PreParserIdentifier(kUnknownIdentifier); | 1033 return PreParserIdentifier(kUnknownIdentifier); |
| 1046 } | 1034 } |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 } | 1792 } |
| 1805 inline void MaterializeTemplateCallsiteLiterals(); | 1793 inline void MaterializeTemplateCallsiteLiterals(); |
| 1806 PreParserExpression NoTemplateTag() { | 1794 PreParserExpression NoTemplateTag() { |
| 1807 return PreParserExpression::NoTemplateTag(); | 1795 return PreParserExpression::NoTemplateTag(); |
| 1808 } | 1796 } |
| 1809 static bool IsTaggedTemplate(const PreParserExpression tag) { | 1797 static bool IsTaggedTemplate(const PreParserExpression tag) { |
| 1810 return !tag.IsNoTemplateTag(); | 1798 return !tag.IsNoTemplateTag(); |
| 1811 } | 1799 } |
| 1812 | 1800 |
| 1813 V8_INLINE bool DeclareFormalParameter(DuplicateFinder* scope, | 1801 V8_INLINE bool DeclareFormalParameter(DuplicateFinder* scope, |
| 1814 PreParserIdentifier param, bool is_rest, | 1802 PreParserIdentifier param, |
| 1815 int pos); | 1803 bool is_rest); |
| 1816 | 1804 |
| 1817 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} | 1805 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} |
| 1818 | 1806 |
| 1819 // Temporary glue; these functions will move to ParserBase. | 1807 // Temporary glue; these functions will move to ParserBase. |
| 1820 PreParserExpression ParseV8Intrinsic(bool* ok); | 1808 PreParserExpression ParseV8Intrinsic(bool* ok); |
| 1821 PreParserExpression ParseFunctionLiteral( | 1809 PreParserExpression ParseFunctionLiteral( |
| 1822 PreParserIdentifier name, Scanner::Location function_name_location, | 1810 PreParserIdentifier name, Scanner::Location function_name_location, |
| 1823 bool name_is_strict_reserved, FunctionKind kind, | 1811 bool name_is_strict_reserved, FunctionKind kind, |
| 1824 int function_token_position, FunctionLiteral::FunctionType type, | 1812 int function_token_position, FunctionLiteral::FunctionType type, |
| 1825 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1813 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 | 1989 |
| 2002 PreParserExpression PreParserTraits::SpreadCallNew(PreParserExpression function, | 1990 PreParserExpression PreParserTraits::SpreadCallNew(PreParserExpression function, |
| 2003 PreParserExpressionList args, | 1991 PreParserExpressionList args, |
| 2004 int pos) { | 1992 int pos) { |
| 2005 return pre_parser_->factory()->NewCallNew(function, args, pos); | 1993 return pre_parser_->factory()->NewCallNew(function, args, pos); |
| 2006 } | 1994 } |
| 2007 | 1995 |
| 2008 | 1996 |
| 2009 bool PreParserTraits::DeclareFormalParameter( | 1997 bool PreParserTraits::DeclareFormalParameter( |
| 2010 DuplicateFinder* duplicate_finder, PreParserIdentifier current_identifier, | 1998 DuplicateFinder* duplicate_finder, PreParserIdentifier current_identifier, |
| 2011 bool is_rest, int pos) { | 1999 bool is_rest) { |
| 2012 return pre_parser_->scanner()->FindSymbol(duplicate_finder, 1) != 0; | 2000 return pre_parser_->scanner()->FindSymbol(duplicate_finder, 1) != 0; |
| 2013 } | 2001 } |
| 2014 | 2002 |
| 2015 | 2003 |
| 2016 void PreParserTraits::ParseArrowFunctionFormalParameters( | 2004 void PreParserTraits::ParseArrowFunctionFormalParameters( |
| 2017 Scope* scope, PreParserExpression params, | 2005 Scope* scope, PreParserExpression params, |
| 2018 const Scanner::Location& params_loc, bool* is_rest, | 2006 const Scanner::Location& params_loc, bool* is_rest, |
| 2019 Scanner::Location* duplicate_loc, bool* ok) { | 2007 Scanner::Location* duplicate_loc, bool* ok) { |
| 2020 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter | 2008 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter |
| 2021 // lists that are too long. | 2009 // lists that are too long. |
| (...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3678 } | 3666 } |
| 3679 | 3667 |
| 3680 | 3668 |
| 3681 template <class Traits> | 3669 template <class Traits> |
| 3682 void ParserBase<Traits>::ParseFormalParameter(FormalParameterScopeT* scope, | 3670 void ParserBase<Traits>::ParseFormalParameter(FormalParameterScopeT* scope, |
| 3683 bool is_rest, | 3671 bool is_rest, |
| 3684 ExpressionClassifier* classifier, | 3672 ExpressionClassifier* classifier, |
| 3685 bool* ok) { | 3673 bool* ok) { |
| 3686 // FormalParameter[Yield,GeneratorParameter] : | 3674 // FormalParameter[Yield,GeneratorParameter] : |
| 3687 // BindingElement[?Yield, ?GeneratorParameter] | 3675 // BindingElement[?Yield, ?GeneratorParameter] |
| 3688 int pos = peek_position(); | |
| 3689 IdentifierT name = ParseAndClassifyIdentifier(classifier, ok); | 3676 IdentifierT name = ParseAndClassifyIdentifier(classifier, ok); |
| 3690 if (!*ok) return; | 3677 if (!*ok) return; |
| 3691 | 3678 |
| 3692 bool was_declared = Traits::DeclareFormalParameter(scope, name, is_rest, pos); | 3679 bool was_declared = Traits::DeclareFormalParameter(scope, name, is_rest); |
| 3693 if (was_declared) { | 3680 if (was_declared) { |
| 3694 classifier->RecordDuplicateFormalParameterError(scanner()->location()); | 3681 classifier->RecordDuplicateFormalParameterError(scanner()->location()); |
| 3695 } | 3682 } |
| 3696 } | 3683 } |
| 3697 | 3684 |
| 3698 | 3685 |
| 3699 template <class Traits> | 3686 template <class Traits> |
| 3700 int ParserBase<Traits>::ParseFormalParameterList( | 3687 int ParserBase<Traits>::ParseFormalParameterList( |
| 3701 FormalParameterScopeT* scope, ExpressionListT initializers, | 3688 FormalParameterScopeT* scope, bool* is_rest, |
| 3702 bool* has_parameter_expressions, bool* is_rest, | |
| 3703 ExpressionClassifier* classifier, bool* ok) { | 3689 ExpressionClassifier* classifier, bool* ok) { |
| 3704 // FormalParameters[Yield,GeneratorParameter] : | 3690 // FormalParameters[Yield,GeneratorParameter] : |
| 3705 // [empty] | 3691 // [empty] |
| 3706 // FormalParameterList[?Yield, ?GeneratorParameter] | 3692 // FormalParameterList[?Yield, ?GeneratorParameter] |
| 3707 // | 3693 // |
| 3708 // FormalParameterList[Yield,GeneratorParameter] : | 3694 // FormalParameterList[Yield,GeneratorParameter] : |
| 3709 // FunctionRestParameter[?Yield] | 3695 // FunctionRestParameter[?Yield] |
| 3710 // FormalsList[?Yield, ?GeneratorParameter] | 3696 // FormalsList[?Yield, ?GeneratorParameter] |
| 3711 // FormalsList[?Yield, ?GeneratorParameter] , FunctionRestParameter[?Yield] | 3697 // FormalsList[?Yield, ?GeneratorParameter] , FunctionRestParameter[?Yield] |
| 3712 // | 3698 // |
| 3713 // FormalsList[Yield,GeneratorParameter] : | 3699 // FormalsList[Yield,GeneratorParameter] : |
| 3714 // FormalParameter[?Yield, ?GeneratorParameter] | 3700 // FormalParameter[?Yield, ?GeneratorParameter] |
| 3715 // FormalsList[?Yield, ?GeneratorParameter] , | 3701 // FormalsList[?Yield, ?GeneratorParameter] , |
| 3716 // FormalParameter[?Yield,?GeneratorParameter] | 3702 // FormalParameter[?Yield,?GeneratorParameter] |
| 3717 | 3703 |
| 3718 int parameter_count = 0; | 3704 int parameter_count = 0; |
| 3719 | 3705 |
| 3720 if (peek() != Token::RPAREN) { | 3706 if (peek() != Token::RPAREN) { |
| 3721 do { | 3707 do { |
| 3722 Scope* param_scope = NewScope(scope_, BLOCK_SCOPE); | |
| 3723 BlockState param_state(&scope_, param_scope); | |
| 3724 param_scope->set_start_position(peek_position()); | |
| 3725 if (++parameter_count > Code::kMaxArguments) { | 3708 if (++parameter_count > Code::kMaxArguments) { |
| 3726 ReportMessage(MessageTemplate::kTooManyParameters); | 3709 ReportMessage(MessageTemplate::kTooManyParameters); |
| 3727 *ok = false; | 3710 *ok = false; |
| 3728 return -1; | 3711 return -1; |
| 3729 } | 3712 } |
| 3730 | |
| 3731 int start_pos = peek_position(); | |
| 3732 *is_rest = allow_harmony_rest_params() && Check(Token::ELLIPSIS); | 3713 *is_rest = allow_harmony_rest_params() && Check(Token::ELLIPSIS); |
| 3733 ParseFormalParameter(scope, *is_rest, classifier, ok); | 3714 ParseFormalParameter(scope, *is_rest, classifier, ok); |
| 3734 if (!*ok) return -1; | 3715 if (!*ok) return -1; |
| 3735 | |
| 3736 // TODO(caitp, dslomov): set *has_parameter_expressions to true if | |
| 3737 // formal parameter is an ObjectBindingPattern containing computed | |
| 3738 // property keys | |
| 3739 | |
| 3740 ExpressionT initializer = this->EmptyExpression(); | |
| 3741 if (allow_harmony_default_parameters() && Check(Token::ASSIGN)) { | |
| 3742 // Default parameter initializer | |
| 3743 static const bool accept_IN = true; | |
| 3744 ExpressionClassifier classifier; | |
| 3745 initializer = ParseAssignmentExpression(accept_IN, &classifier, ok); | |
| 3746 if (!*ok) return -1; | |
| 3747 *has_parameter_expressions = true; | |
| 3748 | |
| 3749 // A rest parameter cannot be initialized. | |
| 3750 if (*is_rest) { | |
| 3751 Scanner::Location loc(start_pos, scanner()->location().end_pos); | |
| 3752 ReportMessageAt(loc, MessageTemplate::kBadRestParameterInitializer); | |
| 3753 *ok = false; | |
| 3754 return -1; | |
| 3755 } | |
| 3756 } | |
| 3757 param_scope->set_end_position(scanner()->location().end_pos); | |
| 3758 initializers->Add(initializer, zone()); | |
| 3759 } while (!*is_rest && Check(Token::COMMA)); | 3716 } while (!*is_rest && Check(Token::COMMA)); |
| 3760 | 3717 |
| 3761 if (*is_rest && peek() == Token::COMMA) { | 3718 if (*is_rest && peek() == Token::COMMA) { |
| 3762 ReportMessageAt(scanner()->peek_location(), | 3719 ReportMessageAt(scanner()->peek_location(), |
| 3763 MessageTemplate::kParamAfterRest); | 3720 MessageTemplate::kParamAfterRest); |
| 3764 *ok = false; | 3721 *ok = false; |
| 3765 return -1; | 3722 return -1; |
| 3766 } | 3723 } |
| 3767 } | 3724 } |
| 3768 | 3725 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4082 *ok = false; | 4039 *ok = false; |
| 4083 return; | 4040 return; |
| 4084 } | 4041 } |
| 4085 has_seen_constructor_ = true; | 4042 has_seen_constructor_ = true; |
| 4086 return; | 4043 return; |
| 4087 } | 4044 } |
| 4088 } | 4045 } |
| 4089 } } // v8::internal | 4046 } } // v8::internal |
| 4090 | 4047 |
| 4091 #endif // V8_PREPARSER_H | 4048 #endif // V8_PREPARSER_H |
| OLD | NEW |