summaryrefslogtreecommitdiff
path: root/js/src/frontend/SyntaxParseHandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/frontend/SyntaxParseHandler.h')
-rw-r--r--js/src/frontend/SyntaxParseHandler.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/js/src/frontend/SyntaxParseHandler.h b/js/src/frontend/SyntaxParseHandler.h
index 4fef3584c8..85c8061162 100644
--- a/js/src/frontend/SyntaxParseHandler.h
+++ b/js/src/frontend/SyntaxParseHandler.h
@@ -58,6 +58,7 @@ class SyntaxParseHandler
// in code not actually executed (or at least not executed enough to be
// noticed).
NodeFunctionCall,
+ NodeOptionalFunctionCall,
// Nodes representing *parenthesized* IsValidSimpleAssignmentTarget
// nodes. We can't simply treat all such parenthesized nodes
@@ -78,7 +79,9 @@ class SyntaxParseHandler
NodeParenthesizedName,
NodeDottedProperty,
+ NodeOptionalDottedProperty,
NodeElement,
+ NodeOptionalElement,
// Destructuring target patterns can't be parenthesized: |([a]) = [3];|
// must be a syntax error. (We can't use NodeGeneric instead of these
@@ -146,6 +149,10 @@ class SyntaxParseHandler
return node == NodeDottedProperty || node == NodeElement;
}
+ bool isOptionalPropertyAccess(Node node) {
+ return node == NodeOptionalDottedProperty || node == NodeOptionalElement;
+ }
+
bool isFunctionCall(Node node) {
// Note: super() is a special form, *not* a function call.
return node == NodeFunctionCall;
@@ -283,6 +290,7 @@ class SyntaxParseHandler
void addArrayElement(Node literal, Node element) { }
Node newCall() { return NodeFunctionCall; }
+ Node newOptionalCall() { return NodeOptionalFunctionCall; }
Node newTaggedTemplate() { return NodeGeneric; }
Node newObjectLiteral(uint32_t begin) { return NodeUnparenthesizedObject; }
@@ -303,6 +311,7 @@ class SyntaxParseHandler
Node newYieldExpression(uint32_t begin, Node value) { return NodeGeneric; }
Node newYieldStarExpression(uint32_t begin, Node value) { return NodeGeneric; }
Node newAwaitExpression(uint32_t begin, Node value) { return NodeGeneric; }
+ Node newOptionalChain(uint32_t begin, Node value) { return NodeGeneric; }
// Statements
@@ -353,8 +362,15 @@ class SyntaxParseHandler
return NodeDottedProperty;
}
+ Node newOptionalPropertyAccess(Node pn, PropertyName* name, uint32_t end) {
+ lastAtom = name;
+ return NodeOptionalDottedProperty;
+ }
+
Node newPropertyByValue(Node pn, Node kid, uint32_t end) { return NodeElement; }
+ Node newOptionalPropertyByValue(Node pn, Node kid, uint32_t end) { return NodeOptionalElement; }
+
MOZ_MUST_USE bool addCatchBlock(Node catchList, Node letBlock, Node catchName,
Node catchGuard, Node catchBody) { return true; }
@@ -471,7 +487,8 @@ class SyntaxParseHandler
list == NodeUnparenthesizedCommaExpr ||
list == NodeVarDeclaration ||
list == NodeLexicalDeclaration ||
- list == NodeFunctionCall);
+ list == NodeFunctionCall ||
+ list == NodeOptionalFunctionCall);
}
Node newAssignment(ParseNodeKind kind, Node lhs, Node rhs, JSOp op) {
@@ -590,7 +607,7 @@ class SyntaxParseHandler
// |this|. It's not really eligible for the funapply/funcall
// optimizations as they're currently implemented (assuming a single
// value is used for both retrieval and |this|).
- if (node != NodeDottedProperty)
+ if (node != NodeDottedProperty && node != NodeOptionalDottedProperty)
return nullptr;
return lastAtom->asPropertyName();
}