Chromium Code Reviews| Index: src/preparser.h |
| diff --git a/src/preparser.h b/src/preparser.h |
| index e0b24328172aa3ec37bc0e6d151d089596490d6c..964f49e4fdc91b9dd4a77ac5db9cc6330f3b18d8 100644 |
| --- a/src/preparser.h |
| +++ b/src/preparser.h |
| @@ -1324,6 +1324,8 @@ struct PreParserFormalParameters { |
| bool has_rest; |
| bool is_simple; |
| int materialized_literals_count; |
| + |
| + PreParserIdentifier at(int i) { return PreParserIdentifier(); } // Dummy |
| }; |
| @@ -1606,7 +1608,7 @@ class PreParserTraits { |
| const PreParserFormalParameters& parameters, |
| Variable* fvar, Token::Value fvar_init_op, FunctionKind kind, bool* ok); |
| - V8_INLINE void ParseArrowFunctionFormalParameters( |
| + V8_INLINE void ParseArrowFunctionFormalParameterList( |
| PreParserFormalParameters* parameters, |
| PreParserExpression expression, const Scanner::Location& params_loc, |
| Scanner::Location* duplicate_loc, bool* ok); |
| @@ -1637,8 +1639,11 @@ class PreParserTraits { |
| return !tag.IsNoTemplateTag(); |
| } |
| - void DeclareFormalParameter(PreParserFormalParameters* parameters, |
| - PreParserExpression pattern, bool is_rest, |
| + void AddFormalParameter( |
| + PreParserFormalParameters* parameters, PreParserExpression pattern, |
| + bool is_rest) {} |
|
adamk
2015/08/03 18:43:52
One option that would make this thing slightly les
|
| + void DeclareFormalParameter(Scope* scope, PreParserIdentifier parameter, |
| + bool is_simple, |
| ExpressionClassifier* classifier) {} |
| void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} |
| @@ -1836,7 +1841,7 @@ PreParserExpression PreParserTraits::SpreadCallNew(PreParserExpression function, |
| } |
| -void PreParserTraits::ParseArrowFunctionFormalParameters( |
| +void PreParserTraits::ParseArrowFunctionFormalParameterList( |
| PreParserFormalParameters* parameters, |
| PreParserExpression params, const Scanner::Location& params_loc, |
| Scanner::Location* duplicate_loc, bool* ok) { |
| @@ -2281,12 +2286,15 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
| // (...x) => y |
| Scope* scope = |
| this->NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction); |
| - FormalParametersT parameters(scope); |
| + FormalParametersT formals(scope); |
| scope->set_start_position(beg_pos); |
| - ExpressionClassifier args_classifier; |
| + ExpressionClassifier formals_classifier; |
| const bool is_rest = true; |
| - this->ParseFormalParameter(is_rest, ¶meters, &args_classifier, |
| + this->ParseFormalParameter(is_rest, &formals, &formals_classifier, |
| CHECK_OK); |
| + Traits::DeclareFormalParameter( |
| + formals.scope, formals.at(0), formals.is_simple, |
| + &formals_classifier); |
| if (peek() == Token::COMMA) { |
| ReportMessageAt(scanner()->peek_location(), |
| MessageTemplate::kParamAfterRest); |
| @@ -2294,7 +2302,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
| return this->EmptyExpression(); |
| } |
| Expect(Token::RPAREN, CHECK_OK); |
| - result = this->ParseArrowFunctionLiteral(parameters, args_classifier, |
| + result = this->ParseArrowFunctionLiteral(formals, formals_classifier, |
| CHECK_OK); |
| } else { |
| // Heuristically try to detect immediately called functions before |
| @@ -2846,8 +2854,8 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
| scope->set_start_position(lhs_location.beg_pos); |
| Scanner::Location duplicate_loc = Scanner::Location::invalid(); |
| - this->ParseArrowFunctionFormalParameters(¶meters, expression, loc, |
| - &duplicate_loc, CHECK_OK); |
| + this->ParseArrowFunctionFormalParameterList(¶meters, expression, loc, |
| + &duplicate_loc, CHECK_OK); |
| if (duplicate_loc.IsValid()) { |
| arrow_formals_classifier.RecordDuplicateFormalParameterError( |
| duplicate_loc); |
| @@ -3649,7 +3657,7 @@ void ParserBase<Traits>::ParseFormalParameter( |
| return; |
| } |
| ++parameters->arity; |
| - Traits::DeclareFormalParameter(parameters, pattern, is_rest, classifier); |
| + Traits::AddFormalParameter(parameters, pattern, is_rest); |
| } |
| @@ -3688,8 +3696,15 @@ void ParserBase<Traits>::ParseFormalParameterList( |
| ReportMessageAt(scanner()->peek_location(), |
| MessageTemplate::kParamAfterRest); |
| *ok = false; |
| + return; |
| } |
| } |
| + |
| + for (int i = 0; i < parameters->arity; ++i) { |
| + auto parameter = parameters->at(i); |
| + Traits::DeclareFormalParameter( |
| + parameters->scope, parameter, parameters->is_simple, classifier); |
| + } |
| } |