From 92ddc474d823158fec0cffaeba6261235c8b00f2 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 24 Jul 2020 17:15:05 +0300 Subject: [PATCH] vm: pretty-print CONVERT and ISTYPE opcodes --- pkg/vm/vm.go | 3 +++ pkg/vm/vm_test.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 14a3a435e..cfaf03f1c 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -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: diff --git a/pkg/vm/vm_test.go b/pkg/vm/vm_test.go index cb55e949b..a61b41a4f 100644 --- a/pkg/vm/vm_test.go +++ b/pkg/vm/vm_test.go @@ -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) } }