core: add VM into interop context
This commit is contained in:
parent
b0f0dc5352
commit
995053f2eb
20 changed files with 384 additions and 382 deletions
|
@ -2,28 +2,27 @@ package json
|
|||
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
)
|
||||
|
||||
// Serialize handles System.JSON.Serialize syscall.
|
||||
func Serialize(_ *interop.Context, v *vm.VM) error {
|
||||
item := v.Estack().Pop().Item()
|
||||
func Serialize(ic *interop.Context) error {
|
||||
item := ic.VM.Estack().Pop().Item()
|
||||
data, err := stackitem.ToJSON(item)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Estack().PushVal(data)
|
||||
ic.VM.Estack().PushVal(data)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Deserialize handles System.JSON.Deserialize syscall.
|
||||
func Deserialize(_ *interop.Context, v *vm.VM) error {
|
||||
data := v.Estack().Pop().Bytes()
|
||||
func Deserialize(ic *interop.Context) error {
|
||||
data := ic.VM.Estack().Pop().Bytes()
|
||||
item, err := stackitem.FromJSON(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Estack().PushVal(item)
|
||||
ic.VM.Estack().PushVal(item)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue