Bug 710932 - Create true/false/this/null parse nodes with a constructor that doesn't examine the token stream. r=jorendorff

--HG--
extra : rebase_source : 29dc590794dd36409a5a171f8043aad1546b7b9a
This commit is contained in:
Jeff Walden 2011-12-14 20:03:35 -05:00
parent 5aa792830d
commit c1446d6b7f
2 changed files with 21 additions and 14 deletions

View File

@ -1198,6 +1198,23 @@ ParseNode::asUseSharpExpression()
return *static_cast<UseSharpExpression *>(this);
}
class ThisLiteral : public ParseNode {
public:
ThisLiteral(const TokenPos &pos) : ParseNode(PNK_THIS, JSOP_THIS, PN_NULLARY, pos) { }
};
class NullLiteral : public ParseNode {
public:
NullLiteral(const TokenPos &pos) : ParseNode(PNK_NULL, JSOP_NULL, PN_NULLARY, pos) { }
};
class BooleanLiteral : public ParseNode {
public:
BooleanLiteral(bool b, const TokenPos &pos)
: ParseNode(b ? PNK_TRUE : PNK_FALSE, b ? JSOP_TRUE : JSOP_FALSE, PN_NULLARY, pos)
{ }
};
ParseNode *
CloneLeftHandSide(ParseNode *opn, TreeContext *tc);

View File

@ -6565,16 +6565,6 @@ Parser::parseXMLText(JSObject *chain, bool allowList)
#endif /* JS_HAS_XMLSUPPORT */
static ParseNode *
PrimaryExprNode(ParseNodeKind kind, JSOp op, TreeContext *tc)
{
ParseNode *pn = NullaryNode::create(kind, tc);
if (!pn)
return NULL;
pn->setOp(op);
return pn;
}
ParseNode *
Parser::primaryExpr(TokenKind tt, JSBool afterDot)
{
@ -7217,13 +7207,13 @@ Parser::primaryExpr(TokenKind tt, JSBool afterDot)
break;
case TOK_TRUE:
return PrimaryExprNode(PNK_TRUE, JSOP_TRUE, tc);
return new_<BooleanLiteral>(true, tokenStream.currentToken().pos);
case TOK_FALSE:
return PrimaryExprNode(PNK_FALSE, JSOP_FALSE, tc);
return new_<BooleanLiteral>(false, tokenStream.currentToken().pos);
case TOK_THIS:
return PrimaryExprNode(PNK_THIS, JSOP_THIS, tc);
return new_<ThisLiteral>(tokenStream.currentToken().pos);
case TOK_NULL:
return PrimaryExprNode(PNK_NULL, JSOP_NULL, tc);
return new_<NullLiteral>(tokenStream.currentToken().pos);
case TOK_ERROR:
/* The scanner or one of its subroutines reported the error. */