Don't add unnecessary quotes to the rhs of the descendant operator. bug 321547, r=brendan

This commit is contained in:
mrbkap%gmail.com 2006-03-23 05:36:20 +00:00
Родитель c61bd6af26
Коммит 9ee66b6f05
3 изменённых файлов: 11 добавлений и 3 удалений

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

@ -2262,6 +2262,11 @@ EmitElemOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg)
if (!js_EmitTree(cx, cg, left))
return JS_FALSE;
}
/* The right side of the descendant operator is implicitly quoted. */
if (op == JSOP_DESCENDANTS && right->pn_op == JSOP_STRING &&
js_NewSrcNote(cx, cg, SRC_UNQUOTE) < 0) {
return JS_FALSE;
}
if (!js_EmitTree(cx, cg, right))
return JS_FALSE;
if (js_NewSrcNote2(cx, cg, SRC_PCBASE, CG_OFFSET(cg) - top) < 0)
@ -4953,7 +4958,7 @@ JS_FRIEND_DATA(JSSrcNoteSpec) js_SrcNoteSpec[] = {
{"pcdelta", 1, 0, 1},
{"assignop", 0, 0, 0},
{"cond", 1, 0, 1},
{"reserved0", 0, 0, 0},
{"unquote", 0, 0, 0},
{"hidden", 0, 0, 0},
{"pcbase", 1, 0, -1},
{"label", 1, 0, 0},

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

@ -415,7 +415,7 @@ typedef enum JSSrcNoteType {
gets and sets */
SRC_ASSIGNOP = 8, /* += or another assign-op follows */
SRC_COND = 9, /* JSOP_IFEQ is from conditional ?: operator */
SRC_RESERVED0 = 10, /* reserved for future use */
SRC_UNQUOTE = 10, /* don't quote a JSOP_STRING */
SRC_HIDDEN = 11, /* opcode shouldn't be decompiled */
SRC_PCBASE = 12, /* distance back from annotated get- or setprop
op to first obj.prop.subprop bytecode */

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

@ -2128,8 +2128,11 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
END_LITOPX_CASE
BEGIN_LITOPX_CASE(JSOP_STRING)
sn = js_GetSrcNote(jp->script, pc);
rval = QuoteString(&ss->sprinter, ATOM_TO_STRING(atom),
(jschar)(inXML ? 0 : '"'));
(jschar)((inXML ||
(sn && SN_TYPE(sn) == SRC_UNQUOTE))
? 0 : '"'));
if (!rval)
return JS_FALSE;
todo = STR2OFF(&ss->sprinter, rval);