Bug 470374 - Decompiler fixes from bug 469625 (r=jorendorff).

This commit is contained in:
Brendan Eich
2008-12-29 23:22:23 -08:00
parent 71e4f75b39
commit de6f33457c

View File

@@ -885,7 +885,7 @@ GetOff(SprintStack *ss, uintN i)
JS_ASSERT(off <= -2);
JS_ASSERT(ss->printer->pcstack);
if (off < -2 && ss->printer->pcstack) {
if (off <= -2 && ss->printer->pcstack) {
pc = ss->printer->pcstack[-2 - off];
bytes = DecompileExpression(ss->sprinter.context, ss->printer->script,
ss->printer->fun, pc);
@@ -1250,12 +1250,19 @@ GetLocal(SprintStack *ss, jsint i)
* We must be called from js_DecompileValueGenerator (via Decompile) when
* dereferencing a local that's undefined or null. Search script->objects
* for the block containing this local by its stack index, i.
*
* In case of destructuring's use of JSOP_GETLOCAL, however, there may be
* no such local. This could mean no blocks (no script objects at all, or
* none of the script's object literals are blocks), or the stack slot i is
* not in a block. In either case, return GetStr(ss, i).
*/
cx = ss->sprinter.context;
script = ss->printer->script;
LOCAL_ASSERT(script->objectsOffset != 0);
if (script->objectsOffset == 0)
return GetStr(ss, i);
for (j = 0, n = JS_SCRIPT_OBJECTS(script)->length; ; j++) {
LOCAL_ASSERT(j < n);
if (j == n)
return GetStr(ss, i);
JS_GET_SCRIPT_OBJECT(script, j, obj);
if (OBJ_GET_CLASS(cx, obj) == &js_BlockClass) {
depth = OBJ_BLOCK_DEPTH(cx, obj);
@@ -2793,7 +2800,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
sn = js_GetSrcNote(jp->script, pc);
#if JS_HAS_DESTRUCTURING
if (sn && SN_TYPE(sn) == SRC_GROUPASSIGN) {
if (sn && SN_TYPE(sn) == SRC_GROUPASSIGN && len > JSOP_GETLOCAL_LENGTH) {
pc = DecompileGroupAssignment(ss, pc, endpc, sn, &todo);
if (!pc)
return NULL;
@@ -5073,6 +5080,12 @@ DecompileExpression(JSContext *cx, JSScript *script, JSFunction *fun,
JS_ASSERT(op != JSOP_CASE && op != JSOP_CASEX &&
op != JSOP_DUP && op != JSOP_DUP2);
/* JSOP_PUSH is used to generate undefined for group assignment holes. */
if (op == JSOP_PUSH) {
name = JS_strdup(cx, js_undefined_str);
goto out;
}
/*
* |this| could convert to a very long object initialiser, so cite it by
* its keyword name instead.