Convert converts the JSON statement into its output form.
()
| 764 | |
| 765 | // Convert converts the JSON statement into its output form. |
| 766 | func (stmt *plpgSQL_stmt_while) Convert() (block Block, err error) { |
| 767 | // Convert the body of the loop first so we can determine the GOTO offsets |
| 768 | convertedLoopBodyStmts, err := jsonConvertStatements(stmt.Body) |
| 769 | if err != nil { |
| 770 | return Block{}, err |
| 771 | } |
| 772 | |
| 773 | block = Block{ |
| 774 | Body: []Statement{ |
| 775 | If{ |
| 776 | Condition: stmt.Condition.Expression.Query, |
| 777 | // Jump forward two statements, so we skip over the GOTO below that exits the WHILE loop. |
| 778 | GotoOffset: 2, |
| 779 | }, |
| 780 | Goto{ |
| 781 | // Jump forward 1 statement to get to the loop body, then jump over the loop body and the |
| 782 | // GOTO statement that jumps to the start of the WHILE loop. |
| 783 | Offset: 1 + OperationSizeForStatements(convertedLoopBodyStmts) + 1, |
| 784 | }, |
| 785 | }, |
| 786 | Label: stmt.Label, |
| 787 | IsLoop: true, |
| 788 | } |
| 789 | |
| 790 | // Add the converted body of the WHILE loop, and a GOTO statement that jumps backwards past the current |
| 791 | // GOTO statement, and past all the body statements, and past the GOTO statement at the start of the loop. |
| 792 | block.Body = append(block.Body, convertedLoopBodyStmts...) |
| 793 | block.Body = append(block.Body, Goto{Offset: -1 * (OperationSizeForStatements(convertedLoopBodyStmts) + 2)}) |
| 794 | return block, nil |
| 795 | } |
nothing calls this directly
no test coverage detected