Fixes left in wake of JSOP_POPN (379925, r=igor).

This commit is contained in:
brendan@mozilla.org 2007-05-08 12:04:13 -07:00
Родитель 76c488cada
Коммит f1fc1579b0
2 изменённых файлов: 14 добавлений и 18 удалений

Просмотреть файл

@ -3406,8 +3406,7 @@ static JSBool
EmitDestructuringOpsHelper(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn);
static JSBool
EmitDestructuringLHS(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
JSBool wantpop)
EmitDestructuringLHS(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
{
jsuint slot;
@ -3424,7 +3423,7 @@ EmitDestructuringLHS(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
if (pn->pn_type == TOK_RB || pn->pn_type == TOK_RC) {
if (!EmitDestructuringOpsHelper(cx, cg, pn))
return JS_FALSE;
if (wantpop && js_Emit1(cx, cg, JSOP_POP) < 0)
if (js_Emit1(cx, cg, JSOP_POP) < 0)
return JS_FALSE;
} else {
if (pn->pn_type == TOK_NAME &&
@ -3449,19 +3448,16 @@ EmitDestructuringLHS(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn,
break;
case JSOP_SETLOCAL:
if (wantpop) {
slot = (jsuint) pn->pn_slot;
EMIT_UINT16_IMM_OP(JSOP_SETLOCALPOP, slot);
break;
}
/* FALL THROUGH */
slot = (jsuint) pn->pn_slot;
EMIT_UINT16_IMM_OP(JSOP_SETLOCALPOP, slot);
break;
case JSOP_SETARG:
case JSOP_SETVAR:
case JSOP_SETGVAR:
slot = (jsuint) pn->pn_slot;
EMIT_UINT16_IMM_OP(pn->pn_op, slot);
if (wantpop && js_Emit1(cx, cg, JSOP_POP) < 0)
if (js_Emit1(cx, cg, JSOP_POP) < 0)
return JS_FALSE;
break;
@ -3576,7 +3572,7 @@ EmitDestructuringOpsHelper(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
if (js_Emit1(cx, cg, JSOP_POP) < 0)
return JS_FALSE;
} else {
if (!EmitDestructuringLHS(cx, cg, pn3, JS_TRUE))
if (!EmitDestructuringLHS(cx, cg, pn3))
return JS_FALSE;
}
@ -3664,7 +3660,7 @@ EmitGroupAssignment(JSContext *cx, JSCodeGenerator *cg, JSOp declOp,
if (js_Emit1(cx, cg, JSOP_POP) < 0)
return JS_FALSE;
} else {
if (!EmitDestructuringLHS(cx, cg, pn, pn->pn_next != NULL))
if (!EmitDestructuringLHS(cx, cg, pn))
return JS_FALSE;
}
++slot;

Просмотреть файл

@ -1285,7 +1285,7 @@ DecompileDestructuringLHS(SprintStack *ss, jsbytecode *pc, jsbytecode *endpc,
LOAD_OP_DATA(pc);
lval = PopStr(ss, JSOP_NOP);
todo = SprintCString(&ss->sprinter, lval);
if (op == JSOP_SETSP)
if (op == JSOP_POPN)
return pc;
LOCAL_ASSERT(*pc == JSOP_POP);
break;
@ -1294,7 +1294,7 @@ DecompileDestructuringLHS(SprintStack *ss, jsbytecode *pc, jsbytecode *endpc,
case JSOP_SETVAR:
case JSOP_SETGVAR:
case JSOP_SETLOCAL:
LOCAL_ASSERT(pc[oplen] == JSOP_POP || pc[oplen] == JSOP_SETSP);
LOCAL_ASSERT(pc[oplen] == JSOP_POP || pc[oplen] == JSOP_POPN);
/* FALL THROUGH */
case JSOP_SETLOCALPOP:
@ -1318,7 +1318,7 @@ DecompileDestructuringLHS(SprintStack *ss, jsbytecode *pc, jsbytecode *endpc,
if (pc == endpc)
return pc;
LOAD_OP_DATA(pc);
if (op == JSOP_SETSP)
if (op == JSOP_POPN)
return pc;
LOCAL_ASSERT(op == JSOP_POP);
}
@ -1555,12 +1555,12 @@ DecompileGroupAssignment(SprintStack *ss, jsbytecode *pc, jsbytecode *endpc,
if (SprintPut(&ss->sprinter, "] = [", 5) < 0)
return NULL;
start = GET_UINT16(pc);
end = ss->top - 1;
start = end - GET_UINT16(pc);
for (i = start; i < end; i++) {
rval = GetStr(ss, i);
if (Sprint(&ss->sprinter, "%s%s",
(i == start) ? "" : ", ",
if (Sprint(&ss->sprinter,
(i == start) ? "%s" : ", %s",
(i == end - 1 && *rval == '\0') ? ", " : rval) < 0) {
return NULL;
}