wasmproc

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2021 License: Apache-2.0, BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FuncDefault      = "_default"
	ViewCopyAllState = "copy_all_state"
)

Variables

View Source
var GoWasmVM wasmhost.WasmVM
View Source
var TestMode = false

Functions

func GetArrayObjectID added in v0.2.0

func GetArrayObjectID(arrayObj WaspObject, index, typeID int32, factory ObjFactory) int32

func GetMapObjectID added in v0.2.0

func GetMapObjectID(mapObj WaspObject, keyID, typeID int32, factories ObjFactories) int32

func GetProcessor

func GetProcessor(binaryCode []byte, log *logger.Logger) (iscp.VMProcessor, error)

GetProcessor creates a new Wasm VM processor.

func NewScViewState

func NewScViewState(ctxView iscp.SandboxView) kv.KVStore

Types

type BytesDecoder

type BytesDecoder struct {
	// contains filtered or unexported fields
}

func NewBytesDecoder

func NewBytesDecoder(data []byte) *BytesDecoder

func (*BytesDecoder) Bytes

func (d *BytesDecoder) Bytes() []byte

func (*BytesDecoder) Int16 added in v0.2.0

func (d *BytesDecoder) Int16() int16

func (*BytesDecoder) Int32 added in v0.2.0

func (d *BytesDecoder) Int32() int32

func (*BytesDecoder) Int64

func (d *BytesDecoder) Int64() int64

type BytesEncoder

type BytesEncoder struct {
	// contains filtered or unexported fields
}

func NewBytesEncoder

func NewBytesEncoder() *BytesEncoder

func (*BytesEncoder) Bytes

func (e *BytesEncoder) Bytes(value []byte) *BytesEncoder

func (*BytesEncoder) Data

func (e *BytesEncoder) Data() []byte

func (*BytesEncoder) Int16 added in v0.2.0

func (e *BytesEncoder) Int16(value int16) *BytesEncoder

func (*BytesEncoder) Int32 added in v0.2.0

func (e *BytesEncoder) Int32(value int32) *BytesEncoder

func (*BytesEncoder) Int64

func (e *BytesEncoder) Int64(value int64) *BytesEncoder

type ObjFactories

type ObjFactories map[int32]ObjFactory

type ObjFactory

type ObjFactory func() WaspObject

type ScContext

type ScContext struct {
	ScSandboxObject
	// contains filtered or unexported fields
}

func NewScContext

func NewScContext(wc *WasmContext, host *wasmhost.KvStoreHost) *ScContext

func (*ScContext) Exists

func (o *ScContext) Exists(keyID, typeID int32) bool

func (*ScContext) GetBytes

func (o *ScContext) GetBytes(keyID, typeID int32) []byte

func (*ScContext) GetObjectID added in v0.2.0

func (o *ScContext) GetObjectID(keyID, typeID int32) int32

func (*ScContext) GetTypeID added in v0.2.0

func (o *ScContext) GetTypeID(keyID int32) int32

func (*ScContext) SetBytes

func (o *ScContext) SetBytes(keyID, typeID int32, bytes []byte)

type ScDict

type ScDict struct {
	// contains filtered or unexported fields
}

func NewScBalances

func NewScBalances(wc *WasmContext, keyID int32) *ScDict

func NewScDict

func NewScDict(host *wasmhost.KvStoreHost, kvStore kv.KVStore) *ScDict

func (*ScDict) CallFunc added in v0.2.0

func (o *ScDict) CallFunc(keyID int32, params []byte) []byte

func (*ScDict) Exists

func (o *ScDict) Exists(keyID, typeID int32) bool

func (*ScDict) FindOrMakeObjectID added in v0.2.0

func (o *ScDict) FindOrMakeObjectID(keyID int32, factory ObjFactory) int32

func (*ScDict) GetBytes

func (o *ScDict) GetBytes(keyID, typeID int32) []byte

func (*ScDict) GetObjectID added in v0.2.0

func (o *ScDict) GetObjectID(keyID, typeID int32) int32

func (*ScDict) GetTypeID added in v0.2.0

func (o *ScDict) GetTypeID(keyID int32) int32

func (*ScDict) InitObj

func (o *ScDict) InitObj(id, keyID int32, owner *ScDict)

func (*ScDict) InvalidKey added in v0.2.0

func (o *ScDict) InvalidKey(keyID int32)

func (*ScDict) KvStore added in v0.2.0

func (o *ScDict) KvStore() kv.KVStore

func (*ScDict) NestedKey

func (o *ScDict) NestedKey() string

func (*ScDict) Owner

func (o *ScDict) Owner() WaspObject

func (*ScDict) Panic

func (o *ScDict) Panic(format string, args ...interface{})

func (*ScDict) SetBytes

func (o *ScDict) SetBytes(keyID, typeID int32, bytes []byte)

func (*ScDict) SetKvStore added in v0.2.0

func (o *ScDict) SetKvStore(res kv.KVStore)

func (*ScDict) Suffix

func (o *ScDict) Suffix(keyID int32) string

func (*ScDict) Tracef added in v0.2.0

func (o *ScDict) Tracef(format string, a ...interface{})

type ScExports

type ScExports struct {
	ScSandboxObject
	// contains filtered or unexported fields
}

func NewScExports

func NewScExports(wc *WasmContext) *ScExports

func (*ScExports) SetBytes

func (o *ScExports) SetBytes(keyID, typeID int32, bytes []byte)

type ScMaps

type ScMaps struct {
	ScSandboxObject
}

func NewScMaps

func NewScMaps(host *wasmhost.KvStoreHost) *ScMaps

func (*ScMaps) GetObjectID added in v0.2.0

func (a *ScMaps) GetObjectID(keyID, typeID int32) int32

type ScSandboxObject

type ScSandboxObject struct {
	ScDict
}

func (*ScSandboxObject) GetBytes

func (o *ScSandboxObject) GetBytes(keyID, typeID int32) []byte

func (*ScSandboxObject) GetObjectID added in v0.2.0

func (o *ScSandboxObject) GetObjectID(keyID, typeID int32) int32

func (*ScSandboxObject) SetBytes

func (o *ScSandboxObject) SetBytes(keyID, typeID int32, bytes []byte)

type ScTransferInfo

type ScTransferInfo struct {
	ScSandboxObject
	// contains filtered or unexported fields
}

func NewScTransferInfo

func NewScTransferInfo(wc *WasmContext) *ScTransferInfo

func (*ScTransferInfo) Invoke

func (o *ScTransferInfo) Invoke(balances int32)

TODO refactor

func (*ScTransferInfo) SetBytes

func (o *ScTransferInfo) SetBytes(keyID, typeID int32, bytes []byte)

type ScTransfers

type ScTransfers struct {
	ScSandboxObject
	// contains filtered or unexported fields
}

func NewScTransfers

func NewScTransfers(wc *WasmContext) *ScTransfers

func (*ScTransfers) GetObjectID added in v0.2.0

func (a *ScTransfers) GetObjectID(keyID, typeID int32) int32

type ScUtility

type ScUtility struct {
	ScSandboxObject
	// contains filtered or unexported fields
}

func NewScUtility

func NewScUtility(wc *WasmContext) *ScUtility

func (*ScUtility) CallFunc added in v0.2.0

func (o *ScUtility) CallFunc(keyID int32, bytes []byte) []byte

func (*ScUtility) Exists

func (o *ScUtility) Exists(keyID, typeID int32) bool

func (*ScUtility) GetTypeID added in v0.2.0

func (o *ScUtility) GetTypeID(keyID int32) int32

func (*ScUtility) InitObj

func (o *ScUtility) InitObj(id, keyID int32, owner *ScDict)

type ScViewState

type ScViewState struct {
	// contains filtered or unexported fields
}

ScViewState wraps immutable view state into a mutable KVStore with the KVWriter functions implemented as panics WaspLib already takes care of the immutability aspect, so these panics should never trigger, and we can avoid a much more drastic refactoring for now

func (ScViewState) Del

func (s ScViewState) Del(key kv.Key)

func (ScViewState) Get

func (s ScViewState) Get(key kv.Key) ([]byte, error)

func (ScViewState) Has

func (s ScViewState) Has(key kv.Key) (bool, error)

func (ScViewState) Iterate

func (s ScViewState) Iterate(prefix kv.Key, f func(key kv.Key, value []byte) bool) error

func (ScViewState) IterateKeys

func (s ScViewState) IterateKeys(prefix kv.Key, f func(key kv.Key) bool) error

func (ScViewState) IterateKeysSorted added in v0.2.0

func (s ScViewState) IterateKeysSorted(prefix kv.Key, f func(key kv.Key) bool) error

func (ScViewState) IterateSorted added in v0.2.0

func (s ScViewState) IterateSorted(prefix kv.Key, f func(key kv.Key, value []byte) bool) error

func (ScViewState) MustGet

func (s ScViewState) MustGet(key kv.Key) []byte

func (ScViewState) MustHas

func (s ScViewState) MustHas(key kv.Key) bool

func (ScViewState) MustIterate

func (s ScViewState) MustIterate(prefix kv.Key, f func(key kv.Key, value []byte) bool)

func (ScViewState) MustIterateKeys

func (s ScViewState) MustIterateKeys(prefix kv.Key, f func(key kv.Key) bool)

func (ScViewState) MustIterateKeysSorted added in v0.2.0

func (s ScViewState) MustIterateKeysSorted(prefix kv.Key, f func(key kv.Key) bool)

func (ScViewState) MustIterateSorted added in v0.2.0

func (s ScViewState) MustIterateSorted(prefix kv.Key, f func(key kv.Key, value []byte) bool)

func (ScViewState) Set

func (s ScViewState) Set(key kv.Key, value []byte)

type WasmContext added in v0.2.0

type WasmContext struct {
	wasmhost.KvStoreHost
	// contains filtered or unexported fields
}

func NewWasmContext added in v0.2.0

func NewWasmContext(function string, proc *WasmProcessor) *WasmContext

func (*WasmContext) AddFunc added in v0.2.0

func (*WasmContext) AddView added in v0.2.0

func (*WasmContext) Call added in v0.2.0

func (wc *WasmContext) Call(ctx interface{}) (dict.Dict, error)

func (*WasmContext) FunctionFromCode added in v0.2.0

func (wc *WasmContext) FunctionFromCode(code uint32) string

func (*WasmContext) IsView added in v0.2.0

func (wc *WasmContext) IsView() bool

type WasmProcessor added in v0.2.0

type WasmProcessor struct {
	wasmhost.WasmHost
	// contains filtered or unexported fields
}

func (*WasmProcessor) GetDefaultEntryPoint added in v0.2.0

func (proc *WasmProcessor) GetDefaultEntryPoint() iscp.VMProcessorEntryPoint

func (*WasmProcessor) GetDescription added in v0.2.0

func (proc *WasmProcessor) GetDescription() string

func (*WasmProcessor) GetEntryPoint added in v0.2.0

func (proc *WasmProcessor) GetEntryPoint(code iscp.Hname) (iscp.VMProcessorEntryPoint, bool)

func (*WasmProcessor) GetKvStore added in v0.2.0

func (proc *WasmProcessor) GetKvStore(id int32) *wasmhost.KvStoreHost

func (*WasmProcessor) KillContext added in v0.2.0

func (proc *WasmProcessor) KillContext(id int32)

type WaspObject

type WaspObject interface {
	wasmhost.HostObject
	InitObj(id int32, keyID int32, owner *ScDict)
	Panic(format string, args ...interface{})
	FindOrMakeObjectID(keyID int32, factory ObjFactory) int32
	NestedKey() string
	Suffix(keyID int32) string
}

func NewNullObject

func NewNullObject(host *wasmhost.KvStoreHost) WaspObject

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL