Now that SRC_COMMA has been renamed to reflect its generality (SRC_PCDELTA),

and more important, to save a byte of useless note offset, use SRC_CONTINUE
instead of SRC_PCDELTA to annotate JSOP_ENDINIT when there's an extra comma
at the end of an array literal (e.g. [1,2,,]).
This commit is contained in:
brendan%netscape.com 1998-09-09 19:18:01 +00:00
parent cf7a9de30f
commit 9b12b81ef6
3 changed files with 5 additions and 3 deletions

View File

@ -2016,7 +2016,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
if (pn->pn_extra) {
/* Emit a source note so we know to decompile an extra comma. */
if (js_NewSrcNote(cx, cg, SRC_PCDELTA) < 0)
if (js_NewSrcNote(cx, cg, SRC_CONTINUE) < 0)
return JS_FALSE;
}

View File

@ -229,7 +229,9 @@ typedef enum JSSrcNoteType {
SRC_IF_ELSE = 2, /* JSOP_IFEQ bytecode is from an if-then-else */
SRC_WHILE = 3, /* JSOP_IFEQ is from a while loop */
SRC_FOR = 4, /* JSOP_NOP or JSOP_POP in for loop head */
SRC_CONTINUE = 5, /* JSOP_GOTO is a continue, not a break */
SRC_CONTINUE = 5, /* JSOP_GOTO is a continue, not a break;
also used on JSOP_ENDINIT if extra comma
at end of array literal: [1,2,,] */
SRC_VAR = 6, /* JSOP_NAME/FORNAME with a var declaration */
SRC_PCDELTA = 7, /* offset from comma-operator to next POP,
or from CONDSWITCH to first CASE opcode */

View File

@ -1860,7 +1860,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
sn = js_GetSrcNote(jp->script, pc);
todo = Sprint(&ss->sprinter, "%s%s%c",
rval,
(sn && SN_TYPE(sn) == SRC_PCDELTA) ? ", " : "",
(sn && SN_TYPE(sn) == SRC_CONTINUE) ? ", " : "",
/* [balance */
(*rval == '{') ? '}' : ']');
break;