diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2019-06-09 16:14:01 -0400 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2019-07-18 22:38:35 -0400 |
commit | 09efd3b4db44175e58c80b3cf4f3408ef218ab19 (patch) | |
tree | 036823d2032034267a87f28139fb3c47d79d6a65 /js/src/frontend/Parser.h | |
parent | efecd2f835bb3761760b0efb4c5e35ae8d18a4a6 (diff) | |
download | uxp-09efd3b4db44175e58c80b3cf4f3408ef218ab19.tar.gz |
1336783 - Part 1: Rework on reserved word and remove TokenStream::KeywordIsName.
Diffstat (limited to 'js/src/frontend/Parser.h')
-rw-r--r-- | js/src/frontend/Parser.h | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index 35b9384a80..9ec862d928 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -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 */ |