зеркало из https://github.com/mozilla/gecko-dev.git
Fix PNX_NEEDBRACES setting logic to detect only function statement directly contained in a block (352281, r=mrbkap).
This commit is contained in:
Родитель
9b155b9f09
Коммит
4c7e90689f
|
@ -159,7 +159,7 @@ struct JSTreeContext { /* tree context for semantic checks */
|
|||
#define TCF_FUN_IS_GENERATOR 0x100 /* parsed yield statement in function */
|
||||
#define TCF_FUN_FLAGS 0x1E0 /* flags to propagate from FunctionBody */
|
||||
#define TCF_HAS_DEFXMLNS 0x200 /* default xml namespace = ...; parsed */
|
||||
#define TCF_HAS_CLOSURE 0x400 /* function statement was parsed */
|
||||
#define TCF_HAS_FUNCTION_STMT 0x400 /* block contains a function statement */
|
||||
|
||||
#define TREE_CONTEXT_INIT(tc) \
|
||||
((tc)->flags = (tc)->numGlobalVars = 0, \
|
||||
|
|
|
@ -1388,7 +1388,6 @@ FunctionDef(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
|||
* sub-statement.
|
||||
*/
|
||||
op = JSOP_CLOSURE;
|
||||
tc->flags |= TCF_HAS_CLOSURE;
|
||||
} else {
|
||||
op = JSOP_NOP;
|
||||
}
|
||||
|
@ -1445,6 +1444,10 @@ Statements(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||
}
|
||||
ts->flags |= TSF_OPERAND;
|
||||
|
||||
/* Detect a function statement for the TOK_LC case in Statement. */
|
||||
if (pn2->pn_type == TOK_FUNCTION && !AT_TOP_LEVEL(tc))
|
||||
tc->flags |= TCF_HAS_FUNCTION_STMT;
|
||||
|
||||
/* If compiling top-level statements, emit as we go to save space. */
|
||||
if (!tc->topStmt && (tc->flags & TCF_COMPILING)) {
|
||||
if (cx->fp->fun &&
|
||||
|
@ -3388,7 +3391,7 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||
uintN oldflags;
|
||||
|
||||
oldflags = tc->flags;
|
||||
tc->flags = oldflags & ~TCF_HAS_CLOSURE;
|
||||
tc->flags = oldflags & ~TCF_HAS_FUNCTION_STMT;
|
||||
js_PushStatement(tc, &stmtInfo, STMT_BLOCK, -1);
|
||||
pn = Statements(cx, ts, tc);
|
||||
if (!pn)
|
||||
|
@ -3401,7 +3404,7 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
|||
* If we contain a function statement and our container is top-level
|
||||
* or another block, flag pn to preserve braces when decompiling.
|
||||
*/
|
||||
if ((tc->flags & TCF_HAS_CLOSURE) &&
|
||||
if ((tc->flags & TCF_HAS_FUNCTION_STMT) &&
|
||||
(!tc->topStmt || tc->topStmt->type == STMT_BLOCK)) {
|
||||
pn->pn_extra |= PNX_NEEDBRACES;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче