go-ext-wasm: github.com/wasmerio/go-ext-wasm/wasmer Index | Files | Directories

package wasmer

import "github.com/wasmerio/go-ext-wasm/wasmer"

Package wasmer is a Go library to run WebAssembly binaries.

Index

Package Files

cgo.go engine.go error.go exports.go exporttype.go extern.go externtype.go function.go functiontype.go global.go globaltype.go import_object.go importtype.go instance.go limits.go memory.go memorytype.go module.go name.go pages.go store.go table.go tabletype.go trap.go value.go valuetype.go wasi.go wasmer.go wat.go

Constants

const (
    FUNCTION = ExternKind(C.WASM_EXTERN_FUNC)
    GLOBAL   = ExternKind(C.WASM_EXTERN_GLOBAL)
    TABLE    = ExternKind(C.WASM_EXTERN_TABLE)
    MEMORY   = ExternKind(C.WASM_EXTERN_MEMORY)
)
const (
    IMMUTABLE = GlobalMutability(C.WASM_CONST)
    MUTABLE   = GlobalMutability(C.WASM_VAR)
)
const (
    I32     = ValueKind(C.WASM_I32)
    I64     = ValueKind(C.WASM_I64)
    F32     = ValueKind(C.WASM_F32)
    F64     = ValueKind(C.WASM_F64)
    AnyRef  = ValueKind(C.WASM_ANYREF)
    FuncRef = ValueKind(C.WASM_FUNCREF)
)
const LimitMaxUnbound = uint32(C.wasm_limits_max_default)
const WasmMaxPages = uint(0x10000)
const WasmMinPages = uint(0x100)
const WasmPageSize = uint(0x10000)

func ValidateModule Uses

func ValidateModule(store *Store, bytes []byte) error

func Wat2Wasm Uses

func Wat2Wasm(wat string) ([]byte, error)

type Engine Uses

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

func NewEngine Uses

func NewEngine() *Engine

func NewJITEngine Uses

func NewJITEngine() *Engine

func NewNativeEngine Uses

func NewNativeEngine() *Engine

type Error Uses

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

func (*Error) Error Uses

func (error *Error) Error() string

type ExportType Uses

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

func NewExportType Uses

func NewExportType(name string, ty IntoExternType) *ExportType

func (*ExportType) Name Uses

func (self *ExportType) Name() string

func (*ExportType) Type Uses

func (self *ExportType) Type() *ExternType

type Exports Uses

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

func (*Exports) Get Uses

func (self *Exports) Get(name string) (*Extern, error)

func (*Exports) GetFunction Uses

func (self *Exports) GetFunction(name string) (func(...interface{}) (interface{}, error), error)

func (*Exports) GetGlobal Uses

func (self *Exports) GetGlobal(name string) (*Global, error)

func (*Exports) GetMemory Uses

func (self *Exports) GetMemory(name string) (*Memory, error)

func (*Exports) GetRawFunction Uses

func (self *Exports) GetRawFunction(name string) (*Function, error)

func (*Exports) GetTable Uses

func (self *Exports) GetTable(name string) (*Table, error)

type Extern Uses

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

func (*Extern) IntoExtern Uses

func (self *Extern) IntoExtern() *Extern

func (*Extern) IntoFunction Uses

func (self *Extern) IntoFunction() *Function

func (*Extern) IntoGlobal Uses

func (self *Extern) IntoGlobal() *Global

func (*Extern) IntoMemory Uses

func (self *Extern) IntoMemory() *Memory

func (*Extern) IntoTable Uses

func (self *Extern) IntoTable() *Table

func (*Extern) Kind Uses

func (self *Extern) Kind() ExternKind

func (*Extern) Type Uses

func (self *Extern) Type() *ExternType

type ExternKind Uses

type ExternKind C.wasm_externkind_t

func (ExternKind) String Uses

func (self ExternKind) String() string

type ExternType Uses

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

func (*ExternType) IntoFunctionType Uses

func (self *ExternType) IntoFunctionType() *FunctionType

func (*ExternType) IntoGlobalType Uses

func (self *ExternType) IntoGlobalType() *GlobalType

func (*ExternType) IntoMemoryType Uses

func (self *ExternType) IntoMemoryType() *MemoryType

func (*ExternType) IntoTableType Uses

func (self *ExternType) IntoTableType() *TableType

func (*ExternType) Kind Uses

func (self *ExternType) Kind() ExternKind

type Frame Uses

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

func (*Frame) FunctionIndex Uses

func (self *Frame) FunctionIndex() uint32

func (*Frame) FunctionOffset Uses

func (self *Frame) FunctionOffset() uint

func (*Frame) Instance Uses

func (self *Frame) Instance()

func (*Frame) ModuleOffset Uses

func (self *Frame) ModuleOffset() uint

type Function Uses

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

func NewFunction Uses

func NewFunction(store *Store, ty *FunctionType, function func([]Value) ([]Value, error)) *Function

func (*Function) Call Uses

func (self *Function) Call(parameters ...interface{}) (interface{}, error)

func (*Function) IntoExtern Uses

func (self *Function) IntoExtern() *Extern

func (*Function) Native Uses

func (self *Function) Native() func(...interface{}) (interface{}, error)

func (*Function) ParameterArity Uses

func (self *Function) ParameterArity() uint

func (*Function) ResultArity Uses

func (self *Function) ResultArity() uint

func (*Function) Type Uses

func (self *Function) Type() *FunctionType

type FunctionEnvironment Uses

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

type FunctionType Uses

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

func NewFunctionType Uses

func NewFunctionType(params []*ValueType, results []*ValueType) *FunctionType

func (*FunctionType) IntoExternType Uses

func (self *FunctionType) IntoExternType() *ExternType

func (*FunctionType) Params Uses

func (self *FunctionType) Params() []*ValueType

func (*FunctionType) Results Uses

func (self *FunctionType) Results() []*ValueType

type Global Uses

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

func NewGlobal Uses

func NewGlobal(store *Store, ty *GlobalType, value Value) *Global

func (*Global) Get Uses

func (self *Global) Get() (interface{}, error)

func (*Global) IntoExtern Uses

func (self *Global) IntoExtern() *Extern

func (*Global) Set Uses

func (self *Global) Set(value interface{}, kind ValueKind) error

func (*Global) Type Uses

func (self *Global) Type() *GlobalType

type GlobalMutability Uses

type GlobalMutability C.wasm_mutability_t

func (GlobalMutability) String Uses

func (self GlobalMutability) String() string

type GlobalType Uses

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

func NewGlobalType Uses

func NewGlobalType(valueType *ValueType, mutability GlobalMutability) *GlobalType

func (*GlobalType) IntoExternType Uses

func (self *GlobalType) IntoExternType() *ExternType

func (*GlobalType) Mutability Uses

func (self *GlobalType) Mutability() GlobalMutability

func (*GlobalType) ValueType Uses

func (self *GlobalType) ValueType() *ValueType

type ImportObject Uses

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

func NewImportObject Uses

func NewImportObject() *ImportObject

func (*ImportObject) ContainsNamespace Uses

func (self *ImportObject) ContainsNamespace(name string) bool

func (*ImportObject) Register Uses

func (self *ImportObject) Register(namespaceName string, namespace map[string]IntoExtern)

type ImportType Uses

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

func NewImportType Uses

func NewImportType(module string, name string, ty IntoExternType) *ImportType

func (*ImportType) Module Uses

func (self *ImportType) Module() string

func (*ImportType) Name Uses

func (self *ImportType) Name() string

func (*ImportType) Type Uses

func (self *ImportType) Type() *ExternType

type Instance Uses

type Instance struct {
    Exports *Exports
    // contains filtered or unexported fields
}

func NewInstance Uses

func NewInstance(module *Module, imports *ImportObject) (*Instance, error)

type IntoExtern Uses

type IntoExtern interface {
    IntoExtern() *Extern
}

type IntoExternType Uses

type IntoExternType interface {
    IntoExternType() *ExternType
}

type Limits Uses

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

func NewLimits Uses

func NewLimits(minimum uint32, maximum uint32) (*Limits, error)

func (*Limits) Maximum Uses

func (self *Limits) Maximum() uint32

func (*Limits) Minimum Uses

func (self *Limits) Minimum() uint32

type Memory Uses

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

func NewMemory Uses

func NewMemory(store *Store, ty *MemoryType) *Memory

func (*Memory) Data Uses

func (self *Memory) Data() []byte

func (*Memory) DataSize Uses

func (self *Memory) DataSize() uint

func (*Memory) Grow Uses

func (self *Memory) Grow(delta Pages) bool

func (*Memory) IntoExtern Uses

func (self *Memory) IntoExtern() *Extern

func (*Memory) Size Uses

func (self *Memory) Size() Pages

func (*Memory) Type Uses

func (self *Memory) Type() *MemoryType

type MemoryType Uses

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

func NewMemoryType Uses

func NewMemoryType(limits *Limits) *MemoryType

func (*MemoryType) IntoExternType Uses

func (self *MemoryType) IntoExternType() *ExternType

func (*MemoryType) Limits Uses

func (self *MemoryType) Limits() *Limits

type Module Uses

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

Module contains stateless WebAssembly code that has already been compiled and can be instantiated multiple times.

Creates a new WebAssembly Module given the configuration in the store.

If the provided bytes are not WebAssembly-like (start with `b"\0asm"`), this function will try to to convert the bytes assuming they correspond to the WebAssembly text format.

## Security

Before the code is compiled, it will be validated using the store features.

func DeserializeModule Uses

func DeserializeModule(store *Store, bytes []byte) (*Module, error)

func NewModule Uses

func NewModule(store *Store, bytes []byte) (*Module, error)

func (*Module) Exports Uses

func (self *Module) Exports() []*ExportType

func (*Module) Imports Uses

func (self *Module) Imports() []*ImportType

func (*Module) Name Uses

func (self *Module) Name() string

func (*Module) Serialize Uses

func (self *Module) Serialize() ([]byte, error)

type Pages Uses

type Pages C.wasm_memory_pages_t

func (*Pages) ToBytes Uses

func (self *Pages) ToBytes() uint

func (*Pages) ToUint32 Uses

func (self *Pages) ToUint32() uint32

type Store Uses

type Store struct {
    Engine *Engine
    // contains filtered or unexported fields
}

Store represents all global state that can be manipulated by WebAssembly programs. It consists of the runtime representation of all instances of functions, tables, memories, and globals that have been allocated during the lifetime of the abstract machine.

The `Store` holds the engine (that is —amongst many things— used to compile the Wasm bytes into a valid module artifact), in addition to the [`Tunables`] (that are used to create the memories, tables and globals).

Spec: https://webassembly.github.io/spec/core/exec/runtime.html#store

func NewStore Uses

func NewStore(engine *Engine) *Store

type Table Uses

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

func (*Table) IntoExtern Uses

func (self *Table) IntoExtern() *Extern

func (*Table) Size Uses

func (self *Table) Size() TableSize

type TableSize Uses

type TableSize C.wasm_table_size_t

func (*TableSize) ToUint32 Uses

func (self *TableSize) ToUint32() uint32

type TableType Uses

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

func NewTableType Uses

func NewTableType(valueType *ValueType, limits *Limits) *TableType

func (*TableType) IntoExternType Uses

func (self *TableType) IntoExternType() *ExternType

func (*TableType) Limits Uses

func (self *TableType) Limits() *Limits

func (*TableType) ValueType Uses

func (self *TableType) ValueType() *ValueType

type Trap Uses

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

func NewTrap Uses

func NewTrap(store *Store, message string) *Trap

func (*Trap) Message Uses

func (self *Trap) Message() string

func (*Trap) Origin Uses

func (self *Trap) Origin() *Frame

func (*Trap) Trace Uses

func (self *Trap) Trace() *trace

type TrapError Uses

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

func (*TrapError) Error Uses

func (self *TrapError) Error() string

func (*TrapError) Origin Uses

func (self *TrapError) Origin() *Frame

func (*TrapError) Trace Uses

func (self *TrapError) Trace() []*Frame

type Value Uses

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

func NewF32 Uses

func NewF32(value interface{}) Value

func NewF64 Uses

func NewF64(value interface{}) Value

func NewI32 Uses

func NewI32(value interface{}) Value

func NewI64 Uses

func NewI64(value interface{}) Value

func NewValue Uses

func NewValue(value interface{}, kind ValueKind) Value

func (*Value) F32 Uses

func (self *Value) F32() float32

func (*Value) F64 Uses

func (self *Value) F64() float64

func (*Value) I32 Uses

func (self *Value) I32() int32

func (*Value) I64 Uses

func (self *Value) I64() int64

func (*Value) Kind Uses

func (self *Value) Kind() ValueKind

func (*Value) Unwrap Uses

func (self *Value) Unwrap() interface{}

type ValueKind Uses

type ValueKind C.wasm_valkind_t

func (ValueKind) IsNumber Uses

func (self ValueKind) IsNumber() bool

func (ValueKind) IsReference Uses

func (self ValueKind) IsReference() bool

func (ValueKind) String Uses

func (self ValueKind) String() string

type ValueType Uses

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

func NewValueType Uses

func NewValueType(kind ValueKind) *ValueType

func NewValueTypes Uses

func NewValueTypes(kinds ...ValueKind) []*ValueType

func (*ValueType) Kind Uses

func (self *ValueType) Kind() ValueKind

type WasiEnvironment Uses

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

type WasiStateBuilder Uses

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

func NewWasiStateBuilder Uses

func NewWasiStateBuilder(programName string) *WasiStateBuilder

Directories

PathSynopsis
test

Package wasmer imports 6 packages (graph) and is imported by 6 packages. Updated 2020-12-03. Refresh now. Tools for package owners.