| 1 |
package vm_indent |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
|
| 6 |
"github.com/goccy/go-json/internal/encoder" |
| 7 |
) |
| 8 |
|
| 9 |
func DebugRun(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) { |
| 10 |
var code *encoder.Opcode |
| 11 |
if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 { |
| 12 |
code = codeSet.EscapeKeyCode |
| 13 |
} else { |
| 14 |
code = codeSet.NoescapeKeyCode |
| 15 |
} |
| 16 |
|
| 17 |
defer func() { |
| 18 |
if err := recover(); err != nil { |
| 19 |
w := ctx.Option.DebugOut |
| 20 |
fmt.Fprintln(w, "=============[DEBUG]===============") |
| 21 |
fmt.Fprintln(w, "* [TYPE]") |
| 22 |
fmt.Fprintln(w, codeSet.Type) |
| 23 |
fmt.Fprintf(w, "\n") |
| 24 |
fmt.Fprintln(w, "* [ALL OPCODE]") |
| 25 |
fmt.Fprintln(w, code.Dump()) |
| 26 |
fmt.Fprintf(w, "\n") |
| 27 |
fmt.Fprintln(w, "* [CONTEXT]") |
| 28 |
fmt.Fprintf(w, "%+v\n", ctx) |
| 29 |
fmt.Fprintln(w, "===================================") |
| 30 |
panic(err) |
| 31 |
} |
| 32 |
}() |
| 33 |
|
| 34 |
return Run(ctx, b, codeSet) |
| 35 |
} |