Bug 1424420 - Adjust AutoAwaitIsKeyword template parameters slightly so a full parser type need not be written out. r=arai

--HG--
extra : rebase_source : 71991d60647fbc7cfa092d81d9a8e073bed25f36
This commit is contained in:
Jeff Walden 2017-12-12 15:17:52 -06:00
Родитель 159471f578
Коммит 22fddd8fb3
2 изменённых файлов: 13 добавлений и 14 удалений

Просмотреть файл

@ -2239,8 +2239,7 @@ Parser<FullParseHandler, CharT>::moduleBody(ModuleSharedContext* modulesc)
if (!mn)
return null();
AutoAwaitIsKeyword<GeneralParser<FullParseHandler, CharT>> awaitIsKeyword(this,
AwaitIsModuleKeyword);
AutoAwaitIsKeyword<FullParseHandler, CharT> awaitIsKeyword(this, AwaitIsModuleKeyword);
ParseNode* pn = statementList(YieldIsName);
if (!pn)
return null();
@ -2583,7 +2582,7 @@ Parser<FullParseHandler, CharT>::standaloneFunction(HandleFunction fun,
YieldHandling yieldHandling = GetYieldHandling(generatorKind);
AwaitHandling awaitHandling = GetAwaitHandling(asyncKind);
AutoAwaitIsKeyword<GeneralParser<FullParseHandler, CharT>> awaitIsKeyword(this, awaitHandling);
AutoAwaitIsKeyword<FullParseHandler, CharT> awaitIsKeyword(this, awaitHandling);
if (!functionFormalParametersAndBody(InAllowed, yieldHandling, fn, Statement,
parameterListEnd, /* isStandaloneFunction = */ true))
{
@ -3711,7 +3710,7 @@ GeneralParser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling i
AwaitHandling awaitHandling = funbox->isAsync() || (kind == Arrow && awaitIsKeyword())
? AwaitIsKeyword
: AwaitIsName;
AutoAwaitIsKeyword<GeneralParser<ParseHandler, CharT>> awaitIsKeyword(this, awaitHandling);
AutoAwaitIsKeyword<ParseHandler, CharT> awaitIsKeyword(this, awaitHandling);
if (!functionArguments(yieldHandling, kind, pn))
return false;
}
@ -3786,8 +3785,7 @@ GeneralParser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling i
bool inheritedStrict = pc->sc()->strict();
Node body;
{
AutoAwaitIsKeyword<GeneralParser<ParseHandler, CharT>> awaitIsKeyword(this,
bodyAwaitHandling);
AutoAwaitIsKeyword<ParseHandler, CharT> awaitIsKeyword(this, bodyAwaitHandling);
body = functionBody(inHandling, bodyYieldHandling, kind, bodyType);
if (!body)
return false;
@ -3951,8 +3949,7 @@ GeneralParser<ParseHandler, CharT>::functionExpr(uint32_t toStringStart,
{
MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_FUNCTION));
AutoAwaitIsKeyword<GeneralParser<ParseHandler, CharT>> awaitIsKeyword(this,
GetAwaitHandling(asyncKind));
AutoAwaitIsKeyword<ParseHandler, CharT> awaitIsKeyword(this, GetAwaitHandling(asyncKind));
GeneratorKind generatorKind = GeneratorKind::NotGenerator;
TokenKind tt;
if (!tokenStream.getToken(&tt))

Просмотреть файл

@ -119,7 +119,7 @@ enum FunctionCallBehavior {
ForbidAssignmentToFunctionCalls
};
template <class Parser>
template <class ParseHandler, typename CharT>
class AutoAwaitIsKeyword;
class ParserBase : public StrictModeGetter
@ -168,7 +168,7 @@ class ParserBase : public StrictModeGetter
return awaitHandling_ != AwaitIsName;
}
template<class> friend class AutoAwaitIsKeyword;
template<class, typename> 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<FullParseHandler, CharT> final
// Functions present in both Parser<ParseHandler, CharT> specializations.
friend class AutoAwaitIsKeyword<GeneralParser<SyntaxParseHandler, CharT>>;
friend class AutoAwaitIsKeyword<SyntaxParseHandler, CharT>;
inline void setAwaitHandling(AwaitHandling awaitHandling);
Node newRegExp();
@ -1264,15 +1264,17 @@ ParserAnyCharsAccess<Parser>::anyChars(const typename Parser::TokenStream::Chars
return reinterpret_cast<const Parser*>(parserAddr)->anyChars;
}
template <class Parser>
template <class ParseHandler, typename CharT>
class MOZ_STACK_CLASS AutoAwaitIsKeyword
{
using GeneralParser = frontend::GeneralParser<ParseHandler, CharT>;
private:
Parser* parser_;
GeneralParser* parser_;
AwaitHandling oldAwaitHandling_;
public:
AutoAwaitIsKeyword(Parser* parser, AwaitHandling awaitHandling) {
AutoAwaitIsKeyword(GeneralParser* parser, AwaitHandling awaitHandling) {
parser_ = parser;
oldAwaitHandling_ = static_cast<AwaitHandling>(parser_->awaitHandling_);