vm: make retCount an internal member of Context

Doesn't make much sense exposing it, it's only used by vm package itself.
This commit is contained in:
Roman Khimov 2021-11-19 19:36:42 +03:00
parent c53d978edd
commit 82d2231ea6
2 changed files with 8 additions and 8 deletions

View file

@ -48,8 +48,8 @@ type Context struct {
// Call flags this context was created with. // Call flags this context was created with.
callFlag callflag.CallFlag callFlag callflag.CallFlag
// RetCount specifies number of return values. // retCount specifies number of return values.
RetCount int retCount int
// NEF represents NEF file for the current contract. // NEF represents NEF file for the current contract.
NEF *nef.File NEF *nef.File
} }
@ -79,7 +79,7 @@ func NewContext(b []byte) *Context {
func NewContextWithParams(b []byte, rvcount int, pos int) *Context { func NewContextWithParams(b []byte, rvcount int, pos int) *Context {
return &Context{ return &Context{
prog: b, prog: b,
RetCount: rvcount, retCount: rvcount,
nextip: pos, nextip: pos,
} }
} }

View file

@ -309,9 +309,9 @@ func (v *VM) LoadScriptWithCallingHash(caller util.Uint160, b []byte, hash util.
ctx.scriptHash = hash ctx.scriptHash = hash
ctx.callingScriptHash = caller ctx.callingScriptHash = caller
if hasReturn { if hasReturn {
ctx.RetCount = 1 ctx.retCount = 1
} else { } 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 newEstack := v.Context().estack
if oldEstack != newEstack { 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", panic(fmt.Errorf("invalid return values count: expected %d, got %d",
oldCtx.RetCount, oldEstack.Len())) oldCtx.retCount, oldEstack.Len()))
} }
rvcount := oldEstack.Len() rvcount := oldEstack.Len()
for i := rvcount; i > 0; i-- { for i := rvcount; i > 0; i-- {
@ -1566,7 +1566,7 @@ func (v *VM) Call(offset int) {
func (v *VM) call(ctx *Context, offset int) { func (v *VM) call(ctx *Context, offset int) {
v.checkInvocationStackSize() v.checkInvocationStackSize()
newCtx := ctx.Copy() newCtx := ctx.Copy()
newCtx.RetCount = -1 newCtx.retCount = -1
newCtx.local = nil newCtx.local = nil
newCtx.arguments = nil newCtx.arguments = nil
initStack(&newCtx.tryStack, "exception", nil) initStack(&newCtx.tryStack, "exception", nil)