Documentation ¶
Index ¶
Constants ¶
const FunctionNotifyMemoryGrowth = "emscripten_notify_memory_growth"
const FunctionThrowLongjmp = "_emscripten_throw_longjmp"
Emscripten uses this host method to throw an error that can then be caught in the dynamic invoke functions. Emscripten uses this to allow for setjmp/longjmp support. When this error is seen in the invoke handler, it ignores the error and does not act on it.
const InvokePrefix = "invoke_"
InvokePrefix is the naming convention of Emscripten dynamic functions.
All `invoke_` functions have an initial "index" parameter of api.ValueTypeI32. This is the index of the desired funcref in the only table in the module. The type of the funcref is via naming convention. The first character after `invoke_` decides the result type: 'v' for no result or 'i' for api.ValueTypeI32. Any count of 'i' following that are api.ValueTypeI32 parameters.
For example, the function `invoke_iiiii` signature has five parameters, but also five i's. The five 'i's mean there are four parameters
(import "env" "invoke_iiiii" (func $invoke_iiiii (param i32 i32 i32 i32 i32) (result i32))))
So, the above function if invoked `invoke_iiiii(1234, 1, 2, 3, 4)` would look up the funcref at table index 1234, which has a type i32i32i3232_i32 and invoke it with the remaining parameters.
Variables ¶
var ( ThrowLongjmpError = errors.New("_emscripten_throw_longjmp") ThrowLongjmp = &wasm.HostFunc{ ExportName: FunctionThrowLongjmp, Name: FunctionThrowLongjmp, ParamTypes: []wasm.ValueType{}, ParamNames: []string{}, Code: wasm.Code{GoFunc: api.GoModuleFunc(func(context.Context, api.Module, []uint64) { panic(ThrowLongjmpError) })}, } )
var NotifyMemoryGrowth = &wasm.HostFunc{ ExportName: FunctionNotifyMemoryGrowth, Name: FunctionNotifyMemoryGrowth, ParamTypes: []wasm.ValueType{wasm.ValueTypeI32}, ParamNames: []string{"memory_index"}, Code: wasm.Code{GoFunc: api.GoModuleFunc(func(context.Context, api.Module, []uint64) {})}, }
Functions ¶
Types ¶
type InvokeFunc ¶
type InvokeFunc struct {
*wasm.FunctionType
}