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

Function visitConditionalExpression

test/fixtures/snapshot/typescript.js:102494–102525  ·  view source on GitHub ↗

* Visits a conditional expression containing `yield`. * * @param node The node to visit.

(node)

Source from the content-addressed store, hash-verified

102492 * @param node The node to visit.
102493 */
102494 function visitConditionalExpression(node) {
102495 // [source]
102496 // x = a() ? yield : b();
102497 //
102498 // [intermediate]
102499 // .local _a
102500 // .brfalse whenFalseLabel, (a())
102501 // .yield resumeLabel
102502 // .mark resumeLabel
102503 // _a = %sent%;
102504 // .br resultLabel
102505 // .mark whenFalseLabel
102506 // _a = b();
102507 // .mark resultLabel
102508 // x = _a;
102509 // We only need to perform a specific transformation if a `yield` expression exists
102510 // in either the `whenTrue` or `whenFalse` branches.
102511 // A `yield` in the condition will be handled by the normal visitor.
102512 if (containsYield(node.whenTrue) || containsYield(node.whenFalse)) {
102513 var whenFalseLabel = defineLabel();
102514 var resultLabel = defineLabel();
102515 var resultLocal = declareLocal();
102516 emitBreakWhenFalse(whenFalseLabel, ts.visitNode(node.condition, visitor, ts.isExpression), /*location*/ node.condition);
102517 emitAssignment(resultLocal, ts.visitNode(node.whenTrue, visitor, ts.isExpression), /*location*/ node.whenTrue);
102518 emitBreak(resultLabel);
102519 markLabel(whenFalseLabel);
102520 emitAssignment(resultLocal, ts.visitNode(node.whenFalse, visitor, ts.isExpression), /*location*/ node.whenFalse);
102521 markLabel(resultLabel);
102522 return resultLocal;
102523 }
102524 return ts.visitEachChild(node, visitor, context);
102525 }
102526 /**
102527 * Visits a `yield` expression.
102528 *

Callers 1

Calls 7

defineLabelFunction · 0.85
declareLocalFunction · 0.85
emitBreakWhenFalseFunction · 0.85
emitAssignmentFunction · 0.85
emitBreakFunction · 0.85
markLabelFunction · 0.85
containsYieldFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…