Skip to main content

Crate walrus

Crate walrus 

Source
Expand description

The walrus WebAssembly transformations library.

§GC Proposal Support

Walrus supports the WebAssembly GC proposal, including struct types, array types, subtyping, recursive type groups, and the full set of GC instructions.

§Creating GC types

Use ModuleTypes::add_struct, ModuleTypes::add_array, and ModuleTypes::add_composite to create GC types programmatically. For mutually-recursive types, use ModuleTypes::add_rec_group which pre-allocates type IDs for forward references.

§GC instructions

All GC instructions (struct.new, array.get, ref.cast, etc.) are available as builder methods on InstrSeqBuilder. See the ir module for the full list of instruction variants.

Re-exports§

pub use crate::ir::Local;
pub use crate::ir::LocalId;
pub use crate::ir::InstrLocId;

Modules§

dot
Utilities for emitting GraphViz dot files.
ir
Intermediate representation for instructions.
passes
Passes over whole modules or individual functions.

Structs§

ArrayType
An array type, consisting of a single field type for all elements.
CodeTransform
Code transformation records, which is used to transform DWARF debug entries.
Data
A data segment.
Element
A passive segment which contains a list of functions
Export
A named item exported from the wasm.
FieldType
A field type for struct and array fields.
Function
A wasm function.
FunctionBuilder
Build instances of LocalFunction.
FunctionType
A function type, consisting of parameter and result types.
Global
A wasm global.
IdsToIndices
Maps our high-level identifiers to the raw indices they end up emitted at.
Import
A named item imported into the wasm.
ImportedFunction
An externally defined, imported function.
IndicesToIds
Maps from old indices in the original Wasm binary to walrus IDs.
InstrSeqBuilder
A builder returned by instruction sequence-construction methods to build up instructions within a block/loop/if-else over time.
LocalFunction
A function defined locally within the wasm module.
Memory
A memory in the wasm.
Module
A wasm module.
ModuleConfig
Configuration for a Module which currently affects parsing.
ModuleCustomSections
A collection of custom sections inside a Wasm module.
ModuleData
All passive data sections of a wasm module, used to initialize memories via various instructions.
ModuleDebugData
The DWARF debug section in input WebAssembly binary.
ModuleElements
All element segments of a wasm module, used to initialize anyfunc tables, used as function pointers.
ModuleExports
The set of exports in a module.
ModuleFunctions
The set of functions within a module.
ModuleGlobals
The set of globals in each function in this module.
ModuleImports
The set of imports in a module.
ModuleLocals
The set of locals in each function in this module.
ModuleMemories
The set of memories in this module.
ModuleProducers
Representation of the wasm custom section producers
ModuleTables
The set of tables in this module.
ModuleTags
All tags in a WebAssembly module.
ModuleTypes
The set of de-duplicated types within a module.
RawCustomSection
A raw, unparsed custom section.
RecGroup
A recursive type group.
RefType
A reference type.
StructType
A struct type, consisting of a sequence of field types.
Table
A table in the wasm.
Tag
A tag in a WebAssembly module, used for exception handling.
Type
A WebAssembly type definition.
TypedCustomSectionId
The id of a CustomSection instance with a statically-known type in a ModuleCustomSections.
UntypedCustomSectionId
The id of some CustomSection instance in a ModuleCustomSections.

Enums§

AbstractHeapType
Abstract heap types for GC reference types.
CompositeType
A composite type that can be a function, struct, or array.
ConstExpr
A constant which is produced in WebAssembly, typically used in global initializers or element/data offsets.
ConstOp
Operations allowed in extended constant expressions
DataKind
The kind of data segment: passive or active.
ElementItems
Represents the items of an element segment.
ElementKind
The kind of element segment.
ErrorKind
A leaf wasm error type.
ExportItem
An exported item.
FunctionKind
The local- or external-specific bits of a function.
GlobalKind
The different kinds of globals a wasm module can have
HeapType
A heap type for GC reference types.
ImportKind
An imported item.
StorageType
A packed storage type for struct and array fields.
TagKind
The kind of tag.
ValType
A value type.

Traits§

CustomSection
A trait for implementing custom sections.
CustomSectionId
A common trait for custom section identifiers.

Type Aliases§

DataId
A passive element segment identifier
ElementId
A passive element segment identifier
ExportId
The id of an export.
FuncParams
Parameter(s) to a function
FuncResults
Result(s) of a given function
FunctionId
A function identifier.
GlobalId
The id of a global.
ImportId
The id of an import.
MemoryId
The id of a memory.
RecGroupId
An identifier for recursive type groups.
Result
Either Ok(T) or Err(failure::Error). Result<T, Error>
TableId
The id of a table.
TagId
The id of a tag.
TypeId
An identifier for types.