diff --git a/pkg/compiler/interop_test.go b/pkg/compiler/interop_test.go index 073c1c2ec..5bcd269a2 100644 --- a/pkg/compiler/interop_test.go +++ b/pkg/compiler/interop_test.go @@ -221,7 +221,7 @@ func TestBuiltinDoesNotCompile(t *testing.T) { ctx := v.Context() retCount := 0 for op, _, err := ctx.Next(); err == nil; op, _, err = ctx.Next() { - if ctx.IP() > len(ctx.Program()) { + if ctx.IP() >= len(ctx.Program()) { break } if op == opcode.RET { diff --git a/pkg/vm/cli/cli.go b/pkg/vm/cli/cli.go index a5fc1b060..61e00d585 100644 --- a/pkg/vm/cli/cli.go +++ b/pkg/vm/cli/cli.go @@ -433,8 +433,8 @@ func handleOps(c *ishell.Context) { } func changePrompt(c ishell.Actions, v *vm.VM) { - if v.Ready() && v.Context().IP()-1 >= 0 { - c.SetPrompt(fmt.Sprintf("NEO-GO-VM %d > ", v.Context().IP()-1)) + if v.Ready() && v.Context().IP() >= 0 { + c.SetPrompt(fmt.Sprintf("NEO-GO-VM %d > ", v.Context().IP())) } else { c.SetPrompt("NEO-GO-VM > ") } diff --git a/pkg/vm/context.go b/pkg/vm/context.go index f2cf01ab1..79893d299 100644 --- a/pkg/vm/context.go +++ b/pkg/vm/context.go @@ -141,11 +141,9 @@ func (c *Context) Next() (opcode.Opcode, []byte, error) { return instr, parameter, nil } -// IP returns the absolute instruction without taking 0 into account. -// If that program starts the ip = 0 but IP() will return 1, cause its -// the first instruction. +// IP returns current instruction offset in the context script. func (c *Context) IP() int { - return c.ip + 1 + return c.ip } // LenInstr returns the number of instructions loaded.