зеркало из https://github.com/mozilla/pjs.git
Bug 624199: Move code for decompiling strict mode code directives to where it works for JS_DecompileScript, too. r=brendan
This commit is contained in:
Родитель
6f6ac0e2a0
Коммит
c042390177
|
@ -4843,6 +4843,20 @@ DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len,
|
|||
|
||||
AutoScriptUntrapper untrapper(cx, script, &pc);
|
||||
|
||||
/* Print a strict mode code directive, if needed. */
|
||||
if (script->strictModeCode && !jp->strict) {
|
||||
if (jp->fun && (jp->fun->flags & JSFUN_EXPR_CLOSURE)) {
|
||||
/*
|
||||
* We have no syntax for strict function expressions;
|
||||
* at least give a hint.
|
||||
*/
|
||||
js_printf(jp, "\t/* use strict */ \n");
|
||||
} else {
|
||||
js_printf(jp, "\t\"use strict\";\n");
|
||||
}
|
||||
jp->strict = true;
|
||||
}
|
||||
|
||||
/* Initialize a sprinter for use with the offset stack. */
|
||||
mark = JS_ARENA_MARK(&cx->tempPool);
|
||||
ok = InitSprintStack(cx, &ss, jp, depth);
|
||||
|
@ -5039,24 +5053,10 @@ js_DecompileFunction(JSPrinter *jp)
|
|||
#endif
|
||||
if (!ok)
|
||||
return JS_FALSE;
|
||||
if (fun->flags & JSFUN_EXPR_CLOSURE) {
|
||||
js_printf(jp, ") ");
|
||||
if (fun->u.i.script->strictModeCode && !jp->strict) {
|
||||
/*
|
||||
* We have no syntax for strict function expressions;
|
||||
* at least give a hint.
|
||||
*/
|
||||
js_printf(jp, "\t/* use strict */ \n");
|
||||
jp->strict = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
js_printf(jp, ") {\n");
|
||||
js_printf(jp, ") ");
|
||||
if (!(fun->flags & JSFUN_EXPR_CLOSURE)) {
|
||||
js_printf(jp, "{\n");
|
||||
jp->indent += 4;
|
||||
if (fun->u.i.script->strictModeCode && !jp->strict) {
|
||||
js_printf(jp, "\t'use strict';\n");
|
||||
jp->strict = true;
|
||||
}
|
||||
}
|
||||
|
||||
len = script->code + script->length - pc;
|
||||
|
|
Загрузка…
Ссылка в новой задаче