Documentation ¶
Overview ¶
Package wag provides a high-level WebAssembly compiler API.
See the Compile function's source code for an example of how to use the low-level compiler APIs (implemented in subpackages).
Errors ¶
ModuleError and ResourceLimit error types are accessible via errors subpackage. Such errors may be returned by compilation and other parsing functions. Other types of errors indicate either a read error or an internal compiler error. (Unexpected EOF is a ModuleError which wraps io.ErrUnexpectedEOF.)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileLibrary ¶ added in v0.32.0
Types ¶
type Config ¶ added in v0.32.0
type Config struct { ImportResolver binding.ImportResolver // Imports are mapped to the library by default. Text compile.CodeBuffer // Defaults to dynamically sized buffer. GlobalsMemory compile.DataBuffer // Defaults to dynamically sized buffer. MemoryAlignment int // Defaults to minimal valid alignment. Entry string // No entry function by default. }
Config for a single compiler invocation. Zero values are replaced with effective defaults during compilation.
type Object ¶ added in v0.32.0
type Object struct { FuncTypes []wa.FuncType // Signatures for debug output. InitialMemorySize int // Current memory allocation. MemorySizeLimit int // -1 if not limited. Text []byte // Machine code and read-only data. debug.InsnMap // Stack unwinding and debug metadata. MemoryOffset int // Threshold between globals and memory. GlobalsMemory []byte // Global values and memory contents. StackFrame []byte // Start and entry function addresses. Names section.NameSection // Symbols for debug output. Debug *dwarf.Data // More detailed debug information. }
Object code with debug information. The fields are roughly in order of appearance during compilation.
Executing the code requires a platform-specific mechanism. It is not supported by this package, but see the compile subpackage for information.
func Compile ¶ added in v0.32.0
func Compile(objectConfig *Config, r compile.Reader, lib compile.Library) (object *Object, err error)
Compile a WebAssembly binary module into machine code. The Object is constructed incrementally so that populated fields may be inspected on error.
See the source code for examples of how to use the lower-level APIs.
Directories ¶
Path | Synopsis |
---|---|
Package binary implements WebAssembly integer decoding.
|
Package binary implements WebAssembly integer decoding. |
Package binding contains import and export utilities.
|
Package binding contains import and export utilities. |
Package buffer implements compile.CodeBuffer and compile.DataBuffer.
|
Package buffer implements compile.CodeBuffer and compile.DataBuffer. |
Package compile implements a WebAssembly compiler.
|
Package compile implements a WebAssembly compiler. |
Package errors exports common error types without unnecessary dependencies.
|
Package errors exports common error types without unnecessary dependencies. |
errordata
Package errordata helps with error serialization.
|
Package errordata helps with error serialization. |
isa
Documented interfaces.
|
Documented interfaces. |
Package object contains ObjectMapper implementations.
|
Package object contains ObjectMapper implementations. |
debug
Package debug contains DebugObjectMapper implementations.
|
Package debug contains DebugObjectMapper implementations. |
stack
Package stack provides runtime call stack manipulation functions.
|
Package stack provides runtime call stack manipulation functions. |
Package section contains binary stream manipulation utilities.
|
Package section contains binary stream manipulation utilities. |
testsuite
module
|
|
Package trap enumerates trap identifiers.
|
Package trap enumerates trap identifiers. |
Package wa contains miscellaneous WebAssembly-related things.
|
Package wa contains miscellaneous WebAssembly-related things. |
opcode
Package opcode enumerates WebAssembly instructions.
|
Package opcode enumerates WebAssembly instructions. |