1336783 - Part 1: Rework on reserved word and remove TokenStream::KeywordIsName.

This commit is contained in:
Gaming4JC 2019-06-09 16:14:01 -04:00 • committed by Roy Tam
commit c1f6b0ff36
15 changed files with 851 additions and 722 deletions

View file

@ -734,6 +734,9 @@ class UsedNameTracker
}
};
template <typename ParseHandler>
class AutoAwaitIsKeyword;
class ParserBase : public StrictModeGetter
{
private:
@ -783,7 +786,13 @@ class ParserBase : public StrictModeGetter
/* Unexpected end of input, i.e. TOK_EOF not at top-level. */
bool isUnexpectedEOF_:1;
bool awaitIsKeyword_:1;
public:
bool awaitIsKeyword() const {
return awaitIsKeyword_;
}
ParserBase(ExclusiveContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
const char16_t* chars, size_t length, bool foldConstants,
UsedNameTracker& usedNames, Parser<SyntaxParseHandler>* syntaxParser,
@ -998,6 +1007,9 @@ class Parser final : public ParserBase, private JS::AutoGCRooter
Parser<SyntaxParseHandler>* syntaxParser, LazyScript* lazyOuterFunction);
~Parser();
friend class AutoAwaitIsKeyword<ParseHandler>;
void setAwaitIsKeyword(bool isKeyword);
bool checkOptions();
// A Parser::Mark is the extension of the LifoAlloc::Mark to the entire
@ -1047,8 +1059,6 @@ class Parser final : public ParserBase, private JS::AutoGCRooter
void trace(JSTracer* trc);
bool checkUnescapedName();
private:
Parser* thisForCtor() { return this; }
@ -1321,17 +1331,18 @@ class Parser final : public ParserBase, private JS::AutoGCRooter
Node classDefinition(YieldHandling yieldHandling, ClassContext classContext,
DefaultHandling defaultHandling);
PropertyName* labelOrIdentifierReference(YieldHandling yieldHandling,
bool yieldTokenizedAsName);
PropertyName* checkLabelOrIdentifierReference(PropertyName* ident,
uint32_t offset,
YieldHandling yieldHandling);
PropertyName* labelOrIdentifierReference(YieldHandling yieldHandling);
PropertyName* labelIdentifier(YieldHandling yieldHandling) {
return labelOrIdentifierReference(yieldHandling, false);
return labelOrIdentifierReference(yieldHandling);
}
PropertyName* identifierReference(YieldHandling yieldHandling,
bool yieldTokenizedAsName = false)
{
return labelOrIdentifierReference(yieldHandling, yieldTokenizedAsName);
PropertyName* identifierReference(YieldHandling yieldHandling) {
return labelOrIdentifierReference(yieldHandling);
}
PropertyName* importedBinding() {
@ -1455,6 +1466,25 @@ class Parser final : public ParserBase, private JS::AutoGCRooter
bool asmJS(Node list);
};
template <typename ParseHandler>
class MOZ_STACK_CLASS AutoAwaitIsKeyword
{
private:
Parser<ParseHandler>* parser_;
bool oldAwaitIsKeyword_;
public:
AutoAwaitIsKeyword(Parser<ParseHandler>* parser, bool awaitIsKeyword) {
parser_ = parser;
oldAwaitIsKeyword_ = parser_->awaitIsKeyword_;
parser_->setAwaitIsKeyword(awaitIsKeyword);
}
~AutoAwaitIsKeyword() {
parser_->setAwaitIsKeyword(oldAwaitIsKeyword_);
}
};
} /* namespace frontend */
} /* namespace js */