| Index: src/parsing/parser-base.h
|
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
|
| index 05fdb8365cec1078df8ca54699e033703b771234..d6b16c99b530d8122ca4d53179c96b93f5ee841b 100644
|
| --- a/src/parsing/parser-base.h
|
| +++ b/src/parsing/parser-base.h
|
| @@ -36,6 +36,12 @@ enum class ParseFunctionFlags {
|
| kIsDefault = 4
|
| };
|
|
|
| +enum class FunctionBody {
|
| + Normal,
|
| + ArrowBlock = Normal,
|
| + ArrowConcise,
|
| +};
|
| +
|
| static inline ParseFunctionFlags operator|(ParseFunctionFlags lhs,
|
| ParseFunctionFlags rhs) {
|
| typedef unsigned char T;
|
| @@ -269,7 +275,7 @@ class ParserBase : public Traits {
|
| void set_generator_object_variable(
|
| typename Traits::Type::GeneratorVariable* variable) {
|
| DCHECK(variable != NULL);
|
| - DCHECK(is_generator());
|
| + DCHECK(is_generator() || is_async_function());
|
| generator_object_variable_ = variable;
|
| }
|
| typename Traits::Type::GeneratorVariable* generator_object_variable()
|
| @@ -2079,8 +2085,9 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
|
| ValidateArrowFormalParameters(&arrow_formals_classifier, expression,
|
| parenthesized_formals, is_async, CHECK_OK);
|
| Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos);
|
| - Scope* scope =
|
| - this->NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction);
|
| + Scope* scope = this->NewScope(scope_, FUNCTION_SCOPE,
|
| + is_async ? FunctionKind::kAsyncArrowFunction
|
| + : FunctionKind::kArrowFunction);
|
| // Because the arrow's parameters were parsed in the outer scope, any
|
| // usage flags that might have been triggered there need to be copied
|
| // to the arrow scope.
|
| @@ -3008,11 +3015,12 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
|
| int expected_property_count = -1;
|
| Scanner::Location super_loc;
|
|
|
| + FunctionKind arrow_kind = is_async ? kAsyncArrowFunction : kArrowFunction;
|
| {
|
| typename Traits::Type::Factory function_factory(ast_value_factory());
|
| - FunctionState function_state(
|
| - &function_state_, &scope_, formal_parameters.scope,
|
| - is_async ? kAsyncArrowFunction : kArrowFunction, &function_factory);
|
| + FunctionState function_state(&function_state_, &scope_,
|
| + formal_parameters.scope, arrow_kind,
|
| + &function_factory);
|
|
|
| function_state.SkipMaterializedLiterals(
|
| formal_parameters.materialized_literals_count);
|
| @@ -3037,7 +3045,7 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
|
| } else {
|
| body = this->ParseEagerFunctionBody(
|
| this->EmptyIdentifier(), RelocInfo::kNoPosition, formal_parameters,
|
| - kArrowFunction, FunctionLiteral::kAnonymousExpression, CHECK_OK);
|
| + arrow_kind, FunctionLiteral::kAnonymousExpression, CHECK_OK);
|
| materialized_literal_count =
|
| function_state.materialized_literal_count();
|
| expected_property_count = function_state.expected_property_count();
|
| @@ -3062,17 +3070,23 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
|
| is_tail_call_expression =
|
| allow_tailcalls() && !is_sloppy(language_mode());
|
| }
|
| - ExpressionT expression =
|
| - ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK);
|
| - Traits::RewriteNonPattern(&classifier, CHECK_OK);
|
| body = this->NewStatementList(1, zone());
|
| - this->AddParameterInitializationBlock(formal_parameters, body, CHECK_OK);
|
| - body->Add(factory()->NewReturnStatement(expression, pos), zone());
|
| + this->AddParameterInitializationBlock(formal_parameters, body, is_async,
|
| + CHECK_OK);
|
| + if (is_async) {
|
| + this->ParseAsyncArrowSingleExpressionBody(body, accept_IN, &classifier,
|
| + pos, CHECK_OK);
|
| + } else {
|
| + ExpressionT expression =
|
| + ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK);
|
| + Traits::RewriteNonPattern(&classifier, CHECK_OK);
|
| + body->Add(factory()->NewReturnStatement(expression, pos), zone());
|
| + if (is_tail_call_expression) {
|
| + this->MarkTailPosition(expression);
|
| + }
|
| + }
|
| materialized_literal_count = function_state.materialized_literal_count();
|
| expected_property_count = function_state.expected_property_count();
|
| - if (is_tail_call_expression) {
|
| - this->MarkTailPosition(expression);
|
| - }
|
| }
|
| super_loc = function_state.super_location();
|
|
|
| @@ -3101,7 +3115,7 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
|
| materialized_literal_count, expected_property_count, num_parameters,
|
| FunctionLiteral::kNoDuplicateParameters,
|
| FunctionLiteral::kAnonymousExpression,
|
| - FunctionLiteral::kShouldLazyCompile, FunctionKind::kArrowFunction,
|
| + FunctionLiteral::kShouldLazyCompile, arrow_kind,
|
| formal_parameters.scope->start_position());
|
|
|
| function_literal->set_function_token_position(
|
|
|