wag: github.com/tsavola/wag Index | Files | Directories

package wag

import "github.com/tsavola/wag"

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

Package Files

compile.go generate.go

func CompileLibrary Uses

func CompileLibrary(r compile.Reader, imports binding.LibraryImportResolver) (lib compile.Library, err error)

type Config Uses

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 Uses

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 Uses

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

PathSynopsis
bindingPackage binding contains import and export utilities.
bufferPackage buffer implements compile.CodeBuffer and compile.DataBuffer.
cmd/wasysProgram wasys implements a standalone toy compiler and runtime.
compilePackage compile implements a WebAssembly compiler.
compile/event
errorsPackage errors exports common error types without unnecessary dependencies.
internal/code
internal/data
internal/datalayout
internal/errorpanic
internal/errors
internal/gen
internal/gen/atomic
internal/gen/codegen
internal/gen/condition
internal/gen/debug
internal/gen/link
internal/gen/operand
internal/gen/reg
internal/gen/regalloc
internal/gen/rodata
internal/gen/storage
internal/initexpr
internal/isaDocumented interfaces.
internal/isa/arm
internal/isa/arm/in
internal/isa/program
internal/isa/prop
internal/isa/reglayout
internal/isa/x86
internal/isa/x86/in
internal/isa/x86/nonabi
internal/loader
internal/module
internal/obj
internal/reader
internal/section
internal/test/fuzzutil
internal/test/library
internal/test/runner
internal/test/runner/imports
internal/test/sexp
internal/test/wat
internal/typedecode
objectPackage object contains ObjectMapper implementations.
object/abi
object/debugPackage debug contains DebugObjectMapper implementations.
object/debug/dump
object/stackPackage stack provides runtime call stack manipulation functions.
object/stack/stacktrace
sectionPackage section contains binary stream manipulation utilities.
trapPackage trap enumerates trap identifiers.
waPackage wa contains miscellaneous WebAssembly-related things.
wa/opcodePackage opcode enumerates WebAssembly instructions.

Package wag imports 8 packages (graph) and is imported by 1 packages. Updated 2020-11-20. Refresh now. Tools for package owners.