Documentation ¶
Overview ¶
Package binding contains import and export utilities.
Index ¶
- Constants
- func BindImports(mod *compile.Module, reso ImportResolver) (err error)
- func BindLibraryImports(lib *compile.Library, reso LibraryImportResolver) (err error)
- func EntryFunc(mod compile.Module, name string) (funcIndex uint32, err error)
- func IsEntryFuncType(sig wa.FuncType) bool
- func IsStartFuncType(sig wa.FuncType) bool
- type ImportResolver
- type LibraryImportResolver
Constants ¶
const ( VectorIndexLastImport = -5 VectorIndexMemoryAddr = -4 VectorIndexCurrentMemory = -3 VectorIndexGrowMemory = -2 VectorIndexTrapHandler = -1 )
Well-known indexes of the import vector. Import function addresses precede VectorIndexMemoryAddr.
Variables ¶
This section is empty.
Functions ¶
func BindImports ¶
func BindImports(mod *compile.Module, reso ImportResolver) (err error)
func BindLibraryImports ¶
func BindLibraryImports(lib *compile.Library, reso LibraryImportResolver) (err error)
func EntryFunc ¶
EntryFunc looks up an export function which is suitable as an entry point. Its result type must be void or i32, and it must not take any parameters.
func IsEntryFuncType ¶
IsEntryFuncType checks if the signature is suitable for an entry function.
func IsStartFuncType ¶
IsStartFuncType checks if the signature is suitable for a start function.
Types ¶
type ImportResolver ¶
type ImportResolver interface { ResolveFunc(module, field string, sig wa.FuncType) (funcIndex uint32, err error) ResolveGlobal(module, field string, t wa.Type) (init uint64, err error) }
ImportResolver maps symbols to library function indexes and constant values.
ResolveFunc returns a non-negative library function index.
ResolveGlobal returns a bit pattern the interpretation of which depends on the scalar type.
type LibraryImportResolver ¶
type LibraryImportResolver interface {
ResolveFunc(module, field string, sig wa.FuncType) (vectorIndex int, err error)
}
LibraryImportResolver maps symbols to vector indexes.
ResolveFunc returns a negative vector index. The vector is addressed from the end. VectorIndexLastImport is the largest valid index which ResolveFunc can return.