vm: pretty-print CONVERT and ISTYPE opcodes

This commit is contained in:
Evgenii Stratonikov 2020-07-24 17:15:05 +03:00
parent 95d86b67c3
commit 92ddc474d8
2 changed files with 5 additions and 0 deletions

View file

@ -191,6 +191,9 @@ func (v *VM) PrintOps() {
v.getOffsetDesc(ctx, catchP), v.getOffsetDesc(ctx, finallyP))
case opcode.INITSSLOT:
desc = fmt.Sprint(parameter[0])
case opcode.CONVERT, opcode.ISTYPE:
typ := stackitem.Type(parameter[0])
desc = fmt.Sprintf("%s (%x)", typ, parameter[0])
case opcode.INITSLOT:
desc = fmt.Sprintf("%d local, %d arg", parameter[0], parameter[1])
case opcode.SYSCALL:

View file

@ -244,6 +244,8 @@ func TestISTYPE(t *testing.T) {
func testCONVERT(to stackitem.Type, item, res stackitem.Item) func(t *testing.T) {
return func(t *testing.T) {
prog := []byte{byte(opcode.CONVERT), byte(to)}
v := load(prog)
v.PrintOps()
runWithArgs(t, prog, res, item)
}
}