goarch

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package goarch isolates code from runtime.GOARCH=wasm in a way that avoids cyclic dependencies when re-used from other packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSP

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

func NewFunc(name string, goFunc Func) *wasm.HostFunc

func StubFunction

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.

Types

type Func

type Func func(context.Context, api.Module, Stack)

type 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

func NewStack(name string, mem api.Memory, sp uint32) Stack

Jump to

Keyboard shortcuts

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