MCPcopy Index your code
hub / github.com/nodejs/node / appendLabel

Function appendLabel

test/fixtures/snapshot/typescript.js:104050–104087  ·  view source on GitHub ↗

* Appends a case clause for the last label and sets the new label. * * @param markLabelEnd Indicates that the transition between labels was a fall-through * from a previous case clause and the change in labels should be * re

(markLabelEnd)

Source from the content-addressed store, hash-verified

104048 * reflected on the `state` object.
104049 */
104050 function appendLabel(markLabelEnd) {
104051 if (!clauses) {
104052 clauses = [];
104053 }
104054 if (statements) {
104055 if (withBlockStack) {
104056 // The previous label was nested inside one or more `with` blocks, so we
104057 // surround the statements in generated `with` blocks to create the same environment.
104058 for (var i = withBlockStack.length - 1; i >= 0; i--) {
104059 var withBlock = withBlockStack[i];
104060 statements = [factory.createWithStatement(withBlock.expression, factory.createBlock(statements))];
104061 }
104062 }
104063 if (currentExceptionBlock) {
104064 // The previous label was nested inside of an exception block, so we must
104065 // indicate entry into a protected region by pushing the label numbers
104066 // for each block in the protected region.
104067 var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel;
104068 statements.unshift(factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(state, "trys"), "push"),
104069 /*typeArguments*/ undefined, [
104070 factory.createArrayLiteralExpression([
104071 createLabel(startLabel),
104072 createLabel(catchLabel),
104073 createLabel(finallyLabel),
104074 createLabel(endLabel)
104075 ])
104076 ])));
104077 currentExceptionBlock = undefined;
104078 }
104079 if (markLabelEnd) {
104080 // The case clause for the last label falls through to this label, so we
104081 // add an assignment statement to reflect the change in labels.
104082 statements.push(factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(state, "label"), factory.createNumericLiteral(labelNumber + 1))));
104083 }
104084 }
104085 clauses.push(factory.createCaseClause(factory.createNumericLiteral(labelNumber), statements || []));
104086 statements = undefined;
104087 }
104088 /**
104089 * Tries to enter into a new label at the current operation index.
104090 */

Callers 2

flushLabelFunction · 0.85
flushFinalLabelFunction · 0.85

Calls 3

createLabelFunction · 0.85
unshiftMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected