Index: src/parsing/parser-base.h |
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
index f4cfc4974ccfec9470fdfec7bdd8ea1df5cec62c..d84465e8403a091c021e0bdb800e1ab7b49e51a6 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; |
@@ -260,7 +266,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() |
@@ -2013,8 +2019,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. |
@@ -2941,11 +2948,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); |
@@ -2970,7 +2978,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(); |
@@ -2980,12 +2988,18 @@ ParserBase<Traits>::ParseArrowFunctionLiteral( |
int pos = position(); |
parenthesized_function_ = false; |
ExpressionClassifier classifier(this); |
- 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()); |
+ } |
materialized_literal_count = function_state.materialized_literal_count(); |
expected_property_count = function_state.expected_property_count(); |
} |
@@ -3016,7 +3030,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( |