From 82d2231ea60bfb8e98d00df3525cc7366b26e708 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 19 Nov 2021 19:36:42 +0300 Subject: [PATCH] vm: make retCount an internal member of Context Doesn't make much sense exposing it, it's only used by vm package itself. --- pkg/vm/context.go | 6 +++--- pkg/vm/vm.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/vm/context.go b/pkg/vm/context.go index c81d29e7e..77d09369f 100644 --- a/pkg/vm/context.go +++ b/pkg/vm/context.go @@ -48,8 +48,8 @@ type Context struct { // Call flags this context was created with. callFlag callflag.CallFlag - // RetCount specifies number of return values. - RetCount int + // retCount specifies number of return values. + retCount int // NEF represents NEF file for the current contract. NEF *nef.File } @@ -79,7 +79,7 @@ func NewContext(b []byte) *Context { func NewContextWithParams(b []byte, rvcount int, pos int) *Context { return &Context{ prog: b, - RetCount: rvcount, + retCount: rvcount, nextip: pos, } } diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index ed3f593a4..855aa7cb4 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -309,9 +309,9 @@ func (v *VM) LoadScriptWithCallingHash(caller util.Uint160, b []byte, hash util. ctx.scriptHash = hash ctx.callingScriptHash = caller if hasReturn { - ctx.RetCount = 1 + ctx.retCount = 1 } else { - ctx.RetCount = 0 + ctx.retCount = 0 } } @@ -1361,9 +1361,9 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro newEstack := v.Context().estack if oldEstack != newEstack { - if oldCtx.RetCount >= 0 && oldEstack.Len() != oldCtx.RetCount { + if oldCtx.retCount >= 0 && oldEstack.Len() != oldCtx.retCount { panic(fmt.Errorf("invalid return values count: expected %d, got %d", - oldCtx.RetCount, oldEstack.Len())) + oldCtx.retCount, oldEstack.Len())) } rvcount := oldEstack.Len() for i := rvcount; i > 0; i-- { @@ -1566,7 +1566,7 @@ func (v *VM) Call(offset int) { func (v *VM) call(ctx *Context, offset int) { v.checkInvocationStackSize() newCtx := ctx.Copy() - newCtx.RetCount = -1 + newCtx.retCount = -1 newCtx.local = nil newCtx.arguments = nil initStack(&newCtx.tryStack, "exception", nil)