diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index 49fd5106ba4..110d7440212 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -1686,119 +1686,6 @@ namespace ts { return convertIterationStatementBodyIfNecessary(node); } - // // TODO(rbuckton): Switch to using __values helper for for..of? - // function visitForOfStatement2(node: ForOfStatement): OneOrMany { - // // [source] - // // for (let v of expr) { - // // } - // // - // // [output] - // // var __values = ...; - // // try { - // // for (_a = __values(expr), _b = _a.next(); !_b.done || (_a = void 0); _b = _a.next()) { - // // var v = _b.value; - // // } - // // } - // // finally { - // // if (_a && typeof _a.return === "function") _a.return(); - // // } - // // var _a, b; - - // const iterator = createTempVariable(); - // const iteratorResult = createTempVariable(); - // hoistVariableDeclaration(iterator); - // hoistVariableDeclaration(iteratorResult); - // const expression = visitNode(node.expression, visitor, isExpression); - // const initializer = node.initializer; - // const statements: Statement[] = []; - // if (isVariableDeclarationList(initializer)) { - // const variable = getMutableClone(initializer.declarations[0]); - // variable.initializer = createPropertyAccess(iteratorResult, "value"); - // statements.push( - // createVariableStatement( - // /*modifiers*/ undefined, - // createVariableDeclarationList( - // isBindingPattern(variable.name) - // ? flattenVariableDestructuring(variable, /*value*/ undefined, visitor) - // : [variable] - // ) - // ) - // ); - // } - // else { - // statements.push( - // createStatement( - // createAssignment( - // node.initializer, - // createPropertyAccess(iteratorResult, "value") - // ) - // ) - // ); - // } - - // if (isBlock(node.statement)) { - // addNodes(statements, visitNodes((node.statement).statements, visitor, isStatement)); - // } - // else { - // addNodes(statements, visitNodes(createNodeArray([node.statement]), visitor, isStatement)); - // } - - // return createTryFinally( - // createBlock([ - // createFor( - // createComma( - // createAssignment( - // iterator, - // createCall( - // createIdentifier("__values"), - // [expression] - // ) - // ), - // createAssignment( - // iteratorResult, - // createCall( - // createPropertyAccess(iterator, "next"), - // [] - // ) - // ) - // ), - // createLogicalOr( - // createLogicalNot(createPropertyAccess(iteratorResult, "done")), - // createAssignment(iterator, createVoidZero()) - // ), - // createAssignment( - // iteratorResult, - // createCall( - // createPropertyAccess(iterator, "next"), - // [] - // ) - // ), - // createBlock(statements) - // ) - // ]), - // createBlock([ - // createIf( - // createLogicalAnd( - // iterator, - // createStrictEquality( - // createTypeOf( - // createPropertyAccess(iterator, "return") - // ), - // createLiteral("function") - // ) - // ), - // createStatement( - // createCall( - // createPropertyAccess(iterator, "return"), - // [], - // /*location*/ node.expression - // ) - // ) - // ) - // ]) - // ); - // } - /** * Visits a ForOfStatement and converts it into a compatible ForStatement. *