| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index f0affc27985c5e8b68f7bfbd3e94755e9cb96426..62a7468ab6f671d45bad5f95c0b7c230611c6330 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -927,6 +927,7 @@ Parser::Parser(ParseInfo* info)
|
| set_allow_strong_mode(FLAG_strong_mode);
|
| set_allow_legacy_const(FLAG_legacy_const);
|
| set_allow_harmony_do_expressions(FLAG_harmony_do_expressions);
|
| + set_allow_harmony_async_await(FLAG_harmony_async_await);
|
| for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
|
| ++feature) {
|
| use_counts_[feature] = 0;
|
| @@ -1408,6 +1409,11 @@ Statement* Parser::ParseStatementListItem(bool* ok) {
|
| }
|
|
|
| switch (peek()) {
|
| + case Token::ASYNC:
|
| + if (allow_harmony_async_await() && IsNextAsyncFunctionKeyword()) {
|
| + return ParseFunctionDeclaration(NULL, ok);
|
| + }
|
| + break;
|
| case Token::FUNCTION:
|
| return ParseFunctionDeclaration(NULL, ok);
|
| case Token::CLASS:
|
| @@ -2229,12 +2235,16 @@ Statement* Parser::ParseFunctionDeclaration(
|
| ZoneList<const AstRawString*>* names, bool* ok) {
|
| // FunctionDeclaration ::
|
| // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}'
|
| + // AsyncFunctionDeclaration ::
|
| + // 'async' 'function' Identifier '(' FormalParameterListopt ')'
|
| + // '{' FunctionBody '}'
|
| // GeneratorDeclaration ::
|
| // 'function' '*' Identifier '(' FormalParameterListopt ')'
|
| // '{' FunctionBody '}'
|
| + bool is_async = allow_harmony_async_await() ? Check(Token::ASYNC) : false;
|
| Expect(Token::FUNCTION, CHECK_OK);
|
| int pos = position();
|
| - bool is_generator = Check(Token::MUL);
|
| + bool is_generator = is_async ? false : Check(Token::MUL);
|
| bool is_strict_reserved = false;
|
| const AstRawString* name = ParseIdentifierOrStrictReservedWord(
|
| &is_strict_reserved, CHECK_OK);
|
| @@ -2243,13 +2253,19 @@ Statement* Parser::ParseFunctionDeclaration(
|
| fni_->Enter();
|
| fni_->PushEnclosingName(name);
|
| }
|
| +
|
| + FunctionKind kind = FunctionKind::kNormalFunction;
|
| + if (is_generator) {
|
| + kind = FunctionKind::kGeneratorFunction;
|
| + } else if (is_async) {
|
| + kind = FunctionKind::kAsyncFunction;
|
| + }
|
| +
|
| FunctionLiteral* fun = ParseFunctionLiteral(
|
| name, scanner()->location(),
|
| is_strict_reserved ? kFunctionNameIsStrictReserved
|
| : kFunctionNameValidityUnknown,
|
| - is_generator ? FunctionKind::kGeneratorFunction
|
| - : FunctionKind::kNormalFunction,
|
| - pos, FunctionLiteral::DECLARATION, FunctionLiteral::NORMAL_ARITY,
|
| + kind, pos, FunctionLiteral::DECLARATION, FunctionLiteral::NORMAL_ARITY,
|
| language_mode(), CHECK_OK);
|
| if (fni_ != NULL) fni_->Leave();
|
|
|
| @@ -4818,6 +4834,7 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
|
| SET_ALLOW(harmony_new_target);
|
| SET_ALLOW(strong_mode);
|
| SET_ALLOW(harmony_do_expressions);
|
| + SET_ALLOW(harmony_async_await);
|
| #undef SET_ALLOW
|
| }
|
| PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
|
|
|