Merge pull request #642 from nspcc-dev/feature/emit

vm, compiler: move Emit* functions to a separate package

Closes #449, #534.
This commit is contained in:
Roman Khimov 2020-02-08 15:56:48 +03:00 committed by GitHub
commit 9b9adb28c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 521 additions and 564 deletions

View file

@ -3,6 +3,8 @@ package vm
import (
"errors"
"github.com/CityOfZion/neo-go/pkg/vm/emit"
"github.com/CityOfZion/neo-go/pkg/io"
)
@ -49,7 +51,7 @@ func serializeItemTo(item StackItem, w *io.BinWriter, seen map[StackItem]bool) {
w.WriteBool(t.value)
case *BigIntegerItem:
w.WriteBytes([]byte{byte(integerT)})
w.WriteVarBytes(IntToBytes(t.value))
w.WriteVarBytes(emit.IntToBytes(t.value))
case *InteropItem:
w.Err = errors.New("interop item can't be serialized")
case *ArrayItem, *StructItem:
@ -108,7 +110,7 @@ func DecodeBinaryStackItem(r *io.BinReader) StackItem {
return NewBoolItem(b)
case integerT:
data := r.ReadVarBytes()
num := BytesToInt(data)
num := emit.BytesToInt(data)
return &BigIntegerItem{
value: num,
}