Fix catch decompilation, again (245308, r=shaver).

This commit is contained in:
brendan%mozilla.org 2004-08-29 18:00:24 +00:00
Родитель 200c699646
Коммит a1e9c15ad9
2 изменённых файлов: 15 добавлений и 13 удалений

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

@ -3448,8 +3448,9 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
* This counts as a non-local jump, so do the finally thing.
*/
/* popscope */
if (js_NewSrcNote(cx, cg, SRC_HIDDEN) < 0 ||
/* leavewith, annotated so the decompiler knows to pop */
off = cg->stackDepth - 1;
if (js_NewSrcNote2(cx, cg, SRC_CATCH, off) < 0 ||
js_Emit1(cx, cg, JSOP_LEAVEWITH) < 0) {
return JS_FALSE;
}
@ -4316,7 +4317,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
#endif
/* Annotate JSOP_INITELEM so we decompile 2:c and not just c. */
if (pn3->pn_type == TOK_NUMBER) {
if (js_NewSrcNote(cx, cg, SRC_LABEL) < 0)
if (js_NewSrcNote2(cx, cg, SRC_LABEL, 0) < 0)
return JS_FALSE;
if (js_Emit1(cx, cg, JSOP_INITELEM) < 0)
return JS_FALSE;

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

@ -853,6 +853,8 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
JSString *str;
JSBool ok;
jsval val;
static const char catch_cookie[] = "/*CATCH*/";
static const char with_cookie[] = "/*WITH*/";
/*
* Local macros
@ -1075,6 +1077,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
js_printf(jp, ") {\n");
jp->indent += 4;
todo = Sprint(&ss->sprinter, catch_cookie);
len = 0;
break;
@ -1130,7 +1133,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
break;
{
static const char finally_cookie[] = "finally-cookie";
static const char finally_cookie[] = "/*FINALLY*/";
case JSOP_FINALLY:
jp->indent -= 4;
@ -1177,6 +1180,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
* The decompiler must match the code generator's model, which
* is why JSOP_FINALLY pushes a cookie that JSOP_RETSUB pops.
*/
LOCAL_ASSERT(ss->top >= (uintN) GET_ATOM_INDEX(pc));
ss->top = (uintN) GET_ATOM_INDEX(pc);
break;
@ -1245,15 +1249,8 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
todo = -2;
break;
{
static const char with_cookie[] = "with-cookie";
case JSOP_ENTERWITH:
sn = js_GetSrcNote(jp->script, pc);
if (sn && SN_TYPE(sn) == SRC_HIDDEN) {
todo = -2;
break;
}
JS_ASSERT(!js_GetSrcNote(jp->script, pc));
rval = POP_STR();
js_printf(jp, "\twith (%s) {\n", rval);
jp->indent += 4;
@ -1266,11 +1263,15 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
if (sn && SN_TYPE(sn) == SRC_HIDDEN)
break;
rval = POP_STR();
if (sn && SN_TYPE(sn) == SRC_CATCH) {
LOCAL_ASSERT(strcmp(rval, catch_cookie) == 0);
LOCAL_ASSERT((uintN) js_GetSrcNoteOffset(sn, 0) == ss->top);
break;
}
LOCAL_ASSERT(strcmp(rval, with_cookie) == 0);
jp->indent -= 4;
js_printf(jp, "\t}\n");
break;
}
case JSOP_SETRVAL:
case JSOP_RETURN: