MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Convert

Method Convert

server/plpgsql/json.go:766–795  ·  view source on GitHub ↗

Convert converts the JSON statement into its output form.

()

Source from the content-addressed store, hash-verified

764
765// Convert converts the JSON statement into its output form.
766func (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}

Callers

nothing calls this directly

Calls 2

jsonConvertStatementsFunction · 0.85

Tested by

no test coverage detected