vm: drop ParamCount from Context

It's unused and it's useless.
This commit is contained in:
Roman Khimov 2021-11-19 19:32:50 +03:00
parent 765235eca3
commit c53d978edd
3 changed files with 9 additions and 13 deletions

View file

@ -113,7 +113,7 @@ func callExFromNative(ic *interop.Context, caller util.Uint160, cs *state.Contra
} }
ic.VM.Invocations[cs.Hash]++ ic.VM.Invocations[cs.Hash]++
ic.VM.LoadScriptWithCallingHash(caller, cs.NEF.Script, cs.Hash, ic.VM.Context().GetCallFlags()&f, hasReturn, uint16(len(args))) ic.VM.LoadScriptWithCallingHash(caller, cs.NEF.Script, cs.Hash, ic.VM.Context().GetCallFlags()&f, hasReturn)
ic.VM.Context().NEF = &cs.NEF ic.VM.Context().NEF = &cs.NEF
for e, i := ic.VM.Estack(), len(args)-1; i >= 0; i-- { for e, i := ic.VM.Estack(), len(args)-1; i >= 0; i-- {
e.PushItem(args[i]) e.PushItem(args[i])

View file

@ -48,8 +48,6 @@ type Context struct {
// Call flags this context was created with. // Call flags this context was created with.
callFlag callflag.CallFlag callFlag callflag.CallFlag
// ParamCount specifies number of parameters.
ParamCount int
// 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.
@ -73,17 +71,16 @@ var errNoInstParam = errors.New("failed to read instruction parameter")
// NewContext returns a new Context object. // NewContext returns a new Context object.
func NewContext(b []byte) *Context { func NewContext(b []byte) *Context {
return NewContextWithParams(b, 0, -1, 0) return NewContextWithParams(b, -1, 0)
} }
// NewContextWithParams creates new Context objects using script, parameter count, // NewContextWithParams creates new Context objects using script, parameter count,
// return value count and initial position in script. // return value count and initial position in script.
func NewContextWithParams(b []byte, pcount int, rvcount int, pos int) *Context { func NewContextWithParams(b []byte, rvcount int, pos int) *Context {
return &Context{ return &Context{
prog: b, prog: b,
ParamCount: pcount, RetCount: rvcount,
RetCount: rvcount, nextip: pos,
nextip: pos,
} }
} }

View file

@ -279,7 +279,7 @@ func (v *VM) LoadScript(b []byte) {
// LoadScriptWithFlags loads script and sets call flag to f. // LoadScriptWithFlags loads script and sets call flag to f.
func (v *VM) LoadScriptWithFlags(b []byte, f callflag.CallFlag) { func (v *VM) LoadScriptWithFlags(b []byte, f callflag.CallFlag) {
v.checkInvocationStackSize() v.checkInvocationStackSize()
ctx := NewContextWithParams(b, 0, -1, 0) ctx := NewContextWithParams(b, -1, 0)
v.estack = newStack("evaluation", &v.refs) v.estack = newStack("evaluation", &v.refs)
ctx.estack = v.estack ctx.estack = v.estack
initStack(&ctx.tryStack, "exception", nil) initStack(&ctx.tryStack, "exception", nil)
@ -297,13 +297,13 @@ func (v *VM) LoadScriptWithFlags(b []byte, f callflag.CallFlag) {
// each other. // each other.
func (v *VM) LoadScriptWithHash(b []byte, hash util.Uint160, f callflag.CallFlag) { func (v *VM) LoadScriptWithHash(b []byte, hash util.Uint160, f callflag.CallFlag) {
shash := v.GetCurrentScriptHash() shash := v.GetCurrentScriptHash()
v.LoadScriptWithCallingHash(shash, b, hash, f, true, 0) v.LoadScriptWithCallingHash(shash, b, hash, f, true)
} }
// LoadScriptWithCallingHash is similar to LoadScriptWithHash but sets calling hash explicitly. // LoadScriptWithCallingHash is similar to LoadScriptWithHash but sets calling hash explicitly.
// It should be used for calling from native contracts. // It should be used for calling from native contracts.
func (v *VM) LoadScriptWithCallingHash(caller util.Uint160, b []byte, hash util.Uint160, func (v *VM) LoadScriptWithCallingHash(caller util.Uint160, b []byte, hash util.Uint160,
f callflag.CallFlag, hasReturn bool, paramCount uint16) { f callflag.CallFlag, hasReturn bool) {
v.LoadScriptWithFlags(b, f) v.LoadScriptWithFlags(b, f)
ctx := v.Context() ctx := v.Context()
ctx.scriptHash = hash ctx.scriptHash = hash
@ -313,7 +313,6 @@ func (v *VM) LoadScriptWithCallingHash(caller util.Uint160, b []byte, hash util.
} else { } else {
ctx.RetCount = 0 ctx.RetCount = 0
} }
ctx.ParamCount = int(paramCount)
} }
// Context returns the current executed context. Nil if there is no context, // Context returns the current executed context. Nil if there is no context,