|
Expand Up
|
@@ -13064,6 +13064,10 @@ const createNodePrinter = (modules) => { |
|
|
// By loop, the labeled statement it is the body of. |
|
|
/** @type {Map<number, number>} */ |
|
|
const labeledParents = new Map(); |
|
|
// By `switch`, the outermost of the labels it is the body of, where a block |
|
|
// or the program lists that label, or an `if` with no `else` runs it. |
|
|
/** @type {Map<number, number>} */ |
|
|
const switchLabels = new Map(); |
|
|
/** @type {Uint8Array} */ |
|
|
let mergedExits = new Uint8Array(0); |
|
|
// By parameter of such a function, the name passed for it, read instead. |
|
Expand Down
Expand Up
|
@@ -21539,6 +21543,22 @@ const createNodePrinter = (modules) => { |
|
|
) { |
|
|
labeledParents.set(A.field(0, Field.body, node), node); |
|
|
} |
|
|
if ( |
|
|
type === NodeType.LabeledStatement && |
|
|
(typeOf(parent) === NodeType.BlockStatement || |
|
|
typeOf(parent) === NodeType.Program || |
|
|
(typeOf(parent) === NodeType.IfStatement && |
|
|
A.field(0, Field.alternate, parent) === 0 && |
|
|
A.field(0, Field.consequent, parent) === node)) |
|
|
) { |
|
|
let body = A.field(0, Field.body, node); |
|
|
while (typeOf(body) === NodeType.LabeledStatement) { |
|
|
body = A.field(0, Field.body, body); |
|
|
} |
|
|
if (typeOf(body) === NodeType.SwitchStatement) { |
|
|
switchLabels.set(body, node); |
|
|
} |
|
|
} |
|
|
} |
|
|
// A `for`'s own declarator nothing reads goes from the head where its |
|
|
// value runs nothing: no statement there could keep what it runs. |
|
Expand Down
Expand Up
|
@@ -30139,12 +30159,16 @@ const createNodePrinter = (modules) => { |
|
|
noteFoldedSwitch(statement, parent); |
|
|
if (!foldedSwitches.has(statement)) noteSureMatch(statement); |
|
|
if (dropsDeadCode) dropAfterFoldedSwitch(statement, parent); |
|
|
// One with no case left that tests what runs nothing goes from its list. |
|
|
// An `if` with no `else` prints its test alone for a body printing nothing. |
|
|
// One with no case left that tests what runs nothing goes from its list, |
|
|
// its label too. An `if` with no `else` prints its test alone for a body |
|
|
// printing nothing. |
|
|
const label = |
|
|
switchLabels.size === 0 ? 0 : switchLabels.get(statement) || 0; |
|
|
if ( |
|
|
dropsDeadCode && |
|
|
(typeOf(parent) === NodeType.BlockStatement || |
|
|
typeOf(parent) === NodeType.Program || |
|
|
(label !== 0 && !holdsComments(label)) || |
|
|
(typeOf(parent) === NodeType.IfStatement && |
|
|
A.field(0, Field.alternate, parent) === 0)) && |
|
|
!foldedSwitches.has(statement) && |
|
Expand All
|
@@ -30153,8 +30177,9 @@ const createNodePrinter = (modules) => { |
|
|
) { |
|
|
if (printedCases(statement) === 0) { |
|
|
dropped[statement] = 1; |
|
|
if (label !== 0) dropped[label] = 1; |
|
|
findNode(statement, discountRead); |
|
|
} else { |
|
|
} else if (label === 0) { |
|
|
// A case may print nothing once what its statements declare goes. |
|
|
idleSwitches.push(statement); |
|
|
} |
|
Expand Down
Expand Up
|
@@ -30380,6 +30405,7 @@ const createNodePrinter = (modules) => { |
|
|
} |
|
|
tailHolders.length = 0; |
|
|
labeledParents.clear(); |
|
|
switchLabels.clear(); |
|
|
for (const statement of listIfs) { |
|
|
const test = childOf(Field.test, statement); |
|
|
if ( |
|
Expand Down
Expand Up
|
@@ -42263,12 +42289,14 @@ const createNodePrinter = (modules) => { |
|
|
// No `break` or `continue` names it. |
|
|
skipNode(A.field(0, Field.label, node)); |
|
|
if ( |
|
|
dropsSideEffectFree && |
|
|
typeOf(body) === NodeType.ExpressionStatement && |
|
|
!holdsComments(body) && |
|
|
isPureValue(childOf(Field.expression, body)) |
|
|
dropped[body] === 1 || |
|
|
(dropsSideEffectFree && |
|
|
typeOf(body) === NodeType.ExpressionStatement && |
|
|
!holdsComments(body) && |
|
|
isPureValue(childOf(Field.expression, body))) |
|
|
) { |
|
|
// A value running nothing goes, a statement left where a list holds none. |
|
|
// A value running nothing goes, as does a body that goes, a statement |
|
|
// left where a list holds none. |
|
|
skipNode(body); |
|
|
const parentType = typeOf(parentAt(0)); |
|
|
if ( |
|
Expand Down
|
|