From 49a807da2dffd6a8a39090676bb69c30e5e3fdf3 Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Sun, 28 Nov 1999 09:46:33 +0000 Subject: [PATCH] Fix decompiler to search function clone prototypes for args and vars (20160, r=rginda@netscape.com). git-svn-id: svn://10.0.0.236/trunk@54531 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/jsopcode.c | 42 ++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/mozilla/js/src/jsopcode.c b/mozilla/js/src/jsopcode.c index 6e56083c0f6..f9934073613 100644 --- a/mozilla/js/src/jsopcode.c +++ b/mozilla/js/src/jsopcode.c @@ -745,17 +745,27 @@ DecompileSwitch(SprintStack *ss, TableEntry *table, uintN tableLength, #endif static JSAtom * -GetSlotAtom(JSScope *scope, JSPropertyOp getter, uintN slot) +GetSlotAtom(JSPrinter *jp, JSPropertyOp getter, uintN slot) { + JSScope *scope; JSScopeProperty *sprop; + JSObject *obj, *proto; - if (!scope) - return NULL; - for (sprop = scope->props; sprop; sprop = sprop->next) { - if (SPROP_GETTER_SCOPE(sprop, scope) != getter) - continue; - if ((uintN)JSVAL_TO_INT(sprop->id) == slot) - return sym_atom(sprop->symbols); + scope = jp->scope; + while (scope) { + for (sprop = scope->props; sprop; sprop = sprop->next) { + if (SPROP_GETTER_SCOPE(sprop, scope) != getter) + continue; + if ((uintN)JSVAL_TO_INT(sprop->id) == slot) + return sym_atom(sprop->symbols); + } + obj = scope->object; + if (!obj) + break; + proto = OBJ_GET_PROTO(jp->sprinter.context, obj); + if (!proto) + break; + scope = OBJ_SCOPE(proto); } return NULL; } @@ -1398,12 +1408,12 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb) break; case JSOP_SETARG: - atom = GetSlotAtom(jp->scope, js_GetArgument, GET_ARGNO(pc)); + atom = GetSlotAtom(jp, js_GetArgument, GET_ARGNO(pc)); LOCAL_ASSERT(atom); goto do_setname; case JSOP_SETVAR: - atom = GetSlotAtom(jp->scope, js_GetLocalVariable, GET_VARNO(pc)); + atom = GetSlotAtom(jp, js_GetLocalVariable, GET_VARNO(pc)); LOCAL_ASSERT(atom); goto do_setname; @@ -1514,13 +1524,13 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb) case JSOP_INCARG: case JSOP_DECARG: - atom = GetSlotAtom(jp->scope, js_GetArgument, GET_ARGNO(pc)); + atom = GetSlotAtom(jp, js_GetArgument, GET_ARGNO(pc)); LOCAL_ASSERT(atom); goto do_incatom; case JSOP_INCVAR: case JSOP_DECVAR: - atom = GetSlotAtom(jp->scope, js_GetLocalVariable, GET_VARNO(pc)); + atom = GetSlotAtom(jp, js_GetLocalVariable, GET_VARNO(pc)); LOCAL_ASSERT(atom); goto do_incatom; @@ -1553,13 +1563,13 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb) case JSOP_ARGINC: case JSOP_ARGDEC: - atom = GetSlotAtom(jp->scope, js_GetArgument, GET_ARGNO(pc)); + atom = GetSlotAtom(jp, js_GetArgument, GET_ARGNO(pc)); LOCAL_ASSERT(atom); goto do_atominc; case JSOP_VARINC: case JSOP_VARDEC: - atom = GetSlotAtom(jp->scope, js_GetLocalVariable, GET_VARNO(pc)); + atom = GetSlotAtom(jp, js_GetLocalVariable, GET_VARNO(pc)); LOCAL_ASSERT(atom); goto do_atominc; @@ -1647,12 +1657,12 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb) break; case JSOP_GETARG: - atom = GetSlotAtom(jp->scope, js_GetArgument, GET_ARGNO(pc)); + atom = GetSlotAtom(jp, js_GetArgument, GET_ARGNO(pc)); LOCAL_ASSERT(atom); goto do_name; case JSOP_GETVAR: - atom = GetSlotAtom(jp->scope, js_GetLocalVariable, GET_VARNO(pc)); + atom = GetSlotAtom(jp, js_GetLocalVariable, GET_VARNO(pc)); LOCAL_ASSERT(atom); goto do_name;