Issue #2173 - Add accessors to NullaryNode and change LoopControlStatement arity to PN_LOOP

Based-on: m-c 1479659/6
This commit is contained in:
Martok 2023-04-01 01:08:40 +02:00 • committed by roytam1
commit a49f4d0483
10 changed files with 166 additions and 68 deletions

View file

@ -1060,7 +1060,7 @@ BytecodeEmitter::checkSideEffects(ParseNode* pn, bool* answer)
case PNK_RAW_UNDEFINED: case PNK_RAW_UNDEFINED:
case PNK_ELISION: case PNK_ELISION:
case PNK_GENERATOR: case PNK_GENERATOR:
MOZ_ASSERT(pn->isArity(PN_NULLARY)); MOZ_ASSERT(pn->is<NullaryNode>());
*answer = false; *answer = false;
return true; return true;
@ -1096,9 +1096,17 @@ BytecodeEmitter::checkSideEffects(ParseNode* pn, bool* answer)
return true; return true;
case PNK_BREAK: case PNK_BREAK:
MOZ_ASSERT(pn->is<BreakStatement>());
*answer = true;
return true;
case PNK_CONTINUE: case PNK_CONTINUE:
MOZ_ASSERT(pn->is<ContinueStatement>());
*answer = true;
return true;
case PNK_DEBUGGER: case PNK_DEBUGGER:
MOZ_ASSERT(pn->isArity(PN_NULLARY)); MOZ_ASSERT(pn->is<DebuggerStatement>());
*answer = true; *answer = true;
return true; return true;

View file

@ -101,8 +101,12 @@ ContainsHoistedDeclaration(ExclusiveContext* cx, ParseNode* node, bool* result)
// Statements with no sub-components at all. // Statements with no sub-components at all.
case PNK_NOP: // induced by function f() {} function f() {} case PNK_NOP: // induced by function f() {} function f() {}
MOZ_ASSERT(node->is<NullaryNode>());
*result = false;
return true;
case PNK_DEBUGGER: case PNK_DEBUGGER:
MOZ_ASSERT(node->isArity(PN_NULLARY)); MOZ_ASSERT(node->is<DebuggerStatement>());
*result = false; *result = false;
return true; return true;
@ -1655,13 +1659,22 @@ Fold(ExclusiveContext* cx, ParseNode** pnp, Parser<FullParseHandler>& parser, bo
case PNK_NULL: case PNK_NULL:
case PNK_RAW_UNDEFINED: case PNK_RAW_UNDEFINED:
case PNK_ELISION: case PNK_ELISION:
case PNK_DEBUGGER:
case PNK_BREAK:
case PNK_CONTINUE:
case PNK_GENERATOR: case PNK_GENERATOR:
case PNK_EXPORT_BATCH_SPEC: case PNK_EXPORT_BATCH_SPEC:
case PNK_POSHOLDER: case PNK_POSHOLDER:
MOZ_ASSERT(pn->isArity(PN_NULLARY)); MOZ_ASSERT(pn->is<NullaryNode>());
return true;
case PNK_DEBUGGER:
MOZ_ASSERT(pn->is<DebuggerStatement>());
return true;
case PNK_BREAK:
MOZ_ASSERT(pn->is<BreakStatement>());
return true;
case PNK_CONTINUE:
MOZ_ASSERT(pn->is<ContinueStatement>());
return true; return true;
case PNK_OBJECT_PROPERTY_NAME: case PNK_OBJECT_PROPERTY_NAME:

View file

@ -151,7 +151,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return new_<NumericLiteral>(value, decimalPoint, pos); return new_<NumericLiteral>(value, decimalPoint, pos);
} }
ParseNode* newBooleanLiteral(bool cond, const TokenPos& pos) { BooleanLiteralType newBooleanLiteral(bool cond, const TokenPos& pos) {
return new_<BooleanLiteral>(cond, pos); return new_<BooleanLiteral>(cond, pos);
} }
@ -195,11 +195,11 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return new_<ThisLiteral>(pos, thisName); return new_<ThisLiteral>(pos, thisName);
} }
ParseNode* newNullLiteral(const TokenPos& pos) { NullLiteralType newNullLiteral(const TokenPos& pos) {
return new_<NullLiteral>(pos); return new_<NullLiteral>(pos);
} }
ParseNode* newRawUndefinedLiteral(const TokenPos& pos) { RawUndefinedLiteralType newRawUndefinedLiteral(const TokenPos& pos) {
return new_<RawUndefinedLiteral>(pos); return new_<RawUndefinedLiteral>(pos);
} }
@ -251,7 +251,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return new_<UnaryNode>(kind, JSOP_NOP, pos, kid); return new_<UnaryNode>(kind, JSOP_NOP, pos, kid);
} }
ParseNode* newNullary(ParseNodeKind kind, JSOp op, const TokenPos& pos) { NullaryNodeType newNullary(ParseNodeKind kind, JSOp op, const TokenPos& pos) {
return new_<NullaryNode>(kind, op, pos); return new_<NullaryNode>(kind, op, pos);
} }
@ -311,7 +311,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
} }
MOZ_MUST_USE bool addElision(ListNodeType literal, const TokenPos& pos) { MOZ_MUST_USE bool addElision(ListNodeType literal, const TokenPos& pos) {
ParseNode* elision = new_<NullaryNode>(PNK_ELISION, pos); NullaryNode* elision = new_<NullaryNode>(PNK_ELISION, pos);
if (!elision) if (!elision)
return false; return false;
literal->append(elision); literal->append(elision);
@ -377,10 +377,10 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
ClassNamesType newClassNames(ParseNode* outer, ParseNode* inner, const TokenPos& pos) { ClassNamesType newClassNames(ParseNode* outer, ParseNode* inner, const TokenPos& pos) {
return new_<ClassNames>(outer, inner, pos); return new_<ClassNames>(outer, inner, pos);
} }
BinaryNodeType newNewTarget(ParseNode* newHolder, ParseNode* targetHolder) { BinaryNodeType newNewTarget(NullaryNodeType newHolder, NullaryNodeType targetHolder) {
return new_<BinaryNode>(PNK_NEWTARGET, JSOP_NOP, newHolder, targetHolder); return new_<BinaryNode>(PNK_NEWTARGET, JSOP_NOP, newHolder, targetHolder);
} }
ParseNode* newPosHolder(const TokenPos& pos) { NullaryNodeType newPosHolder(const TokenPos& pos) {
return new_<NullaryNode>(PNK_POSHOLDER, pos); return new_<NullaryNode>(PNK_POSHOLDER, pos);
} }
UnaryNodeType newSuperBase(Node thisName, const TokenPos& pos) { UnaryNodeType newSuperBase(Node thisName, const TokenPos& pos) {
@ -536,7 +536,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
MOZ_ASSERT(stmtList->isKind(PNK_STATEMENTLIST)); MOZ_ASSERT(stmtList->isKind(PNK_STATEMENTLIST));
TokenPos yieldPos(stmtList->pn_pos.begin, stmtList->pn_pos.begin + 1); TokenPos yieldPos(stmtList->pn_pos.begin, stmtList->pn_pos.begin + 1);
ParseNode* makeGen = new_<NullaryNode>(PNK_GENERATOR, yieldPos); NullaryNode* makeGen = new_<NullaryNode>(PNK_GENERATOR, yieldPos);
if (!makeGen) if (!makeGen)
return false; return false;
@ -560,7 +560,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return newBinary(PNK_SETTHIS, thisName, val); return newBinary(PNK_SETTHIS, thisName, val);
} }
ParseNode* newEmptyStatement(const TokenPos& pos) { UnaryNodeType newEmptyStatement(const TokenPos& pos) {
return new_<UnaryNode>(PNK_SEMI, JSOP_NOP, pos, (ParseNode*) nullptr); return new_<UnaryNode>(PNK_SEMI, JSOP_NOP, pos, (ParseNode*) nullptr);
} }
@ -657,11 +657,11 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return new_<CaseClause>(expr, body, begin); return new_<CaseClause>(expr, body, begin);
} }
ParseNode* newContinueStatement(PropertyName* label, const TokenPos& pos) { ContinueStatementType newContinueStatement(PropertyName* label, const TokenPos& pos) {
return new_<ContinueStatement>(label, pos); return new_<ContinueStatement>(label, pos);
} }
ParseNode* newBreakStatement(PropertyName* label, const TokenPos& pos) { BreakStatementType newBreakStatement(PropertyName* label, const TokenPos& pos) {
return new_<BreakStatement>(label, pos); return new_<BreakStatement>(label, pos);
} }
@ -690,7 +690,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return new_<TernaryNode>(PNK_TRY, JSOP_NOP, body, catchList, finallyBlock, pos); return new_<TernaryNode>(PNK_TRY, JSOP_NOP, body, catchList, finallyBlock, pos);
} }
ParseNode* newDebuggerStatement(const TokenPos& pos) { DebuggerStatementType newDebuggerStatement(const TokenPos& pos) {
return new_<DebuggerStatement>(pos); return new_<DebuggerStatement>(pos);
} }

View file

@ -388,12 +388,21 @@ class NameResolver
case PNK_RAW_UNDEFINED: case PNK_RAW_UNDEFINED:
case PNK_ELISION: case PNK_ELISION:
case PNK_GENERATOR: case PNK_GENERATOR:
case PNK_BREAK:
case PNK_CONTINUE:
case PNK_DEBUGGER:
case PNK_EXPORT_BATCH_SPEC: case PNK_EXPORT_BATCH_SPEC:
case PNK_POSHOLDER: case PNK_POSHOLDER:
MOZ_ASSERT(cur->isArity(PN_NULLARY)); MOZ_ASSERT(cur->is<NullaryNode>());
break;
case PNK_DEBUGGER:
MOZ_ASSERT(cur->is<DebuggerStatement>());
break;
case PNK_BREAK:
MOZ_ASSERT(cur->is<BreakStatement>());
break;
case PNK_CONTINUE:
MOZ_ASSERT(cur->is<ContinueStatement>());
break; break;
case PNK_OBJECT_PROPERTY_NAME: case PNK_OBJECT_PROPERTY_NAME:
@ -801,7 +810,7 @@ class NameResolver
ListNode* list = &cur->as<ListNode>(); ListNode* list = &cur->as<ListNode>();
ParseNode* item = list->head(); ParseNode* item = list->head();
if (!isImport && item && item->isKind(PNK_EXPORT_BATCH_SPEC)) { if (!isImport && item && item->isKind(PNK_EXPORT_BATCH_SPEC)) {
MOZ_ASSERT(item->isArity(PN_NULLARY)); MOZ_ASSERT(item->is<NullaryNode>());
break; break;
} }
for (ParseNode* item : list->contents()) { for (ParseNode* item : list->contents()) {

View file

@ -183,14 +183,23 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
case PNK_RAW_UNDEFINED: case PNK_RAW_UNDEFINED:
case PNK_ELISION: case PNK_ELISION:
case PNK_GENERATOR: case PNK_GENERATOR:
case PNK_BREAK:
case PNK_CONTINUE:
case PNK_DEBUGGER:
case PNK_EXPORT_BATCH_SPEC: case PNK_EXPORT_BATCH_SPEC:
case PNK_POSHOLDER: case PNK_POSHOLDER:
MOZ_ASSERT(pn->isArity(PN_NULLARY)); MOZ_ASSERT(pn->is<NullaryNode>());
return PushResult::Recyclable; return PushResult::Recyclable;
case PNK_DEBUGGER:
MOZ_ASSERT(pn->is<DebuggerStatement>());
return PushResult::Recyclable;
case PNK_BREAK:
MOZ_ASSERT(pn->is<BreakStatement>());
return PushResult::Recyclable;
case PNK_CONTINUE:
MOZ_ASSERT(pn->is<ContinueStatement>());
return PushResult::Recyclable;
case PNK_OBJECT_PROPERTY_NAME: case PNK_OBJECT_PROPERTY_NAME:
case PNK_STRING: case PNK_STRING:
case PNK_TEMPLATE_STRING: case PNK_TEMPLATE_STRING:
@ -662,7 +671,7 @@ ParseNode::dump(int indent)
{ {
switch (pn_arity) { switch (pn_arity) {
case PN_NULLARY: case PN_NULLARY:
((NullaryNode*) this)->dump(); as<NullaryNode>().dump();
return; return;
case PN_UNARY: case PN_UNARY:
as<UnaryNode>().dump(indent); as<UnaryNode>().dump(indent);
@ -688,6 +697,9 @@ ParseNode::dump(int indent)
case PN_REGEXP: case PN_REGEXP:
as<RegExpLiteral>().dump(indent); as<RegExpLiteral>().dump(indent);
return; return;
case PN_LOOP:
as<LoopControlStatement>().dump(indent);
return;
case PN_SCOPE: case PN_SCOPE:
((LexicalScopeNode*) this)->dump(indent); ((LexicalScopeNode*) this)->dump(indent);
return; return;
@ -731,6 +743,18 @@ RegExpLiteral::dump(int indent)
fprintf(stderr, "(%s)", parseNodeNames[size_t(getKind())]); fprintf(stderr, "(%s)", parseNodeNames[size_t(getKind())]);
} }
void
LoopControlStatement::dump(int indent)
{
const char* name = parseNodeNames[size_t(getKind())];
fprintf(stderr, "(%s", name);
if (label()) {
fprintf(stderr, " ");
label()->dumpCharsNoNewline();
}
fprintf(stderr, ")");
}
void void
UnaryNode::dump(int indent) UnaryNode::dump(int indent)
{ {

View file

@ -321,9 +321,9 @@ IsTypeofKind(ParseNodeKind kind)
* kid2: null or the catch guard expression * kid2: null or the catch guard expression
* kid3: catch block statements * kid3: catch block statements
* PNK_BREAK (BreakStatement) * PNK_BREAK (BreakStatement)
* atom: label or null * label: label or null
* PNK_CONTINUE (ContinueStatement) * PNK_CONTINUE (ContinueStatement)
* atom: label or null * label: label or null
* PNK_WITH (BinaryNode) * PNK_WITH (BinaryNode)
* left: head expr * left: head expr
* right: body * right: body
@ -506,10 +506,12 @@ IsTypeofKind(ParseNodeKind kind)
* regexp: RegExp model object * regexp: RegExp model object
* PNK_NUMBER (NumericLiteral) * PNK_NUMBER (NumericLiteral)
* value: double value of numeric literal * value: double value of numeric literal
* PNK_TRUE, nullary pn_op: JSOp bytecode * PNK_TRUE, PNK_FALSE (BooleanLiteral)
* PNK_FALSE, * pn_op: JSOp bytecode
* PNK_NULL, * PNK_NULL (NullLiteral)
* PNK_RAW_UNDEFINED * pn_op: JSOp bytecode
* PNK_RAW_UNDEFINED (RawUndefinedLiteral)
* pn_op: JSOp bytecode
* *
* PNK_THIS (UnaryNode) * PNK_THIS (UnaryNode)
* kid: '.this' Name if function `this`, else nullptr * kid: '.this' Name if function `this`, else nullptr
@ -524,7 +526,7 @@ IsTypeofKind(ParseNodeKind kind)
* right: SuperCall * right: SuperCall
* PNK_LEXICALSCOPE scope pn_u.scope.bindings: scope bindings * PNK_LEXICALSCOPE scope pn_u.scope.bindings: scope bindings
* pn_u.scope.body: scope body * pn_u.scope.body: scope body
* PNK_GENERATOR nullary * PNK_GENERATOR (NullaryNode)
* PNK_INITIALYIELD (UnaryNode) * PNK_INITIALYIELD (UnaryNode)
* kid: generator object * kid: generator object
* PNK_YIELD, PNK_YIELD_STAR, PNK_AWAIT (UnaryNode) * PNK_YIELD, PNK_YIELD_STAR, PNK_AWAIT (UnaryNode)
@ -535,7 +537,7 @@ IsTypeofKind(ParseNodeKind kind)
* if-guarded PNK_ARRAYPUSH * if-guarded PNK_ARRAYPUSH
* PNK_ARRAYPUSH unary pn_op: JSOP_ARRAYCOMP * PNK_ARRAYPUSH unary pn_op: JSOP_ARRAYCOMP
* pn_kid: array comprehension expression * pn_kid: array comprehension expression
* PNK_NOP nullary * PNK_NOP (NullaryNode)
*/ */
enum ParseNodeArity enum ParseNodeArity
{ {
@ -548,6 +550,7 @@ enum ParseNodeArity
PN_NAME, /* name, label, string */ PN_NAME, /* name, label, string */
PN_NUMBER, /* numeric literal */ PN_NUMBER, /* numeric literal */
PN_REGEXP, /* regexp literal */ PN_REGEXP, /* regexp literal */
PN_LOOP, /* loop control (break/continue) */
PN_SCOPE /* lexical scope */ PN_SCOPE /* lexical scope */
}; };
@ -567,9 +570,19 @@ enum ParseNodeArity
macro(ListNode, ListNodeType, asList) \ macro(ListNode, ListNodeType, asList) \
macro(CallSiteNode, CallSiteNodeType, asCallSite) \ macro(CallSiteNode, CallSiteNodeType, asCallSite) \
\ \
macro(LoopControlStatement, LoopControlStatementType, asLoopControlStatement) \
macro(BreakStatement, BreakStatementType, asBreakStatement) \
macro(ContinueStatement, ContinueStatementType, asContinueStatement) \
\
macro(NameNode, NameNodeType, asName) \ macro(NameNode, NameNodeType, asName) \
macro(LabeledStatement, LabeledStatementType, asLabeledStatement) \ macro(LabeledStatement, LabeledStatementType, asLabeledStatement) \
\ \
macro(NullaryNode, NullaryNodeType, asNullary) \
macro(BooleanLiteral, BooleanLiteralType, asBooleanLiteral) \
macro(DebuggerStatement, DebuggerStatementType, asDebuggerStatement) \
macro(NullLiteral, NullLiteralType, asNullLiteral) \
macro(RawUndefinedLiteral, RawUndefinedLiteralType, asRawUndefinedLiteral) \
\
macro(NumericLiteral, NumericLiteralType, asNumericLiteral) \ macro(NumericLiteral, NumericLiteralType, asNumericLiteral) \
\ \
macro(RegExpLiteral, RegExpLiteralType, asRegExpLiteral) \ macro(RegExpLiteral, RegExpLiteralType, asRegExpLiteral) \
@ -580,10 +593,6 @@ enum ParseNodeArity
macro(UnaryNode, UnaryNodeType, asUnary) \ macro(UnaryNode, UnaryNodeType, asUnary) \
macro(ThisLiteral, ThisLiteralType, asThisLiteral) macro(ThisLiteral, ThisLiteralType, asThisLiteral)
class LoopControlStatement;
class BreakStatement;
class ContinueStatement;
#define DECLARE_CLASS(typeName, longTypeName, asMethodName) \ #define DECLARE_CLASS(typeName, longTypeName, asMethodName) \
class typeName; class typeName;
FOR_EACH_PARSENODE_SUBCLASS(DECLARE_CLASS) FOR_EACH_PARSENODE_SUBCLASS(DECLARE_CLASS)
@ -733,6 +742,7 @@ class ParseNode
DecimalPoint decimalPoint; /* Whether the number has a decimal point */ DecimalPoint decimalPoint; /* Whether the number has a decimal point */
} number; } number;
class { class {
private:
friend class LoopControlStatement; friend class LoopControlStatement;
PropertyName* label; /* target of break/continue statement */ PropertyName* label; /* target of break/continue statement */
} loopControl; } loopControl;
@ -819,13 +829,18 @@ class ParseNode
#endif #endif
}; };
struct NullaryNode : public ParseNode class NullaryNode : public ParseNode
{ {
public:
NullaryNode(ParseNodeKind kind, const TokenPos& pos) NullaryNode(ParseNodeKind kind, const TokenPos& pos)
: ParseNode(kind, JSOP_NOP, PN_NULLARY, pos) {} : ParseNode(kind, JSOP_NOP, PN_NULLARY, pos) {}
NullaryNode(ParseNodeKind kind, JSOp op, const TokenPos& pos) NullaryNode(ParseNodeKind kind, JSOp op, const TokenPos& pos)
: ParseNode(kind, op, PN_NULLARY, pos) {} : ParseNode(kind, op, PN_NULLARY, pos) {}
static bool test(const ParseNode& node) {
return node.isArity(PN_NULLARY);
}
#ifdef DEBUG #ifdef DEBUG
void dump(); void dump();
#endif #endif
@ -1587,7 +1602,7 @@ class LoopControlStatement : public ParseNode
{ {
protected: protected:
LoopControlStatement(ParseNodeKind kind, PropertyName* label, const TokenPos& pos) LoopControlStatement(ParseNodeKind kind, PropertyName* label, const TokenPos& pos)
: ParseNode(kind, JSOP_NOP, PN_NULLARY, pos) : ParseNode(kind, JSOP_NOP, PN_LOOP, pos)
{ {
MOZ_ASSERT(kind == PNK_BREAK || kind == PNK_CONTINUE); MOZ_ASSERT(kind == PNK_BREAK || kind == PNK_CONTINUE);
pn_u.loopControl.label = label; pn_u.loopControl.label = label;
@ -1599,9 +1614,13 @@ class LoopControlStatement : public ParseNode
return pn_u.loopControl.label; return pn_u.loopControl.label;
} }
#ifdef DEBUG
void dump(int indent);
#endif
static bool test(const ParseNode& node) { static bool test(const ParseNode& node) {
bool match = node.isKind(PNK_BREAK) || node.isKind(PNK_CONTINUE); bool match = node.isKind(PNK_BREAK) || node.isKind(PNK_CONTINUE);
MOZ_ASSERT_IF(match, node.isArity(PN_NULLARY)); MOZ_ASSERT_IF(match, node.isArity(PN_LOOP));
MOZ_ASSERT_IF(match, node.isOp(JSOP_NOP)); MOZ_ASSERT_IF(match, node.isOp(JSOP_NOP));
return match; return match;
} }
@ -1616,7 +1635,7 @@ class BreakStatement : public LoopControlStatement
static bool test(const ParseNode& node) { static bool test(const ParseNode& node) {
bool match = node.isKind(PNK_BREAK); bool match = node.isKind(PNK_BREAK);
MOZ_ASSERT_IF(match, node.isArity(PN_NULLARY)); MOZ_ASSERT_IF(match, node.is<LoopControlStatement>());
MOZ_ASSERT_IF(match, node.isOp(JSOP_NOP)); MOZ_ASSERT_IF(match, node.isOp(JSOP_NOP));
return match; return match;
} }
@ -1631,18 +1650,24 @@ class ContinueStatement : public LoopControlStatement
static bool test(const ParseNode& node) { static bool test(const ParseNode& node) {
bool match = node.isKind(PNK_CONTINUE); bool match = node.isKind(PNK_CONTINUE);
MOZ_ASSERT_IF(match, node.isArity(PN_NULLARY)); MOZ_ASSERT_IF(match, node.is<LoopControlStatement>());
MOZ_ASSERT_IF(match, node.isOp(JSOP_NOP)); MOZ_ASSERT_IF(match, node.isOp(JSOP_NOP));
return match; return match;
} }
}; };
class DebuggerStatement : public ParseNode class DebuggerStatement : public NullaryNode
{ {
public: public:
explicit DebuggerStatement(const TokenPos& pos) explicit DebuggerStatement(const TokenPos& pos)
: ParseNode(PNK_DEBUGGER, JSOP_NOP, PN_NULLARY, pos) : NullaryNode(PNK_DEBUGGER, JSOP_NOP, pos)
{ } { }
static bool test(const ParseNode& node) {
bool match = node.isKind(PNK_DEBUGGER);
MOZ_ASSERT_IF(match, node.is<NullaryNode>());
return match;
}
}; };
class ConditionalExpression : public TernaryNode class ConditionalExpression : public TernaryNode
@ -1697,6 +1722,12 @@ class NullLiteral : public NullaryNode
explicit NullLiteral(const TokenPos& pos) explicit NullLiteral(const TokenPos& pos)
: NullaryNode(PNK_NULL, JSOP_NULL, pos) : NullaryNode(PNK_NULL, JSOP_NULL, pos)
{ } { }
static bool test(const ParseNode& node) {
bool match = node.isKind(PNK_NULL);
MOZ_ASSERT_IF(match, node.is<NullaryNode>());
return match;
}
}; };
// This is only used internally, currently just for tagged templates. // This is only used internally, currently just for tagged templates.
@ -1707,6 +1738,12 @@ class RawUndefinedLiteral : public NullaryNode
public: public:
explicit RawUndefinedLiteral(const TokenPos& pos) explicit RawUndefinedLiteral(const TokenPos& pos)
: NullaryNode(PNK_RAW_UNDEFINED, JSOP_UNDEFINED, pos) { } : NullaryNode(PNK_RAW_UNDEFINED, JSOP_UNDEFINED, pos) { }
static bool test(const ParseNode& node) {
bool match = node.isKind(PNK_RAW_UNDEFINED);
MOZ_ASSERT_IF(match, node.is<NullaryNode>());
return match;
}
}; };
class BooleanLiteral : public NullaryNode class BooleanLiteral : public NullaryNode
@ -1715,6 +1752,12 @@ class BooleanLiteral : public NullaryNode
BooleanLiteral(bool b, const TokenPos& pos) BooleanLiteral(bool b, const TokenPos& pos)
: NullaryNode(b ? PNK_TRUE : PNK_FALSE, b ? JSOP_TRUE : JSOP_FALSE, pos) : NullaryNode(b ? PNK_TRUE : PNK_FALSE, b ? JSOP_TRUE : JSOP_FALSE, pos)
{ } { }
static bool test(const ParseNode& node) {
bool match = node.isKind(PNK_TRUE) || node.isKind(PNK_FALSE);
MOZ_ASSERT_IF(match, node.is<NullaryNode>());
return match;
}
}; };
class RegExpLiteral : public ParseNode class RegExpLiteral : public ParseNode

View file

@ -5469,7 +5469,7 @@ Parser<ParseHandler>::exportBatch(uint32_t begin)
// Handle the form |export *| by adding a special export batch // Handle the form |export *| by adding a special export batch
// specifier to the list. // specifier to the list.
Node exportSpec = handler.newNullary(PNK_EXPORT_BATCH_SPEC, JSOP_NOP, pos()); NullaryNodeType exportSpec = handler.newNullary(PNK_EXPORT_BATCH_SPEC, JSOP_NOP, pos());
if (!exportSpec) if (!exportSpec)
return null(); return null();
@ -6542,7 +6542,7 @@ Parser<ParseHandler>::switchStatement(YieldHandling yieldHandling)
} }
template <typename ParseHandler> template <typename ParseHandler>
typename ParseHandler::Node typename ParseHandler::ContinueStatementType
Parser<ParseHandler>::continueStatement(YieldHandling yieldHandling) Parser<ParseHandler>::continueStatement(YieldHandling yieldHandling)
{ {
MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_CONTINUE)); MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_CONTINUE));
@ -6600,7 +6600,7 @@ Parser<ParseHandler>::continueStatement(YieldHandling yieldHandling)
} }
template <typename ParseHandler> template <typename ParseHandler>
typename ParseHandler::Node typename ParseHandler::BreakStatementType
Parser<ParseHandler>::breakStatement(YieldHandling yieldHandling) Parser<ParseHandler>::breakStatement(YieldHandling yieldHandling)
{ {
MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_BREAK)); MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_BREAK));
@ -7192,7 +7192,7 @@ Parser<ParseHandler>::catchBlockStatement(YieldHandling yieldHandling,
} }
template <typename ParseHandler> template <typename ParseHandler>
typename ParseHandler::Node typename ParseHandler::DebuggerStatementType
Parser<ParseHandler>::debuggerStatement() Parser<ParseHandler>::debuggerStatement()
{ {
TokenPos p; TokenPos p;
@ -10378,7 +10378,7 @@ Parser<ParseHandler>::tryNewTarget(BinaryNodeType* newTarget)
*newTarget = null(); *newTarget = null();
Node newHolder = handler.newPosHolder(pos()); NullaryNodeType newHolder = handler.newPosHolder(pos());
if (!newHolder) if (!newHolder)
return false; return false;
@ -10406,7 +10406,7 @@ Parser<ParseHandler>::tryNewTarget(BinaryNodeType* newTarget)
return false; return false;
} }
Node targetHolder = handler.newPosHolder(pos()); NullaryNodeType targetHolder = handler.newPosHolder(pos());
if (!targetHolder) if (!targetHolder)
return false; return false;

View file

@ -1211,14 +1211,14 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
Node expressionAfterForInOrOf(ParseNodeKind forHeadKind, YieldHandling yieldHandling); Node expressionAfterForInOrOf(ParseNodeKind forHeadKind, YieldHandling yieldHandling);
SwitchStatementType switchStatement(YieldHandling yieldHandling); SwitchStatementType switchStatement(YieldHandling yieldHandling);
Node continueStatement(YieldHandling yieldHandling); ContinueStatementType continueStatement(YieldHandling yieldHandling);
Node breakStatement(YieldHandling yieldHandling); BreakStatementType breakStatement(YieldHandling yieldHandling);
UnaryNodeType returnStatement(YieldHandling yieldHandling); UnaryNodeType returnStatement(YieldHandling yieldHandling);
BinaryNodeType withStatement(YieldHandling yieldHandling); BinaryNodeType withStatement(YieldHandling yieldHandling);
UnaryNodeType throwStatement(YieldHandling yieldHandling); UnaryNodeType throwStatement(YieldHandling yieldHandling);
TernaryNodeType tryStatement(YieldHandling yieldHandling); TernaryNodeType tryStatement(YieldHandling yieldHandling);
Node catchBlockStatement(YieldHandling yieldHandling, ParseContext::Scope& catchParamScope); Node catchBlockStatement(YieldHandling yieldHandling, ParseContext::Scope& catchParamScope);
Node debuggerStatement(); DebuggerStatementType debuggerStatement();
Node variableStatement(YieldHandling yieldHandling); Node variableStatement(YieldHandling yieldHandling);

View file

@ -224,7 +224,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
} }
NumericLiteralType newNumber(double value, DecimalPoint decimalPoint, const TokenPos& pos) { return NodeGeneric; } NumericLiteralType newNumber(double value, DecimalPoint decimalPoint, const TokenPos& pos) { return NodeGeneric; }
Node newBooleanLiteral(bool cond, const TokenPos& pos) { return NodeGeneric; } BooleanLiteralType newBooleanLiteral(bool cond, const TokenPos& pos) { return NodeGeneric; }
NameNodeType newStringLiteral(JSAtom* atom, const TokenPos& pos) { NameNodeType newStringLiteral(JSAtom* atom, const TokenPos& pos) {
lastAtom = atom; lastAtom = atom;
@ -243,8 +243,8 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
void addToCallSiteObject(CallSiteNodeType callSiteObj, Node rawNode, Node cookedNode) {} void addToCallSiteObject(CallSiteNodeType callSiteObj, Node rawNode, Node cookedNode) {}
UnaryNodeType newThisLiteral(const TokenPos& pos, Node thisName) { return NodeGeneric; } UnaryNodeType newThisLiteral(const TokenPos& pos, Node thisName) { return NodeGeneric; }
Node newNullLiteral(const TokenPos& pos) { return NodeGeneric; } NullLiteralType newNullLiteral(const TokenPos& pos) { return NodeGeneric; }
Node newRawUndefinedLiteral(const TokenPos& pos) { return NodeGeneric; } RawUndefinedLiteralType newRawUndefinedLiteral(const TokenPos& pos) { return NodeGeneric; }
template <class Boxer> template <class Boxer>
RegExpLiteralType newRegExp(RegExpObject* reobj, const TokenPos& pos, Boxer& boxer) { return NodeGeneric; } RegExpLiteralType newRegExp(RegExpObject* reobj, const TokenPos& pos, Boxer& boxer) { return NodeGeneric; }
@ -263,7 +263,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return NodeUnparenthesizedUnary; return NodeUnparenthesizedUnary;
} }
Node newNullary(ParseNodeKind kind, JSOp op, const TokenPos& pos) { NullaryNodeType newNullary(ParseNodeKind kind, JSOp op, const TokenPos& pos) {
return NodeGeneric; return NodeGeneric;
} }
@ -316,8 +316,10 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
ClassNamesType newClassNames(Node outer, Node inner, const TokenPos& pos) { return NodeGeneric; } ClassNamesType newClassNames(Node outer, Node inner, const TokenPos& pos) { return NodeGeneric; }
ClassNodeType newClass(Node name, Node heritage, Node methodBlock, const TokenPos& pos) { return NodeGeneric; } ClassNodeType newClass(Node name, Node heritage, Node methodBlock, const TokenPos& pos) { return NodeGeneric; }
BinaryNodeType newNewTarget(Node newHolder, Node targetHolder) { return NodeGeneric; } BinaryNodeType newNewTarget(NullaryNodeType newHolder, NullaryNodeType targetHolder) {
Node newPosHolder(const TokenPos& pos) { return NodeGeneric; } return NodeGeneric;
}
NullaryNodeType newPosHolder(const TokenPos& pos) { return NodeGeneric; }
UnaryNodeType newSuperBase(Node thisName, const TokenPos& pos) { return NodeSuperBase; } UnaryNodeType newSuperBase(Node thisName, const TokenPos& pos) { return NodeSuperBase; }
MOZ_MUST_USE bool addPrototypeMutation(ListNodeType literal, uint32_t begin, Node expr) { return true; } MOZ_MUST_USE bool addPrototypeMutation(ListNodeType literal, uint32_t begin, Node expr) { return true; }
@ -337,7 +339,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
void addStatementToList(ListNodeType list, Node stmt) {} void addStatementToList(ListNodeType list, Node stmt) {}
void addCaseStatementToList(ListNodeType list, CaseClauseType caseClause) {} void addCaseStatementToList(ListNodeType list, CaseClauseType caseClause) {}
MOZ_MUST_USE bool prependInitialYield(ListNodeType stmtList, Node genName) { return true; } MOZ_MUST_USE bool prependInitialYield(ListNodeType stmtList, Node genName) { return true; }
Node newEmptyStatement(const TokenPos& pos) { return NodeEmptyStatement; } UnaryNodeType newEmptyStatement(const TokenPos& pos) { return NodeEmptyStatement; }
UnaryNodeType newExportDeclaration(Node kid, const TokenPos& pos) { UnaryNodeType newExportDeclaration(Node kid, const TokenPos& pos) {
return NodeGeneric; return NodeGeneric;
@ -365,8 +367,8 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return NodeGeneric; return NodeGeneric;
} }
CaseClauseType newCaseOrDefault(uint32_t begin, Node expr, Node body) { return NodeGeneric; } CaseClauseType newCaseOrDefault(uint32_t begin, Node expr, Node body) { return NodeGeneric; }
Node newContinueStatement(PropertyName* label, const TokenPos& pos) { return NodeGeneric; } ContinueStatementType newContinueStatement(PropertyName* label, const TokenPos& pos) { return NodeGeneric; }
Node newBreakStatement(PropertyName* label, const TokenPos& pos) { return NodeBreak; } BreakStatementType newBreakStatement(PropertyName* label, const TokenPos& pos) { return NodeBreak; }
UnaryNodeType newReturnStatement(Node expr, const TokenPos& pos) { return NodeReturn; } UnaryNodeType newReturnStatement(Node expr, const TokenPos& pos) { return NodeReturn; }
BinaryNodeType newWithStatement(uint32_t begin, Node expr, Node body) { return NodeGeneric; } BinaryNodeType newWithStatement(uint32_t begin, Node expr, Node body) { return NodeGeneric; }
@ -378,7 +380,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
Node newTryStatement(uint32_t begin, Node body, ListNodeType catchList, Node finallyBlock) { Node newTryStatement(uint32_t begin, Node body, ListNodeType catchList, Node finallyBlock) {
return NodeGeneric; return NodeGeneric;
} }
Node newDebuggerStatement(const TokenPos& pos) { return NodeGeneric; } DebuggerStatementType newDebuggerStatement(const TokenPos& pos) { return NodeGeneric; }
NameNodeType newPropertyName(PropertyName* name, const TokenPos& pos) { NameNodeType newPropertyName(PropertyName* name, const TokenPos& pos) {
lastAtom = name; lastAtom = name;

View file

@ -598,7 +598,6 @@ static inline PropertyName*
LoopControlMaybeLabel(ParseNode* pn) LoopControlMaybeLabel(ParseNode* pn)
{ {
MOZ_ASSERT(pn->isKind(PNK_BREAK) || pn->isKind(PNK_CONTINUE)); MOZ_ASSERT(pn->isKind(PNK_BREAK) || pn->isKind(PNK_CONTINUE));
MOZ_ASSERT(pn->isArity(PN_NULLARY));
return pn->as<LoopControlStatement>().label(); return pn->as<LoopControlStatement>().label();
} }