MCPcopy Index your code
hub / github.com/TypeScriptToLua/TypeScriptToLua / printForStatement

Method printForStatement

src/LuaPrinter.ts:516–537  ·  view source on GitHub ↗
(statement: lua.ForStatement)

Source from the content-addressed store, hash-verified

514 }
515
516 public printForStatement(statement: lua.ForStatement): SourceNode {
517 const ctrlVar = this.printExpression(statement.controlVariable);
518 const ctrlVarInit = this.printExpression(statement.controlVariableInitializer);
519 const limit = this.printExpression(statement.limitExpression);
520
521 const chunks: SourceChunk[] = [];
522
523 chunks.push(this.indent("for "), ctrlVar, " = ", ctrlVarInit, ", ", limit);
524
525 if (statement.stepExpression) {
526 chunks.push(", ", this.printExpression(statement.stepExpression));
527 }
528 chunks.push(" do\n");
529
530 this.pushIndent();
531 chunks.push(this.printBlock(statement.body));
532 this.popIndent();
533
534 chunks.push(this.indent("end"));
535
536 return this.concatNodes(...chunks);
537 }
538
539 public printForInStatement(statement: lua.ForInStatement): SourceNode {
540 const names = this.joinChunksWithComma(statement.names.map(i => this.printIdentifier(i)));

Callers 1

Calls 6

printExpressionMethod · 0.95
indentMethod · 0.95
pushIndentMethod · 0.95
printBlockMethod · 0.95
popIndentMethod · 0.95
concatNodesMethod · 0.95

Tested by

no test coverage detected