mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 14:58:37 +09:00
Issue #2298 - Carry private-ness of names through ParseNodeHandler
This commit is contained in:
parent
8ea70e0eac
commit
b0d9f0e2ed
3 changed files with 19 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue