mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 713759 - Split PNK_INC and PNK_DEC into pre- and post- variants. r=bhackett
--HG-- extra : rebase_source : a429d9cc2d7095e06e54c48c3ae53e1c16076405
This commit is contained in:
parent
48182510d9
commit
b89737cc2d
@ -7334,8 +7334,10 @@ frontend::EmitTree(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
||||
ok = EmitUnary(cx, bce, pn);
|
||||
break;
|
||||
|
||||
case PNK_INC:
|
||||
case PNK_DEC:
|
||||
case PNK_PREINCREMENT:
|
||||
case PNK_PREDECREMENT:
|
||||
case PNK_POSTINCREMENT:
|
||||
case PNK_POSTDECREMENT:
|
||||
ok = EmitIncOrDec(cx, bce, pn);
|
||||
break;
|
||||
|
||||
|
@ -75,8 +75,10 @@ enum ParseNodeKind {
|
||||
PNK_STAR,
|
||||
PNK_DIV,
|
||||
PNK_MOD,
|
||||
PNK_INC,
|
||||
PNK_DEC,
|
||||
PNK_PREINCREMENT,
|
||||
PNK_POSTINCREMENT,
|
||||
PNK_PREDECREMENT,
|
||||
PNK_POSTDECREMENT,
|
||||
PNK_DOT,
|
||||
PNK_LB,
|
||||
PNK_RB,
|
||||
@ -347,8 +349,10 @@ enum ParseNodeKind {
|
||||
* PNK_VOID,
|
||||
* PNK_NOT,
|
||||
* PNK_BITNOT
|
||||
* PNK_INC, unary pn_kid: MEMBER expr
|
||||
* PNK_DEC
|
||||
* PNK_PREINCREMENT, unary pn_kid: MEMBER expr
|
||||
* PNK_POSTINCREMENT,
|
||||
* PNK_PREDECREMENT,
|
||||
* PNK_POSTDECREMENT
|
||||
* PNK_NEW list pn_head: list of ctor, arg1, arg2, ... argN
|
||||
* pn_count: 1 + N (where N is number of args)
|
||||
* ctor is a MEMBER expr
|
||||
|
@ -4780,7 +4780,7 @@ Parser::assignExpr()
|
||||
return ParseNode::newBinaryOrAppend(kind, op, lhs, rhs, tc);
|
||||
}
|
||||
|
||||
static ParseNode *
|
||||
static bool
|
||||
SetLvalKid(JSContext *cx, TokenStream *ts, TreeContext *tc, ParseNode *pn, ParseNode *kid,
|
||||
const char *name)
|
||||
{
|
||||
@ -4795,25 +4795,24 @@ SetLvalKid(JSContext *cx, TokenStream *ts, TreeContext *tc, ParseNode *pn, Parse
|
||||
!kid->isKind(PNK_LB))
|
||||
{
|
||||
ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR, JSMSG_BAD_OPERAND, name);
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
if (!CheckStrictAssignment(cx, tc, kid))
|
||||
return NULL;
|
||||
return false;
|
||||
pn->pn_kid = kid;
|
||||
return kid;
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char incop_name_str[][10] = {"increment", "decrement"};
|
||||
|
||||
static JSBool
|
||||
SetIncOpKid(JSContext *cx, TokenStream *ts, TreeContext *tc, ParseNode *pn, ParseNode *kid,
|
||||
TokenKind tt, JSBool preorder)
|
||||
TokenKind tt, bool preorder)
|
||||
{
|
||||
JSOp op;
|
||||
|
||||
kid = SetLvalKid(cx, ts, tc, pn, kid, incop_name_str[tt == TOK_DEC]);
|
||||
if (!kid)
|
||||
return JS_FALSE;
|
||||
if (!SetLvalKid(cx, ts, tc, pn, kid, incop_name_str[tt == TOK_DEC]))
|
||||
return false;
|
||||
switch (kid->getKind()) {
|
||||
case PNK_NAME:
|
||||
op = (tt == TOK_INC)
|
||||
@ -4885,13 +4884,13 @@ Parser::unaryExpr()
|
||||
|
||||
case TOK_INC:
|
||||
case TOK_DEC:
|
||||
pn = UnaryNode::create((tt == TOK_INC) ? PNK_INC : PNK_DEC, tc);
|
||||
pn = UnaryNode::create((tt == TOK_INC) ? PNK_PREINCREMENT : PNK_PREDECREMENT, tc);
|
||||
if (!pn)
|
||||
return NULL;
|
||||
pn2 = memberExpr(JS_TRUE);
|
||||
if (!pn2)
|
||||
return NULL;
|
||||
if (!SetIncOpKid(context, &tokenStream, tc, pn, pn2, tt, JS_TRUE))
|
||||
if (!SetIncOpKid(context, &tokenStream, tc, pn, pn2, tt, true))
|
||||
return NULL;
|
||||
pn->pn_pos.end = pn2->pn_pos.end;
|
||||
break;
|
||||
@ -4954,11 +4953,11 @@ Parser::unaryExpr()
|
||||
if (tokenStream.onCurrentLine(pn->pn_pos)) {
|
||||
tt = tokenStream.peekTokenSameLine(TSF_OPERAND);
|
||||
if (tt == TOK_INC || tt == TOK_DEC) {
|
||||
(void) tokenStream.getToken();
|
||||
pn2 = UnaryNode::create((tt == TOK_INC) ? PNK_INC : PNK_DEC, tc);
|
||||
tokenStream.consumeKnownToken(tt);
|
||||
pn2 = UnaryNode::create((tt == TOK_INC) ? PNK_POSTINCREMENT : PNK_POSTDECREMENT, tc);
|
||||
if (!pn2)
|
||||
return NULL;
|
||||
if (!SetIncOpKid(context, &tokenStream, tc, pn2, pn, tt, JS_FALSE))
|
||||
if (!SetIncOpKid(context, &tokenStream, tc, pn2, pn, tt, false))
|
||||
return NULL;
|
||||
pn2->pn_pos.begin = pn->pn_pos.begin;
|
||||
pn = pn2;
|
||||
|
@ -2432,15 +2432,22 @@ ASTSerializer::expression(ParseNode *pn, Value *dst)
|
||||
return leftAssociate(pn, dst);
|
||||
}
|
||||
|
||||
case PNK_INC:
|
||||
case PNK_DEC:
|
||||
case PNK_PREINCREMENT:
|
||||
case PNK_PREDECREMENT:
|
||||
{
|
||||
bool incr = pn->isKind(PNK_INC);
|
||||
bool prefix = pn->getOp() >= JSOP_INCNAME && pn->getOp() <= JSOP_DECELEM;
|
||||
|
||||
bool inc = pn->isKind(PNK_PREINCREMENT);
|
||||
Value expr;
|
||||
return expression(pn->pn_kid, &expr) &&
|
||||
builder.updateExpression(expr, incr, prefix, &pn->pn_pos, dst);
|
||||
builder.updateExpression(expr, inc, true, &pn->pn_pos, dst);
|
||||
}
|
||||
|
||||
case PNK_POSTINCREMENT:
|
||||
case PNK_POSTDECREMENT:
|
||||
{
|
||||
bool inc = pn->isKind(PNK_POSTINCREMENT);
|
||||
Value expr;
|
||||
return expression(pn->pn_kid, &expr) &&
|
||||
builder.updateExpression(expr, inc, false, &pn->pn_pos, dst);
|
||||
}
|
||||
|
||||
case PNK_ASSIGN:
|
||||
|
Loading…
Reference in New Issue
Block a user