Documentation ¶
Overview ¶
Package exec provides functions for executing WebAssembly bytecode.
Index ¶
- Constants
- Variables
- func ByteArrToNum(numArray []byte) (byte, error)
- func ByteToFloat64(bytes []byte) float64
- func BytesToF32(b []byte) float32
- func BytesToF64(b []byte) float64
- func BytesToString(bytes []byte) string
- func Convert(vm *VM, pos uint64, length uint64) ([]byte, error)
- func ConvertStr(param []byte, pos uint64, length uint64) ([]byte, error)
- func ConvertU8Byte(param []byte, pos uint64, length uint64) ([]byte, error)
- func F32ToBytes(f32 float32) []byte
- func F64ToBytes(f64 float64) []byte
- func GetInstance() *wasmEngine
- func GetWasmVersion(ctx *contract.Context) uint32
- func I32ToBytes(i32 uint32) []byte
- func I64ToBytes(i64 uint64) []byte
- func PackStrToByteArray(vm *VM, pos uint64, length uint64) ([]byte, error)
- func RemoveElement(slice []byte, start, end uint64) []byte
- func UnConvertStr(param []byte, pos uint64, length uint64) ([]byte, error)
- type ApplyContext
- type Authorization
- type EnvFunc
- type FuncInfo
- type InvalidFunctionIndexError
- type InvalidReturnTypeError
- type Message
- type ParamInfo
- type ParamList
- type Rtn
- type SrcFileType
- type TYPE
- type Type
- type VM
- func (vm *VM) ExecCode(fnIndex int64, args ...uint64) (interface{}, error)
- func (vm *VM) ExecEnvFunc(compiled compiledFunction) error
- func (vm *VM) GetContract() *contract.Context
- func (vm *VM) GetData(pos uint64) ([]byte, error)
- func (vm *VM) GetFuncInfo(method string, param []byte) error
- func (vm *VM) GetFuncParams() []uint64
- func (vm *VM) GetMemory() []byte
- func (vm *VM) GetMsgBytes() ([]byte, error)
- func (vm *VM) Memory() []byte
- func (vm *VM) RecoverContext() bool
- func (vm *VM) SetChannel(channel chan []byte) error
- func (vm *VM) SetContract(contract *contract.Context) error
- func (vm *VM) StorageData(data interface{}) (uint64, error)
- func (vm *VM) StrLen(pos uint64) uint64
Constants ¶
const ( VM_FALSE = iota VM_TRUE )
const ( // ENTRY_FUNCTION config the entry name ENTRY_FUNCTION = "start" // VM_PERIOD_OF_VALIDITY config the VM period of validity VM_PERIOD_OF_VALIDITY = "1h" // WAIT_TIME config the wait times WAIT_TIME = 4 // BOTTOS_INVALID_CODE config the status of code BOTTOS_INVALID_CODE = 1 // CALL_DEP_LIMIT config the max depth of call CALL_DEP_LIMIT = 5 // CALL_WID_LIMIT config the max width of call CALL_WID_LIMIT = 10 CALL_MAX_VM_LIMIT = 10 // CTX_WASM_FILE config ctx wasm file //CTX_WASM_FILE = "/opt/bin/go/usermng.wasm" //CTX_WASM_FILE = "C:\\Users\\stewa\\Desktop\\BottosCTX\\math.wasm" //CTX_WASM_FILE = "C:\\Users\\stewa\\Desktop\\BottosCTX\\callcontract.wasm" //CTX_WASM_FILE = "C:\\Users\\stewa\\go\\src\\github.com\\AssemblyScript\\assemblyscript\\examples\\example\\module.optimized.wasm" //CTX_WASM_FILE = "C:\\Users\\stewa\\go\\src\\github.com\\AssemblyScript\\assemblyscript\\examples\\example\\module.optimized.wasm" //CTX_WASM_FILE = "C:\\Users\\stewa\\Desktop\\BottosCTX\\commontoken.wasm" CTX_WASM_FILE = "C:\\Users\\stewa\\Desktop\\BottosCTX\\module.optimized.wasm" //CTX_WASM_FILE = "C:\\Users\\stewa\\Desktop\\BottosCTX\\module.optimized.coredump.wasm" // SUB_WASM_FILE config sub wasm file SUB_WASM_FILE = "/opt/bin/go/sub.wasm" // TST Test status TST = true )
const (
VM_NULL = iota
)
Variables ¶
var ( // ErrSignatureMismatch is the error value used while trapping the VM when // a signature mismatch between the table entry and the type entry is found // in a call_indirect operation. ErrSignatureMismatch = errors.New("exec: signature mismatch in call_indirect") // ErrUndefinedElementIndex is the error value used while trapping the VM when // an invalid index to the module's table space is used as an operand to // call_indirect ErrUndefinedElementIndex = errors.New("exec: undefined element index") )
var ERR_CALL_ENV_METHOD = errors.New("*ERROR* failed to call the env method")
var ERR_COPY_DATA = errors.New("*ERROR* failed to copy data")
var ERR_CREATE_VM = errors.New("*ERROR* failed to create a new VM instance")
var ERR_DATA_INDEX = errors.New("*ERROR* failed to get data index from memory")
var ERR_EMPTY_INVALID_PARAM = errors.New("*ERROR* empty parameter or invalid parameter")
var ERR_EOF = errors.New("EOF")
var ERR_FIND_VM_METHOD = errors.New("*ERROR* failed to find the method from the wasm module")
var ERR_FINE_MAP = errors.New("*ERROR* the specified value can't be found by the key from the map")
var ERR_GET_STORE_POS = errors.New("*ERROR* failed to get the position of data")
var ERR_GET_VM = errors.New("*ERROR* failed to get a VM instance from memory")
var ERR_INVALID_ARGUMENT_COUNT = errors.New("*ERROR* invalid number of arguments to function")
ErrInvalidArgumentCount is returned by (*VM).ExecCode when an invalid number of arguments to the WebAssembly function are passed to it.
var ERR_INVALID_WASM = errors.New("*ERROR* invalid wasm module")
var ERR_MULTIPLE_LINEAR_MEMORIES = errors.New("*ERROR* more than one linear memories in module")
ErrMultipleLinearMemories is returned by (*VM).NewVM when the module has more then one entries in the linear memory space.
var ERR_OUT_BOUNDS = errors.New("*ERROR* (array) index out of bounds")
var ERR_PARAM_COUNT = errors.New("*ERROR* parameters count is not right")
var ERR_STORE_MEMORY = errors.New("*ERROR* failed to storage data to memory")
var ERR_STORE_METHOD = errors.New("*ERROR* failed to store the method name at the memory")
var ERR_STORE_PARAM = errors.New("*ERROR* failed to store the method arguments at the memory")
var ERR_UNSUPPORT_TYPE = errors.New("*ERROR* unsupport type")
var ERR_USED_POS = errors.New("*ERROR* the specified storage pos had been used")
var ErrOutOfBoundsMemoryAccess = errors.New("exec: out of bounds memory access")
ErrOutOfBoundsMemoryAccess is the error value used while trapping the VM when it detects an out of bounds access to the linear memory.
var ErrUnreachable = errors.New("exec: reached unreachable")
ErrUnreachable is the error value used while trapping the VM when an unreachable operator is reached during execution.
Functions ¶
func ByteArrToNum ¶
func ConvertU8Byte ¶
for js
func GetWasmVersion ¶
GetWasmVersion is to get wasm version
func PackStrToByteArray ¶
for js
func RemoveElement ¶
Types ¶
type Authorization ¶
Authorization define the struct of authorization
type EnvFunc ¶
type EnvFunc struct {
// contains filtered or unexported fields
}
EnvFunc defines env for func execution
func (*EnvFunc) GetEnvFuncMap ¶
GetEnvFuncMap retrieve a method from FuncMap
type FuncInfo ¶
type FuncInfo struct {
// contains filtered or unexported fields
}
FuncInfo is function information
type InvalidFunctionIndexError ¶
type InvalidFunctionIndexError int64
InvalidFunctionIndexError is returned by (*VM).ExecCode when the function index provided is invalid.
func (InvalidFunctionIndexError) Error ¶
func (e InvalidFunctionIndexError) Error() string
type InvalidReturnTypeError ¶
type InvalidReturnTypeError int8
InvalidReturnTypeError is returned by (*VM).ExecCode when the module specifies an invalid return type value for the executed function.
func (InvalidReturnTypeError) Error ¶
func (e InvalidReturnTypeError) Error() string
type Message ¶
type Message struct { WasmName string //crx name MethodName string //method name Auth Authorization MethodParam []byte //parameter }
Message define the message info
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM is the execution context for executing WebAssembly bytecode.
func NewVM ¶
NewVM creates a new VM from a given module. If the module defines a start function, it will be executed.
func (*VM) ExecCode ¶
ExecCode calls the function with the given index and arguments. fnIndex should be a valid index into the function index space of the VM's module.
func (*VM) ExecEnvFunc ¶
ExecEnvFunc exec function
func (*VM) GetFuncInfo ¶
GetFuncInfo is to get function information
func (*VM) RecoverContext ¶
func (*VM) SetContract ¶
SetContract set contract param
func (*VM) StorageData ¶
StorageData store data
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
compile
Package compile is used internally by wagon to convert standard structured WebAssembly bytecode into an unstructured form suitable for execution by it's VM.
|
Package compile is used internally by wagon to convert standard structured WebAssembly bytecode into an unstructured form suitable for execution by it's VM. |