зеркало из https://github.com/mozilla/pjs.git
Don't add unnecessary quotes to the rhs of the descendant operator. bug 321547, r=brendan
This commit is contained in:
Родитель
c61bd6af26
Коммит
9ee66b6f05
|
@ -2262,6 +2262,11 @@ EmitElemOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg)
|
||||||
if (!js_EmitTree(cx, cg, left))
|
if (!js_EmitTree(cx, cg, left))
|
||||||
return JS_FALSE;
|
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))
|
if (!js_EmitTree(cx, cg, right))
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
if (js_NewSrcNote2(cx, cg, SRC_PCBASE, CG_OFFSET(cg) - top) < 0)
|
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},
|
{"pcdelta", 1, 0, 1},
|
||||||
{"assignop", 0, 0, 0},
|
{"assignop", 0, 0, 0},
|
||||||
{"cond", 1, 0, 1},
|
{"cond", 1, 0, 1},
|
||||||
{"reserved0", 0, 0, 0},
|
{"unquote", 0, 0, 0},
|
||||||
{"hidden", 0, 0, 0},
|
{"hidden", 0, 0, 0},
|
||||||
{"pcbase", 1, 0, -1},
|
{"pcbase", 1, 0, -1},
|
||||||
{"label", 1, 0, 0},
|
{"label", 1, 0, 0},
|
||||||
|
|
|
@ -415,7 +415,7 @@ typedef enum JSSrcNoteType {
|
||||||
gets and sets */
|
gets and sets */
|
||||||
SRC_ASSIGNOP = 8, /* += or another assign-op follows */
|
SRC_ASSIGNOP = 8, /* += or another assign-op follows */
|
||||||
SRC_COND = 9, /* JSOP_IFEQ is from conditional ?: operator */
|
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_HIDDEN = 11, /* opcode shouldn't be decompiled */
|
||||||
SRC_PCBASE = 12, /* distance back from annotated get- or setprop
|
SRC_PCBASE = 12, /* distance back from annotated get- or setprop
|
||||||
op to first obj.prop.subprop bytecode */
|
op to first obj.prop.subprop bytecode */
|
||||||
|
|
|
@ -2128,8 +2128,11 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
||||||
END_LITOPX_CASE
|
END_LITOPX_CASE
|
||||||
|
|
||||||
BEGIN_LITOPX_CASE(JSOP_STRING)
|
BEGIN_LITOPX_CASE(JSOP_STRING)
|
||||||
|
sn = js_GetSrcNote(jp->script, pc);
|
||||||
rval = QuoteString(&ss->sprinter, ATOM_TO_STRING(atom),
|
rval = QuoteString(&ss->sprinter, ATOM_TO_STRING(atom),
|
||||||
(jschar)(inXML ? 0 : '"'));
|
(jschar)((inXML ||
|
||||||
|
(sn && SN_TYPE(sn) == SRC_UNQUOTE))
|
||||||
|
? 0 : '"'));
|
||||||
if (!rval)
|
if (!rval)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
todo = STR2OFF(&ss->sprinter, rval);
|
todo = STR2OFF(&ss->sprinter, rval);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче