| Index: src/preparser.h
|
| diff --git a/src/preparser.h b/src/preparser.h
|
| index 156fd64a2e5db9aa2ea3f7cf8bbe5f75ae97e366..185bf44729fc1cbeab21376b3a86479144d56daf 100644
|
| --- a/src/preparser.h
|
| +++ b/src/preparser.h
|
| @@ -1011,7 +1011,7 @@ class PreParserFactory {
|
| FunctionLiteral::FunctionType function_type,
|
| FunctionLiteral::IsFunctionFlag is_function,
|
| FunctionLiteral::IsParenthesizedFlag is_parenthesized,
|
| - FunctionLiteral::IsGeneratorFlag is_generator, int position) {
|
| + FunctionLiteral::KindFlag kind, int position) {
|
| return PreParserExpression::Default();
|
| }
|
|
|
| @@ -1113,6 +1113,11 @@ class PreParserTraits {
|
| // PreParser should not use FuncNameInferrer.
|
| UNREACHABLE();
|
| }
|
| + static void InferFunctionName(FuncNameInferrer* fni,
|
| + PreParserExpression expression) {
|
| + // PreParser should not use FuncNameInferrer.
|
| + UNREACHABLE();
|
| + }
|
|
|
| static void CheckFunctionLiteralInsideTopLevelObjectLiteral(
|
| PreParserScope* scope, PreParserExpression value, bool* has_function) {}
|
| @@ -2490,8 +2495,15 @@ ParserBase<Traits>::ParseArrowFunctionLiteralBody(
|
| const Scanner::Location& reserved_loc,
|
| FunctionLiteral::IsParenthesizedFlag parenthesized, int start_pos,
|
| bool* ok) {
|
| + typename Traits::Type::StatementList body;
|
| + typename Traits::Type::AstProperties ast_properties;
|
| + FunctionLiteral::ParameterFlag duplicate_parameters =
|
| + dupe_error_loc.IsValid() ? FunctionLiteral::kHasDuplicateParameters
|
| + : FunctionLiteral::kNoDuplicateParameters;
|
| + BailoutReason dont_optimize_reason = kNoReason;
|
| int materialized_literal_count = -1;
|
| int expected_property_count = -1;
|
| + int handler_count = 0;
|
|
|
| Expect(Token::ARROW, CHECK_OK);
|
|
|
| @@ -2505,14 +2517,24 @@ ParserBase<Traits>::ParseArrowFunctionLiteralBody(
|
| &materialized_literal_count,
|
| &expected_property_count, CHECK_OK);
|
| } else {
|
| - this->ParseEagerFunctionBody(this->EmptyIdentifier(),
|
| - RelocInfo::kNoPosition, NULL,
|
| - Token::INIT_VAR, false, // Not a generator.
|
| - CHECK_OK);
|
| + body = this->ParseEagerFunctionBody(
|
| + this->EmptyIdentifier(), RelocInfo::kNoPosition, NULL,
|
| + Token::INIT_VAR, false, // Not a generator.
|
| + CHECK_OK);
|
| + materialized_literal_count = function_state->materialized_literal_count();
|
| + expected_property_count = function_state->expected_property_count();
|
| + handler_count = function_state->handler_count();
|
| }
|
| } else {
|
| // Single-expression body
|
| - ParseAssignmentExpression(true, CHECK_OK);
|
| + int pos = position();
|
| + parenthesized_function_ = false;
|
| + ExpressionT expression = ParseAssignmentExpression(true, CHECK_OK);
|
| + body = this->NewStatementList(1, zone());
|
| + body->Add(factory()->NewReturnStatement(expression, pos), zone());
|
| + materialized_literal_count = function_state->materialized_literal_count();
|
| + expected_property_count = function_state->expected_property_count();
|
| + handler_count = function_state->handler_count();
|
| }
|
|
|
| scope->set_start_position(start_pos);
|
| @@ -2532,16 +2554,22 @@ ParserBase<Traits>::ParseArrowFunctionLiteralBody(
|
| if (allow_harmony_scoping() && strict_mode() == STRICT)
|
| this->CheckConflictingVarDeclarations(scope, CHECK_OK);
|
|
|
| - // TODO(aperez): Generate a proper FunctionLiteral instead of
|
| - // returning a dummy value.
|
| + ast_properties = *factory()->visitor()->ast_properties();
|
| + dont_optimize_reason = factory()->visitor()->dont_optimize_reason();
|
| +
|
| FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
|
| - this->EmptyIdentifierString(), this->ast_value_factory(), scope,
|
| - this->NewStatementList(0, zone()), 0, 0, 0, num_parameters,
|
| - FunctionLiteral::kNoDuplicateParameters,
|
| + this->EmptyIdentifierString(), this->ast_value_factory(), scope, body,
|
| + materialized_literal_count, expected_property_count, handler_count,
|
| + num_parameters, duplicate_parameters,
|
| FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction,
|
| - FunctionLiteral::kNotParenthesized, FunctionLiteral::kNotGenerator,
|
| - start_pos);
|
| + parenthesized, FunctionLiteral::kArrowFunction, start_pos);
|
| +
|
| function_literal->set_function_token_position(start_pos);
|
| + function_literal->set_ast_properties(&ast_properties);
|
| + function_literal->set_dont_optimize_reason(dont_optimize_reason);
|
| +
|
| + if (fni_ != NULL) this->InferFunctionName(fni_, function_literal);
|
| +
|
| return function_literal;
|
| }
|
|
|
|
|