mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-27 15:42:54 +00:00
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:
parent
c53d978edd
commit
82d2231ea6
2 changed files with 8 additions and 8 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
10
pkg/vm/vm.go
10
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)
|
||||
|
|
Loading…
Reference in a new issue