From d3fee6e695813fc1f82b55eb7922a9dfcecd36cc Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Wed, 19 Jul 2023 17:09:45 +0400 Subject: [PATCH] Fix OpLoadEnv disassemble --- vm/program.go | 5 ++++- vm/program_test.go | 2 +- vm/vm.go | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vm/program.go b/vm/program.go index d424df14f..57d7140eb 100644 --- a/vm/program.go +++ b/vm/program.go @@ -97,6 +97,9 @@ func (program *Program) Disassemble() string { case OpLoadFunc: argument("OpLoadFunc") + case OpLoadEnv: + code("OpLoadEnv") + case OpFetch: code("OpFetch") @@ -270,7 +273,7 @@ func (program *Program) Disassemble() string { code("OpEnd") default: - _, _ = fmt.Fprintf(w, "%v\t%#x\n", ip, op) + _, _ = fmt.Fprintf(w, "%v\t%#x (unknown)\n", ip, op) } } _ = w.Flush() diff --git a/vm/program_test.go b/vm/program_test.go index b7bb4f226..06e83b18c 100644 --- a/vm/program_test.go +++ b/vm/program_test.go @@ -15,7 +15,7 @@ func TestProgram_Disassemble(t *testing.T) { Arguments: []int{1}, } d := program.Disassemble() - if strings.Contains(d, "\t0x") { + if strings.Contains(d, "(unknown)") { t.Errorf("cannot disassemble all opcodes") } } diff --git a/vm/vm.go b/vm/vm.go index 3e5411b1f..b2b2e619e 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -125,6 +125,7 @@ func (vm *VM) Run(program *Program, env interface{}) (_ interface{}, err error) case OpLoadEnv: vm.push(env) + case OpMethod: a := vm.pop() vm.push(runtime.FetchMethod(a, program.Constants[arg].(*runtime.Method)))