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

Function transformAndEmitForInStatement

test/fixtures/snapshot/typescript.js:102990–103049  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

102988 return node;
102989 }
102990 function transformAndEmitForInStatement(node) {
102991 // TODO(rbuckton): Source map locations
102992 if (containsYield(node)) {
102993 // [source]
102994 // for (var p in o) {
102995 // /*body*/
102996 // }
102997 //
102998 // [intermediate]
102999 // .local _a, _b, _i
103000 // _a = [];
103001 // for (_b in o) _a.push(_b);
103002 // _i = 0;
103003 // .loop incrementLabel, endLoopLabel
103004 // .mark conditionLabel
103005 // .brfalse endLoopLabel, (_i < _a.length)
103006 // p = _a[_i];
103007 // /*body*/
103008 // .mark incrementLabel
103009 // _b++;
103010 // .br conditionLabel
103011 // .endloop
103012 // .mark endLoopLabel
103013 var keysArray = declareLocal(); // _a
103014 var key = declareLocal(); // _b
103015 var keysIndex = factory.createLoopVariable(); // _i
103016 var initializer = node.initializer;
103017 hoistVariableDeclaration(keysIndex);
103018 emitAssignment(keysArray, factory.createArrayLiteralExpression());
103019 emitStatement(factory.createForInStatement(key, ts.visitNode(node.expression, visitor, ts.isExpression), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
103020 /*typeArguments*/ undefined, [key]))));
103021 emitAssignment(keysIndex, factory.createNumericLiteral(0));
103022 var conditionLabel = defineLabel();
103023 var incrementLabel = defineLabel();
103024 var endLabel = beginLoopBlock(incrementLabel);
103025 markLabel(conditionLabel);
103026 emitBreakWhenFalse(endLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
103027 var variable = void 0;
103028 if (ts.isVariableDeclarationList(initializer)) {
103029 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
103030 var variable_1 = _a[_i];
103031 hoistVariableDeclaration(variable_1.name);
103032 }
103033 variable = factory.cloneNode(initializer.declarations[0].name);
103034 }
103035 else {
103036 variable = ts.visitNode(initializer, visitor, ts.isExpression);
103037 ts.Debug.assert(ts.isLeftHandSideExpression(variable));
103038 }
103039 emitAssignment(variable, factory.createElementAccessExpression(keysArray, keysIndex));
103040 transformAndEmitEmbeddedStatement(node.statement);
103041 markLabel(incrementLabel);
103042 emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
103043 emitBreak(conditionLabel);
103044 endLoopBlock();
103045 }
103046 else {
103047 emitStatement(ts.visitNode(node, visitor, ts.isStatement));

Callers 1

Calls 13

declareLocalFunction · 0.85
hoistVariableDeclarationFunction · 0.85
emitAssignmentFunction · 0.85
emitStatementFunction · 0.85
defineLabelFunction · 0.85
beginLoopBlockFunction · 0.85
markLabelFunction · 0.85
emitBreakWhenFalseFunction · 0.85
emitBreakFunction · 0.85
endLoopBlockFunction · 0.85
assertMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…