From 19d94f3391e3ac5ffc26df27ac5e7a0609c042a7 Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Tue, 16 Nov 1999 02:15:22 +0000 Subject: [PATCH] Fix exception bytecodes to use script->main (18926, r=jband@netscape.com). --- js/src/js.c | 12 +++++++----- js/src/jsinterp.c | 13 +++++++------ js/src/jsopcode.c | 4 +++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/js/src/js.c b/js/src/js.c index 70b0c80ca8c4..bdd8710231de 100644 --- a/js/src/js.c +++ b/js/src/js.c @@ -772,7 +772,7 @@ LineToPC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) pc = JS_LineNumberToPC(cx, script, lineno); if (!pc) return JS_FALSE; - *rval = INT_TO_JSVAL(pc - script->code); + *rval = INT_TO_JSVAL(PTRDIFF(pc, script->code, jsbytecode)); return JS_TRUE; } @@ -811,7 +811,8 @@ SrcNotes(JSContext *cx, JSScript *script) delta = SN_DELTA(sn); offset += delta; fprintf(gOutFile, "%3u: %5u [%4u] %-8s", - sn - notes, offset, delta, js_SrcNoteName[SN_TYPE(sn)]); + PTRDIFF(sn, notes, jssrcnote), offset, delta, + js_SrcNoteName[SN_TYPE(sn)]); type = SN_TYPE(sn); switch (type) { case SRC_SETLINE: @@ -988,8 +989,9 @@ DisassWithSrc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval } } - len = js_Disassemble1(cx, script, pc, pc - script->code, - JS_TRUE, stdout); + len = js_Disassemble1(cx, script, pc, + PTRDIFF(pc, script->code, jsbytecode), + JS_TRUE, stdout); if (!len) return JS_FALSE; pc += len; @@ -1670,7 +1672,7 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report) report->linebuf, (n > 0 && report->linebuf[n-1] == '\n') ? "" : "\n", prefix); - n = report->tokenptr - report->linebuf; + n = PTRDIFF(report->tokenptr, report->linebuf, char); for (i = j = 0; i < n; i++) { if (report->linebuf[i] == '\t') { for (k = (j + 8) & ~7; j < k; j++) { diff --git a/js/src/jsinterp.c b/js/src/jsinterp.c index 42a4f2f9e0f0..dedd59e5b773 100644 --- a/js/src/jsinterp.c +++ b/js/src/jsinterp.c @@ -1106,8 +1106,9 @@ js_Interpret(JSContext *cx, jsval *result) intN nuses, n; fprintf(tracefp, "%4u: ", js_PCToLineNumber(script, pc)); - js_Disassemble1(cx, script, pc, pc - script->code, JS_FALSE, - tracefp); + js_Disassemble1(cx, script, pc, + PTRDIFF(pc, script->code, jsbytecode), JS_FALSE, + tracefp); nuses = cs->nuses; if (nuses) { fp->sp = sp - nuses; @@ -2853,7 +2854,7 @@ js_Interpret(JSContext *cx, jsval *result) case JSOP_GOSUB: len = GET_JUMP_OFFSET(pc); JS_ASSERT(js_CodeSpec[JSOP_GOSUB].length == 3); - i = pc - script->code + 3; + i = PTRDIFF(pc, script->main, jsbytecode) + 3; PUSH(INT_TO_JSVAL(i)); break; @@ -2861,7 +2862,7 @@ js_Interpret(JSContext *cx, jsval *result) rval = POP(); JS_ASSERT(JSVAL_IS_INT(rval)); i = JSVAL_TO_INT(rval); - pc = script->code + i; + pc = script->main + i; len = 0; break; @@ -3008,11 +3009,11 @@ out: */ tn = script->trynotes; if (tn) { - offset = PTRDIFF(pc, script->code, jsbytecode); + offset = PTRDIFF(pc, script->main, jsbytecode); while (JS_UPTRDIFF(offset, tn->start) >= (jsuword)tn->length) tn++; if (tn->catchStart) { - pc = script->code + tn->catchStart; + pc = script->main + tn->catchStart; len = 0; cx->throwing = JS_FALSE; /* caught */ ok = JS_TRUE; diff --git a/js/src/jsopcode.c b/js/src/jsopcode.c index 57d57b96fc86..3f244b74c22c 100644 --- a/js/src/jsopcode.c +++ b/js/src/jsopcode.c @@ -114,7 +114,9 @@ js_Disassemble(JSContext *cx, JSScript *script, JSBool lines, FILE *fp) while (pc < end) { if (pc == script->main) fputs("main:\n", fp); - len = js_Disassemble1(cx, script, pc, pc - script->code, lines, fp); + len = js_Disassemble1(cx, script, pc, + PTRDIFF(pc, script->code, jsbytecode), + lines, fp); if (!len) return; pc += len;