| Index: src/preparser.h
|
| diff --git a/src/preparser.h b/src/preparser.h
|
| index 156fd64a2e5db9aa2ea3f7cf8bbe5f75ae97e366..6c6a63ade3d30ba7f5c55aee9aa3dd641f8c0c67 100644
|
| --- a/src/preparser.h
|
| +++ b/src/preparser.h
|
| @@ -1249,11 +1249,13 @@ class PreParserTraits {
|
| bool is_generator, bool* ok);
|
|
|
| // Utility functions
|
| - Vector<PreParserIdentifier> ParameterListFromExpression(
|
| - PreParserExpression expression, bool* ok) {
|
| + unsigned DeclareArrowParametersFromExpression(PreParserExpression expression,
|
| + PreParserScope* scope,
|
| + Scanner::Location* dupe_loc,
|
| + bool* ok) {
|
| // TODO(aperez): Detect duplicated identifiers in paramlists.
|
| *ok = expression.IsValidArrowParamList();
|
| - return Vector<PreParserIdentifier>::empty();
|
| + return 0;
|
| }
|
|
|
| static AstValueFactory* ast_value_factory() { return NULL; }
|
| @@ -2436,16 +2438,6 @@ template <class Traits>
|
| typename ParserBase<Traits>::ExpressionT ParserBase<
|
| Traits>::ParseArrowFunctionLiteral(int start_pos, ExpressionT params_ast,
|
| bool* ok) {
|
| - typename Traits::Type::ParameterIdentifierVector params =
|
| - Traits::ParameterListFromExpression(params_ast, ok);
|
| -
|
| - if (!*ok) {
|
| - ReportMessageAt(Scanner::Location(start_pos, scanner()->location().beg_pos),
|
| - "malformed_arrow_function_parameter_list");
|
| - params.Dispose();
|
| - return this->EmptyExpression();
|
| - }
|
| -
|
| // TODO(aperez): Change this to use ARROW_SCOPE
|
| typename Traits::Type::ScopePtr scope =
|
| this->NewScope(scope_, FUNCTION_SCOPE);
|
| @@ -2453,30 +2445,25 @@ typename ParserBase<Traits>::ExpressionT ParserBase<
|
| FunctionState function_state(&function_state_, &scope_, &scope, zone(),
|
| this->ast_value_factory());
|
| Scanner::Location dupe_error_loc = Scanner::Location::invalid();
|
| + unsigned num_params = Traits::DeclareArrowParametersFromExpression(
|
| + params_ast, scope_, &dupe_error_loc, ok);
|
| + if (!*ok) {
|
| + ReportMessageAt(Scanner::Location(start_pos, scanner()->location().beg_pos),
|
| + "malformed_arrow_function_parameter_list");
|
| + return this->EmptyExpression();
|
| + }
|
|
|
| - if (params.length() > Code::kMaxArguments) {
|
| + if (num_params > Code::kMaxArguments) {
|
| ReportMessageAt(Scanner::Location(params_ast->position(), position()),
|
| "too_many_parameters");
|
| *ok = false;
|
| - params.Dispose();
|
| return this->EmptyExpression();
|
| }
|
|
|
| - for (int i = 0; i < params.length(); ++i) {
|
| - const IdentifierT param_name = params.at(i)->raw_name();
|
| - if (!dupe_error_loc.IsValid() && scope_->IsDeclared(param_name)) {
|
| - int param_pos = params.at(i)->position();
|
| - dupe_error_loc =
|
| - Scanner::Location(param_pos, param_pos + param_name->length());
|
| - }
|
| - scope_->DeclareParameter(param_name, VAR);
|
| - }
|
| -
|
| ExpressionT expression = ParseArrowFunctionLiteralBody(
|
| - &function_state, scope, params.length(), Scanner::Location::invalid(),
|
| + &function_state, scope, num_params, Scanner::Location::invalid(),
|
| dupe_error_loc, Scanner::Location::invalid(),
|
| FunctionLiteral::kNotParenthesized, start_pos, CHECK_OK);
|
| - params.Dispose();
|
| return expression;
|
| }
|
|
|
|
|