core: add VM into interop context

This commit is contained in:
Anna Shaleva 2020-08-07 14:37:49 +03:00
parent b0f0dc5352
commit 995053f2eb
20 changed files with 384 additions and 382 deletions

View file

@ -18,19 +18,19 @@ type Callback interface {
}
// Invoke invokes provided callback.
func Invoke(ic *interop.Context, v *vm.VM) error {
cb := v.Estack().Pop().Interop().Value().(Callback)
args := v.Estack().Pop().Array()
func Invoke(ic *interop.Context) error {
cb := ic.VM.Estack().Pop().Interop().Value().(Callback)
args := ic.VM.Estack().Pop().Array()
if cb.ArgCount() != len(args) {
return errors.New("invalid argument count")
}
cb.LoadContext(v, args)
cb.LoadContext(ic.VM, args)
switch t := cb.(type) {
case *MethodCallback:
id := emit.InteropNameToID([]byte("System.Contract.Call"))
return ic.SyscallHandler(v, id)
return ic.SyscallHandler(ic.VM, id)
case *SyscallCallback:
return ic.SyscallHandler(v, t.desc.ID)
return ic.SyscallHandler(ic.VM, t.desc.ID)
default:
return nil
}