func GetSP(mod api.Module) uint32
GetSP gets the stack pointer, which is needed prior to storing a value when in an operation that can trigger a Go event handler.
See https://github.com/golang/go/blob/go1.20/misc/wasm/wasm_exec.js#L210-L213
func NewFunc(name string, goFunc Func) *wasm.HostFunc
func StubFunction(name string) *wasm.HostFunc
StubFunction stubs functions not used in Go's main source tree. This traps (unreachable opcode) to ensure the function is never called.
type Func func(context.Context, api.Module, Stack)
type Stack interface { // Name is the function name being invoked. Name() string Param(i int) uint64 // ParamBytes reads a byte slice, given its memory offset and length (stack // positions i, i+1) ParamBytes(mem api.Memory, i int) []byte // ParamString reads a string, given its memory offset and length (stack // positions i, i+1) ParamString(mem api.Memory, i int) string ParamInt32(i int) int32 ParamUint32(i int) uint32 // Refresh the stack from the current stack pointer (SP). // // Note: This is needed prior to storing a value when in an operation that // can trigger a Go event handler. Refresh(api.Module) SetResult(i int, v uint64) SetResultBool(i int, v bool) SetResultI32(i int, v int32) SetResultI64(i int, v int64) SetResultUint32(i int, v uint32) }
func NewStack(name string, mem api.Memory, sp uint32) Stack