wavm

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: MIT Imports: 5 Imported by: 0

README

wavm-go

Documentation

Index

Constants

View Source
const (
	ExternFunc   = ExternKind(C.WASM_EXTERN_FUNC)
	ExternTable  = ExternKind(C.WASM_EXTERN_TABLE)
	ExternMemory = ExternKind(C.WASM_EXTERN_MEMORY)
	ExternGlobal = ExternKind(C.WASM_EXTERN_GLOBAL)
)
View Source
const (
	CONST = Mutability(C.WASM_CONST)
	VAR   = Mutability(C.WASM_VAR)
)
View Source
const (
	NOTSHARED = Shared(C.WASM_NOTSHARED)
	SHARED    = Shared(C.WASM_SHARED)
)
View Source
const (
	INDEX_I32 = Index(C.WASM_INDEX_I32)
	INDEX_I64 = Index(C.WASM_INDEX_I64)
)
View Source
const (
	I32     = ValKind(C.WASM_I32)
	I64     = ValKind(C.WASM_I64)
	F32     = ValKind(C.WASM_F32)
	F64     = ValKind(C.WASM_F64)
	V128    = ValKind(C.WASM_V128)
	ANYREF  = ValKind(C.WASM_ANYREF)
	FUNCREF = ValKind(C.WASM_FUNCREF)
)
View Source
const (
	WASMMemoryPageSize        = 0x10000
	WASMMemoryPagesMax        = math.MaxUint32
	WASMTableSizeMax          = math.MaxUint32
	LimitsMaxDefault   uint32 = 0xffffffff
)

Variables

View Source
var (
	WASMFuncCall             = C.wasm_func_call
	WASMFuncCallNoCopy       = C.wasm_func_call_no_copy
	WASMFuncCallNoTrap       = C.wasm_func_call_no_trap
	WASMFuncCallNoCopyNoTrap = C.wasm_func_call_no_copy_no_trap
)
View Source
var (
	EMPTY = C.CString("")
)

Functions

func ModuleValidate

func ModuleValidate(binary []byte) bool

func NewGlobal

func NewGlobal(
	compartment *Compartment,
	globalType *GlobalType,
	val *Val,
	debugName string,
) *C.wasm_global_t

func ValGetF32

func ValGetF32(val *Val) float32

func ValGetF64

func ValGetF64(val *Val) float64

func ValGetI32

func ValGetI32(val *Val) int32

func ValGetI64

func ValGetI64(val *Val) int64

Types

type Compartment

type Compartment C.wasm_compartment_t

func NewCompartment

func NewCompartment(engine *Engine, debugName string) *Compartment

func (*Compartment) Clone

func (c *Compartment) Clone() *Compartment

func (*Compartment) Close

func (c *Compartment) Close() error

func (*Compartment) Contains

func (c *Compartment) Contains(ref *Ref) bool

func (*Compartment) Delete

func (c *Compartment) Delete()

func (*Compartment) NewFunc

func (c *Compartment) NewFunc(
	funcType *FuncType,
	callback FuncCallback,
	debugName string,
) *Func

func (*Compartment) NewStore

func (c *Compartment) NewStore(debugName string) *Store

type Config

type Config C.wasm_config_t

func NewConfig

func NewConfig() *Config

func NewConfigAll

func NewConfigAll() *Config

func (*Config) Close

func (c *Config) Close() error

func (*Config) Delete

func (c *Config) Delete()

func (*Config) EnableAll

func (c *Config) EnableAll() *Config

func (*Config) SetAtomics

func (c *Config) SetAtomics(enable bool) *Config

func (*Config) SetBulkMemoryOps

func (c *Config) SetBulkMemoryOps(enable bool) *Config

func (*Config) SetExceptionHandling

func (c *Config) SetExceptionHandling(enable bool) *Config

func (*Config) SetExtendedNameSection

func (c *Config) SetExtendedNameSection(enable bool) *Config

func (*Config) SetImportExportMutableGlobals

func (c *Config) SetImportExportMutableGlobals(enable bool) *Config

func (*Config) SetMultiMemory

func (c *Config) SetMultiMemory(enable bool) *Config

func (*Config) SetMultiValue

func (c *Config) SetMultiValue(enable bool) *Config

func (*Config) SetNonTrappingFloatToInt

func (c *Config) SetNonTrappingFloatToInt(enable bool) *Config

func (*Config) SetReferenceTypes

func (c *Config) SetReferenceTypes(enable bool) *Config

func (*Config) SetSIMD

func (c *Config) SetSIMD(enable bool) *Config

func (*Config) SetSignExtension

func (c *Config) SetSignExtension(enable bool) *Config

type Engine

type Engine C.wasm_engine_t

func NewEngine

func NewEngine() *Engine

func NewEngineWithConfig

func NewEngineWithConfig(config *Config) *Engine

func (*Engine) Close

func (e *Engine) Close() error

func (*Engine) Compile

func (e *Engine) Compile(wasm []byte, out []byte) []byte

func (*Engine) CompileObject

func (e *Engine) CompileObject(wasm []byte, out []byte) []byte

func (*Engine) Delete

func (e *Engine) Delete()

func (*Engine) NewCompartment

func (e *Engine) NewCompartment(debugName string) *Compartment

func (*Engine) NewModule

func (e *Engine) NewModule(binary []byte) *Module

func (*Engine) NewPrecompiledModule

func (e *Engine) NewPrecompiledModule(binary []byte) *Module

type Export

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

typedef struct wasm_export_t

{
	const char* name;
	size_t num_name_bytes;
	wasm_externtype_t* type;
} wasm_export_t;

func (*Export) NameUnsafe

func (w *Export) NameUnsafe() string

type Extern

type Extern C.wasm_extern_t

func (*Extern) AsFunc

func (e *Extern) AsFunc() *Func

func (*Extern) AsGlobal

func (e *Extern) AsGlobal() *Global

func (*Extern) AsKind

func (e *Extern) AsKind() ExternKind

func (*Extern) AsMemory

func (e *Extern) AsMemory() *Memory

func (*Extern) AsTable

func (e *Extern) AsTable() *Table

func (*Extern) Close

func (e *Extern) Close() error

func (*Extern) Delete

func (e *Extern) Delete()

type ExternKind

type ExternKind uint8

func WASMExternKind

func WASMExternKind(extern *Extern) ExternKind

type ExternType

type ExternType C.wasm_externtype_t

func FuncTypeAsExternType

func FuncTypeAsExternType(t *FuncType) *ExternType

func FuncTypeAsExternTypeConst

func FuncTypeAsExternTypeConst(t *FuncType) *ExternType

func GlobalTypeAsExternType

func GlobalTypeAsExternType(t *GlobalType) *ExternType

func GlobalTypeAsExternTypeConst

func GlobalTypeAsExternTypeConst(t *GlobalType) *ExternType

func MemoryTypeAsExternType

func MemoryTypeAsExternType(t *MemoryType) *ExternType

func MemoryTypeAsExternTypeConst

func MemoryTypeAsExternTypeConst(t *MemoryType) *ExternType

func TableTypeAsExternType

func TableTypeAsExternType(t *TableType) *ExternType

func TableTypeAsExternTypeConst

func TableTypeAsExternTypeConst(t *TableType) *ExternType

func WASMExternType

func WASMExternType(extern *Extern) *ExternType

type Foreign

type Foreign C.wasm_foreign_t

func NewForeign

func NewForeign(compartment *Compartment, debugName string) *Foreign

func (*Foreign) Close

func (f *Foreign) Close() error

func (*Foreign) Delete

func (f *Foreign) Delete()

type Frame

type Frame struct {
	Function   *Func
	InstrIndex C.size_t
}

typedef struct wasm_frame_t

{
	wasm_func_t* function;
	size_t instr_index;
} wasm_frame_t;

type Func

type Func C.wasm_func_t

func NewFunc

func NewFunc(
	compartment *Compartment,
	funcType *FuncType,
	callback FuncCallback,
	debugName string) *Func

func (*Func) AsExtern

func (f *Func) AsExtern() *Extern

func (*Func) Call

func (f *Func) Call(store *Store, args *Val, results *Val) *Trap

func (*Func) CallNoCopy

func (f *Func) CallNoCopy(store *Store, args *Val, results *Val) *Trap

func (*Func) CallNoTrap

func (f *Func) CallNoTrap(store *Store, args *Val, results *Val) *Trap

func (*Func) CallUnsafe

func (f *Func) CallUnsafe(store *Store, args *Val, results *Val) *Trap

func (*Func) Close

func (f *Func) Close() error

func (*Func) Delete

func (f *Func) Delete()

func (*Func) ParamArity

func (f *Func) ParamArity() int

func (*Func) ResultArity

func (f *Func) ResultArity() int

func (*Func) Type

func (f *Func) Type() *FuncType

type FuncCallback

type FuncCallback C.wasm_func_callback_t

type FuncType

type FuncType C.wasm_functype_t

func ExternTypeAsFuncType

func ExternTypeAsFuncType(t *ExternType) *FuncType

func ExternTypeAsFuncTypeConst

func ExternTypeAsFuncTypeConst(t *ExternType) *FuncType

func FuncType_0_0

func FuncType_0_0() *FuncType

func FuncType_0_1

func FuncType_0_1(r1 *ValType) *FuncType

func FuncType_0_2

func FuncType_0_2(
	r1 *ValType,
	r2 *ValType,
) *FuncType

func FuncType_1_0

func FuncType_1_0(
	p1 *ValType,
) *FuncType

func FuncType_1_1

func FuncType_1_1(
	p1 *ValType,
	r1 *ValType,
) *FuncType

func FuncType_1_2

func FuncType_1_2(
	p1 *ValType,
	r1 *ValType,
	r2 *ValType,
) *FuncType

func FuncType_2_0

func FuncType_2_0(
	p1 *ValType,
	p2 *ValType,
) *FuncType

func FuncType_2_1

func FuncType_2_1(
	p1 *ValType,
	p2 *ValType,
	r1 *ValType,
) *FuncType

func FuncType_2_2

func FuncType_2_2(
	p1 *ValType,
	p2 *ValType,
	r1 *ValType,
	r2 *ValType,
) *FuncType

func FuncType_3_0

func FuncType_3_0(
	p1 *ValType,
	p2 *ValType,
	p3 *ValType,
) *FuncType

func FuncType_3_1

func FuncType_3_1(
	p1 *ValType,
	p2 *ValType,
	p3 *ValType,
	r1 *ValType,
) *FuncType

func FuncType_3_2

func FuncType_3_2(
	p1 *ValType,
	p2 *ValType,
	p3 *ValType,
	r1 *ValType,
	r2 *ValType,
) *FuncType

func FuncType_4_1

func FuncType_4_1(
	p1 *ValType,
	p2 *ValType,
	p3 *ValType,
	p4 *ValType,
	r1 *ValType,
) *FuncType

func NewFuncType

func NewFuncType(params []*ValType, results []*ValType) *FuncType

func (*FuncType) Close

func (f *FuncType) Close() error

func (*FuncType) Delete

func (f *FuncType) Delete()

func (*FuncType) NumParams

func (f *FuncType) NumParams() int

func (*FuncType) NumResults

func (f *FuncType) NumResults() int

func (*FuncType) Param

func (f *FuncType) Param(index int) *ValType

func (*FuncType) Result

func (f *FuncType) Result(index int) *ValType

type Global

type Global C.wasm_global_t

func (*Global) AsExtern

func (g *Global) AsExtern() *Extern

func (*Global) Close

func (g *Global) Close() error

func (*Global) Delete

func (g *Global) Delete()

func (*Global) Get

func (g *Global) Get(store *Store) *Val

func (*Global) Type

func (g *Global) Type() *GlobalType

type GlobalType

type GlobalType C.wasm_globaltype_t

func ExternTypeAsGlobalType

func ExternTypeAsGlobalType(t *ExternType) *GlobalType

func ExternTypeAsGlobalTypeConst

func ExternTypeAsGlobalTypeConst(t *ExternType) *GlobalType

func NewGlobalType

func NewGlobalType(valType *ValType, mutability Mutability) *GlobalType

func (*GlobalType) Close

func (g *GlobalType) Close() error

func (*GlobalType) Content

func (g *GlobalType) Content() *ValType

func (*GlobalType) Delete

func (g *GlobalType) Delete()

func (*GlobalType) Mutability

func (g *GlobalType) Mutability() Mutability

type Import

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

typedef struct wasm_import_t

{
	const char* module;
	size_t num_module_bytes;
	const char* name;
	size_t num_name_bytes;
	wasm_externtype_t* type;
} wasm_import_t;

func (*Import) Module

func (w *Import) Module() string

func (*Import) ModuleUnsafe

func (w *Import) ModuleUnsafe() string

func (*Import) Name

func (w *Import) Name() string

func (*Import) NameUnsafe

func (w *Import) NameUnsafe() string

type Index

type Index uint8

type Instance

type Instance C.wasm_instance_t

func NewInstance

func NewInstance(
	store *Store,
	module *Module,
	imports []*Extern,
	outTrap **Trap,
	debugName string,
) *Instance

func (*Instance) Close

func (inst *Instance) Close() error

func (*Instance) Delete

func (inst *Instance) Delete()

func (*Instance) Export

func (inst *Instance) Export(index int) *Extern

func (*Instance) Exports

func (inst *Instance) Exports(exports []*Extern) []*Extern

func (*Instance) NumExports

func (inst *Instance) NumExports() int

type Limits

type Limits struct {
	Min uint32
	Max uint32
}

typedef struct wasm_limits_t

{
	uint32_t min;
	uint32_t max;
} wasm_limits_t;

type Memory

type Memory C.wasm_memory_t

func (*Memory) AsExtern

func (m *Memory) AsExtern() *Extern

func (*Memory) Close

func (m *Memory) Close() error

func (*Memory) Data

func (m *Memory) Data() *C.char

func (*Memory) Delete

func (m *Memory) Delete()

func (*Memory) Grow

func (m *Memory) Grow(delta int) (bool, int)

func (*Memory) Pages

func (m *Memory) Pages() int

func (*Memory) Size

func (m *Memory) Size() int

type MemoryType

type MemoryType C.wasm_memorytype_t

func ExternTypeAsMemoryType

func ExternTypeAsMemoryType(t *ExternType) *MemoryType

func ExternTypeAsMemoryTypeConst

func ExternTypeAsMemoryTypeConst(t *ExternType) *MemoryType

func NewMemoryType

func NewMemoryType(limits *Limits, shared Shared, index int) *MemoryType

func (*MemoryType) Close

func (m *MemoryType) Close() error

func (*MemoryType) Delete

func (m *MemoryType) Delete()

func (*MemoryType) Limits

func (m *MemoryType) Limits() *Limits

func (*MemoryType) Shared

func (m *MemoryType) Shared() Shared

type Module

type Module C.wasm_module_t

func NewModule

func NewModule(engine *Engine, binary []byte) *Module

func NewModulePrecompiled

func NewModulePrecompiled(engine *Engine, binary []byte) *Module

func NewModuleText

func NewModuleText(engine *Engine, wast string) *Module

func (*Module) Close

func (m *Module) Close() error

func (*Module) Delete

func (m *Module) Delete()

func (*Module) Export

func (m *Module) Export(index int) Export

func (*Module) Exports

func (m *Module) Exports(exports []Export) []Export

func (*Module) Import

func (m *Module) Import(index int) Import

func (*Module) Imports

func (m *Module) Imports(imports []Import) []Import

func (*Module) NumExports

func (m *Module) NumExports() int

func (*Module) NumImports

func (m *Module) NumImports() int

func (*Module) Print

func (m *Module) Print() string

func (*Module) PrintTo

func (m *Module) PrintTo(b []byte) []byte

type Mutability

type Mutability uint8

type Ref

type Ref C.wasm_ref_t

type Shared

type Shared uint8

type Store

type Store C.wasm_store_t

func NewStore

func NewStore(compartment *Compartment, debugName string) *Store

func (*Store) Call

func (s *Store) Call(fn *Func, args *Val, results *Val) *Trap

func (*Store) Close

func (s *Store) Close() error

func (*Store) Delete

func (s *Store) Delete()

func (*Store) NewInstance

func (s *Store) NewInstance(
	module *Module,
	imports []*Extern,
	outTrap **Trap,
	debugName string,
) *Instance

type Table

type Table C.wasm_table_t

func NewTable

func NewTable(
	compartment *Compartment,
	tableType *TableType,
	init *Ref,
	debugName string) *Table

func (*Table) AsExtern

func (t *Table) AsExtern() *Extern

func (*Table) Close

func (t *Table) Close() error

func (*Table) Delete

func (t *Table) Delete()

func (*Table) Get

func (t *Table) Get(index int) *Ref

func (*Table) Grow

func (t *Table) Grow(delta int, init *Ref) (bool, int)

func (*Table) Set

func (t *Table) Set(index int, value *Ref) bool

func (*Table) Size

func (t *Table) Size() int

func (*Table) Type

func (t *Table) Type() *TableType

type TableType

type TableType C.wasm_tabletype_t

func ExternTypeAsTableType

func ExternTypeAsTableType(t *ExternType) *TableType

func ExternTypeAsTableTypeConst

func ExternTypeAsTableTypeConst(t *ExternType) *TableType

func NewTableType

func NewTableType(t *ValType, limits *Limits, shared Shared, index int) *TableType

func (*TableType) Close

func (t *TableType) Close() error

func (*TableType) Delete

func (t *TableType) Delete()

func (*TableType) Element

func (t *TableType) Element() *ValType

func (*TableType) Limits

func (t *TableType) Limits() *Limits

func (*TableType) Shared

func (t *TableType) Shared() Shared

type Trap

type Trap C.wasm_trap_t

func NewTrap

func NewTrap(compartment *Compartment, message string) *Trap

func (*Trap) Close

func (t *Trap) Close() error

func (*Trap) Delete

func (t *Trap) Delete()

func (*Trap) Error

func (t *Trap) Error() string

func (*Trap) Message

func (t *Trap) Message(b []byte) []byte

func (*Trap) StackFrame

func (t *Trap) StackFrame(index int, outFrame *Frame)

func (*Trap) StackNumFrames

func (t *Trap) StackNumFrames() int

func (*Trap) String

func (t *Trap) String() string

type V128T

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

// NOTE: not 128-bit aligned typedef struct wasm_v128_t

{
	uint64_t u64x2[2];
} wasm_v128_t;

type Val

type Val C.wasm_val_t

typedef union wasm_val_t

{
	int32_t i32;
	int64_t i64;
	wasm_float32_t f32;
	wasm_float64_t f64;
	wasm_v128_t v128;
	wasm_ref_t* ref;
} wasm_val_t;

func ValF32

func ValF32(value float32) Val

func ValF64

func ValF64(value float64) Val

func ValI32

func ValI32(value int32) Val

func ValI64

func ValI64(value int64) Val

func (*Val) F32

func (v *Val) F32() float32

func (*Val) F64

func (v *Val) F64() float64

func (*Val) I32

func (v *Val) I32() int32

func (*Val) I64

func (v *Val) I64() int64

func (*Val) Ref32

func (v *Val) Ref32() uint32

func (*Val) Ref64

func (v *Val) Ref64() uint64

func (*Val) SetF32

func (v *Val) SetF32(value float32)

func (*Val) SetF64

func (v *Val) SetF64(value float64)

func (*Val) SetI32

func (v *Val) SetI32(value int32)

func (*Val) SetI64

func (v *Val) SetI64(value int64)

func (*Val) SetRef32

func (v *Val) SetRef32(value uint32)

func (*Val) SetRef64

func (v *Val) SetRef64(value uint64)

func (*Val) SetV128

func (v *Val) SetV128(value V128T)

func (*Val) V128

func (v *Val) V128() V128T

type ValKind

type ValKind uint8

func (ValKind) IsNum

func (k ValKind) IsNum() bool

func (ValKind) IsRef

func (k ValKind) IsRef() bool

type ValType

type ValType C.wasm_valtype_t

func NewValType

func NewValType(kind ValKind) *ValType

func ValTypeAnyref

func ValTypeAnyref() *ValType

func ValTypeF32

func ValTypeF32() *ValType

func ValTypeF64

func ValTypeF64() *ValType

func ValTypeFuncref

func ValTypeFuncref() *ValType

func ValTypeI32

func ValTypeI32() *ValType

func ValTypeI64

func ValTypeI64() *ValType

func ValTypeV128

func ValTypeV128() *ValType

func (*ValType) Delete

func (v *ValType) Delete()

func (*ValType) IsNum

func (t *ValType) IsNum() bool

func (*ValType) IsRef

func (t *ValType) IsRef() bool

func (*ValType) Kind

func (v *ValType) Kind() ValKind

Directories

Path Synopsis
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
lib
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
lib/darwin_amd64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
lib/darwin_arm64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
lib/linux_amd64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
cgo
cmd command

Jump to

Keyboard shortcuts

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