(expression: lua.FunctionExpression)
| 662 | } |
| 663 | |
| 664 | public printFunctionExpression(expression: lua.FunctionExpression): SourceNode { |
| 665 | const chunks: SourceChunk[] = []; |
| 666 | |
| 667 | chunks.push("function("); |
| 668 | chunks.push(...this.printFunctionParameters(expression)); |
| 669 | chunks.push(")"); |
| 670 | |
| 671 | if (lua.isInlineFunctionExpression(expression)) { |
| 672 | const returnStatement = expression.body.statements[0]; |
| 673 | chunks.push(" "); |
| 674 | const returnNode: SourceChunk[] = [ |
| 675 | "return ", |
| 676 | ...this.joinChunksWithComma(returnStatement.expressions.map(e => this.printExpression(e))), |
| 677 | ]; |
| 678 | chunks.push(this.createSourceNode(returnStatement, returnNode)); |
| 679 | chunks.push(this.createSourceNode(expression, " end")); |
| 680 | } else { |
| 681 | chunks.push("\n"); |
| 682 | this.pushIndent(); |
| 683 | chunks.push(this.printBlock(expression.body)); |
| 684 | this.popIndent(); |
| 685 | chunks.push(this.indent(this.createSourceNode(expression, "end"))); |
| 686 | } |
| 687 | |
| 688 | return this.createSourceNode(expression, chunks); |
| 689 | } |
| 690 | |
| 691 | public printFunctionDefinition(statement: lua.FunctionDefinition): SourceNode { |
| 692 | const expression = statement.right[0]; |
no test coverage detected