diff options
Diffstat (limited to 'js/src/frontend/FullParseHandler.h')
-rw-r--r-- | js/src/frontend/FullParseHandler.h | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/js/src/frontend/FullParseHandler.h b/js/src/frontend/FullParseHandler.h index f34635125..eeb4432e4 100644 --- a/js/src/frontend/FullParseHandler.h +++ b/js/src/frontend/FullParseHandler.h @@ -74,6 +74,10 @@ class FullParseHandler return node->isKind(PNK_DOT) || node->isKind(PNK_ELEM); } + bool isOptionalPropertyAccess(ParseNode* node) { + return node->isKind(PNK_OPTDOT) || node->isKind(PNK_OPTELEM); + } + bool isFunctionCall(ParseNode* node) { // Note: super() is a special form, *not* a function call. return node->isKind(PNK_CALL); @@ -213,6 +217,18 @@ class FullParseHandler if (expr->isKind(PNK_ELEM)) return newUnary(PNK_DELETEELEM, JSOP_NOP, begin, expr); + if (expr->isKind(PNK_OPTCHAIN)) { + ParseNode* kid = expr->pn_kid; + // Handle property deletion explicitly. OptionalCall is handled + // via DeleteExpr. + if (kid->isKind(PNK_DOT) || + kid->isKind(PNK_OPTDOT) || + kid->isKind(PNK_ELEM) || + kid->isKind(PNK_OPTELEM)) { + return newUnary(PNK_DELETEOPTCHAIN, JSOP_NOP, begin, kid); + } + } + return newUnary(PNK_DELETEEXPR, JSOP_NOP, begin, expr); } @@ -319,6 +335,10 @@ class FullParseHandler return newList(PNK_CALL, JSOP_CALL); } + ParseNode* newOptionalCall() { + return newList(PNK_OPTCALL, JSOP_CALL); + } + ParseNode* newTaggedTemplate() { return newList(PNK_TAGGED_TEMPLATE, JSOP_CALL); } @@ -459,6 +479,11 @@ class FullParseHandler return new_<UnaryNode>(PNK_AWAIT, JSOP_AWAIT, pos, value); } + ParseNode* newOptionalChain(uint32_t begin, ParseNode* value) { + TokenPos pos(begin, value->pn_pos.end); + return new_<UnaryNode>(PNK_OPTCHAIN, JSOP_NOP, pos, value); + } + // Statements ParseNode* newStatementList(const TokenPos& pos) { @@ -678,6 +703,14 @@ class FullParseHandler return new_<PropertyByValue>(lhs, index, lhs->pn_pos.begin, end); } + ParseNode* newOptionalPropertyAccess(ParseNode* pn, PropertyName* name, uint32_t end) { + return new_<OptionalPropertyAccess>(pn, name, pn->pn_pos.begin, end); + } + + ParseNode* newOptionalPropertyByValue(ParseNode* lhs, ParseNode* index, uint32_t end) { + return new_<OptionalPropertyByValue>(lhs, index, lhs->pn_pos.begin, end); + } + inline MOZ_MUST_USE bool addCatchBlock(ParseNode* catchList, ParseNode* lexicalScope, ParseNode* catchName, ParseNode* catchGuard, ParseNode* catchBody); @@ -920,7 +953,9 @@ class FullParseHandler return pn->isKind(PNK_CALL); } PropertyName* maybeDottedProperty(ParseNode* pn) { - return pn->is<PropertyAccess>() ? &pn->as<PropertyAccess>().name() : nullptr; + return pn->is<PropertyAccessBase>() ? + &pn->as<PropertyAccessBase>().name() : + nullptr; } JSAtom* isStringExprStatement(ParseNode* pn, TokenPos* pos) { if (JSAtom* atom = pn->isStringExprStatement()) { |