summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/src/frontend/FullParseHandler.h4
-rw-r--r--js/src/frontend/ParseNode.h4
-rw-r--r--js/src/frontend/SyntaxParseHandler.h12
3 files changed, 19 insertions, 1 deletions
diff --git a/js/src/frontend/FullParseHandler.h b/js/src/frontend/FullParseHandler.h
index e27b9f540a..d2c8bbc2df 100644
--- a/js/src/frontend/FullParseHandler.h
+++ b/js/src/frontend/FullParseHandler.h
@@ -965,6 +965,10 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return node->isKind(PNK_NAME);
}
+ bool isPrivateName(Node node) {
+ return node->isKind(PNK_NAME) && node->as<NameNode>().isPrivateName();
+ }
+
bool isArgumentsAnyParentheses(Node node, ExclusiveContext* cx) {
return node->isKind(PNK_NAME) && node->as<NameNode>().atom() == cx->names().arguments;
}
diff --git a/js/src/frontend/ParseNode.h b/js/src/frontend/ParseNode.h
index b1fcab0735..439a6d8937 100644
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -953,6 +953,10 @@ class NameNode : public ParseNode
JSAtom* atom() const {
return pn_u.name.atom;
}
+
+ bool isPrivateName() const {
+ return atom()->asPropertyName()->latin1OrTwoByteChar(0) == '#';
+ }
ParseNode* initializer() const {
return pn_u.name.initOrStmt;
diff --git a/js/src/frontend/SyntaxParseHandler.h b/js/src/frontend/SyntaxParseHandler.h
index 818530cfe9..80ca13ce45 100644
--- a/js/src/frontend/SyntaxParseHandler.h
+++ b/js/src/frontend/SyntaxParseHandler.h
@@ -104,6 +104,9 @@ class SyntaxParseHandler
// Node representing the "async" name, which may actually be a
// contextual keyword.
NodePotentialAsyncKeyword,
+
+ // Node representing a private name. Handled mostly like NodeUnparenthesizedName.
+ NodePrivateName,
// Valuable for recognizing potential destructuring patterns.
NodeUnparenthesizedArray,
@@ -212,6 +215,8 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return NodePotentialAsyncKeyword;
if (name == cx->names().eval)
return NodeUnparenthesizedEvalName;
+ if (name->length() >= 1 && name->latin1OrTwoByteChar(0) == '#')
+ return NodePrivateName;
return NodeUnparenthesizedName;
}
@@ -614,7 +619,8 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return node == NodeUnparenthesizedArgumentsName ||
node == NodeUnparenthesizedEvalName ||
node == NodeUnparenthesizedName ||
- node == NodePotentialAsyncKeyword;
+ node == NodePotentialAsyncKeyword ||
+ node == NodePrivateName;
}
bool isNameAnyParentheses(Node node) {
@@ -625,6 +631,10 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
node == NodeParenthesizedName;
}
+ bool isPrivateName(Node node) {
+ return node == NodePrivateName;
+ }
+
bool isArgumentsAnyParentheses(Node node, ExclusiveContext* cx) {
return node == NodeUnparenthesizedArgumentsName || node == NodeParenthesizedArgumentsName;
}