(node)
| 100491 | return factory.updateWhileStatement(node, ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody); |
| 100492 | } |
| 100493 | function createConvertedLoopState(node) { |
| 100494 | var loopInitializer; |
| 100495 | switch (node.kind) { |
| 100496 | case 242 /* SyntaxKind.ForStatement */: |
| 100497 | case 243 /* SyntaxKind.ForInStatement */: |
| 100498 | case 244 /* SyntaxKind.ForOfStatement */: |
| 100499 | var initializer = node.initializer; |
| 100500 | if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { |
| 100501 | loopInitializer = initializer; |
| 100502 | } |
| 100503 | break; |
| 100504 | } |
| 100505 | // variables that will be passed to the loop as parameters |
| 100506 | var loopParameters = []; |
| 100507 | // variables declared in the loop initializer that will be changed inside the loop |
| 100508 | var loopOutParameters = []; |
| 100509 | if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { |
| 100510 | var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || |
| 100511 | shouldConvertConditionOfForStatement(node) || |
| 100512 | shouldConvertIncrementorOfForStatement(node); |
| 100513 | for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { |
| 100514 | var decl = _a[_i]; |
| 100515 | processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead); |
| 100516 | } |
| 100517 | } |
| 100518 | var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters }; |
| 100519 | if (convertedLoopState) { |
| 100520 | // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. |
| 100521 | // if outer converted loop has already accumulated some state - pass it through |
| 100522 | if (convertedLoopState.argumentsName) { |
| 100523 | // outer loop has already used 'arguments' so we've already have some name to alias it |
| 100524 | // use the same name in all nested loops |
| 100525 | currentState.argumentsName = convertedLoopState.argumentsName; |
| 100526 | } |
| 100527 | if (convertedLoopState.thisName) { |
| 100528 | // outer loop has already used 'this' so we've already have some name to alias it |
| 100529 | // use the same name in all nested loops |
| 100530 | currentState.thisName = convertedLoopState.thisName; |
| 100531 | } |
| 100532 | if (convertedLoopState.hoistedLocalVariables) { |
| 100533 | // we've already collected some non-block scoped variable declarations in enclosing loop |
| 100534 | // use the same storage in nested loop |
| 100535 | currentState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables; |
| 100536 | } |
| 100537 | } |
| 100538 | return currentState; |
| 100539 | } |
| 100540 | function addExtraDeclarationsForConvertedLoop(statements, state, outerState) { |
| 100541 | var extraVariableDeclarations; |
| 100542 | // propagate state from the inner loop to the outer loop if necessary |
no test coverage detected