From 22fddd8fb3498ff2a07a365ca752e876a9b982e2 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Tue, 12 Dec 2017 15:17:52 -0600 Subject: [PATCH] Bug 1424420 - Adjust AutoAwaitIsKeyword template parameters slightly so a full parser type need not be written out. r=arai --HG-- extra : rebase_source : 71991d60647fbc7cfa092d81d9a8e073bed25f36 --- js/src/frontend/Parser.cpp | 13 +++++-------- js/src/frontend/Parser.h | 14 ++++++++------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index f2f36ded7783..1bca2fb6524e 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -2239,8 +2239,7 @@ Parser::moduleBody(ModuleSharedContext* modulesc) if (!mn) return null(); - AutoAwaitIsKeyword> awaitIsKeyword(this, - AwaitIsModuleKeyword); + AutoAwaitIsKeyword awaitIsKeyword(this, AwaitIsModuleKeyword); ParseNode* pn = statementList(YieldIsName); if (!pn) return null(); @@ -2583,7 +2582,7 @@ Parser::standaloneFunction(HandleFunction fun, YieldHandling yieldHandling = GetYieldHandling(generatorKind); AwaitHandling awaitHandling = GetAwaitHandling(asyncKind); - AutoAwaitIsKeyword> awaitIsKeyword(this, awaitHandling); + AutoAwaitIsKeyword awaitIsKeyword(this, awaitHandling); if (!functionFormalParametersAndBody(InAllowed, yieldHandling, fn, Statement, parameterListEnd, /* isStandaloneFunction = */ true)) { @@ -3711,7 +3710,7 @@ GeneralParser::functionFormalParametersAndBody(InHandling i AwaitHandling awaitHandling = funbox->isAsync() || (kind == Arrow && awaitIsKeyword()) ? AwaitIsKeyword : AwaitIsName; - AutoAwaitIsKeyword> awaitIsKeyword(this, awaitHandling); + AutoAwaitIsKeyword awaitIsKeyword(this, awaitHandling); if (!functionArguments(yieldHandling, kind, pn)) return false; } @@ -3786,8 +3785,7 @@ GeneralParser::functionFormalParametersAndBody(InHandling i bool inheritedStrict = pc->sc()->strict(); Node body; { - AutoAwaitIsKeyword> awaitIsKeyword(this, - bodyAwaitHandling); + AutoAwaitIsKeyword awaitIsKeyword(this, bodyAwaitHandling); body = functionBody(inHandling, bodyYieldHandling, kind, bodyType); if (!body) return false; @@ -3951,8 +3949,7 @@ GeneralParser::functionExpr(uint32_t toStringStart, { MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_FUNCTION)); - AutoAwaitIsKeyword> awaitIsKeyword(this, - GetAwaitHandling(asyncKind)); + AutoAwaitIsKeyword awaitIsKeyword(this, GetAwaitHandling(asyncKind)); GeneratorKind generatorKind = GeneratorKind::NotGenerator; TokenKind tt; if (!tokenStream.getToken(&tt)) diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index f69416f5ab7e..f69b25109cb7 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -119,7 +119,7 @@ enum FunctionCallBehavior { ForbidAssignmentToFunctionCalls }; -template +template class AutoAwaitIsKeyword; class ParserBase : public StrictModeGetter @@ -168,7 +168,7 @@ class ParserBase : public StrictModeGetter return awaitHandling_ != AwaitIsName; } - template friend class AutoAwaitIsKeyword; + template friend class AutoAwaitIsKeyword; ParserBase(JSContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options, const char16_t* chars, size_t length, bool foldConstants, @@ -1120,7 +1120,7 @@ class Parser final // Functions present in both Parser specializations. - friend class AutoAwaitIsKeyword>; + friend class AutoAwaitIsKeyword; inline void setAwaitHandling(AwaitHandling awaitHandling); Node newRegExp(); @@ -1264,15 +1264,17 @@ ParserAnyCharsAccess::anyChars(const typename Parser::TokenStream::Chars return reinterpret_cast(parserAddr)->anyChars; } -template +template class MOZ_STACK_CLASS AutoAwaitIsKeyword { + using GeneralParser = frontend::GeneralParser; + private: - Parser* parser_; + GeneralParser* parser_; AwaitHandling oldAwaitHandling_; public: - AutoAwaitIsKeyword(Parser* parser, AwaitHandling awaitHandling) { + AutoAwaitIsKeyword(GeneralParser* parser, AwaitHandling awaitHandling) { parser_ = parser; oldAwaitHandling_ = static_cast(parser_->awaitHandling_);