pub enum Instruction<'a> {
Show 54 variants GetArg { nth: usize, }, AddrOf, I32FromChar, I64FromU64, I64FromS64, I32FromU32, I32FromS32, I32FromUsize, I32FromU16, I32FromS16, I32FromU8, I32FromS8, I32FromChar8, I32FromPointer, I32FromConstPointer, I32FromHandle { ty: &'a NamedType, }, I32FromBitflags { ty: &'a NamedType, }, I64FromBitflags { ty: &'a NamedType, }, ListPointerLength, ListFromPointerLength { ty: &'a TypeRef, }, F32FromIf32, F64FromIf64, CallWasm { module: &'a str, name: &'a str, params: &'a [WasmType], results: &'a [WasmType], }, CallInterface { module: &'a str, func: &'a InterfaceFunc, }, S8FromI32, U8FromI32, S16FromI32, U16FromI32, S32FromI32, U32FromI32, S64FromI64, U64FromI64, CharFromI32, Char8FromI32, UsizeFromI32, If32FromF32, If64FromF64, HandleFromI32 { ty: &'a NamedType, }, PointerFromI32 { ty: &'a TypeRef, }, ConstPointerFromI32 { ty: &'a TypeRef, }, BitflagsFromI32 { ty: &'a NamedType, }, BitflagsFromI64 { ty: &'a NamedType, }, ReturnPointerGet { n: usize, }, Load { ty: &'a NamedType, }, Store { ty: &'a NamedType, }, ResultLift, ResultLower { ok: Option<&'a TypeRef>, err: Option<&'a TypeRef>, }, EnumLift { ty: &'a NamedType, }, EnumLower { ty: &'a NamedType, }, TupleLift { amt: usize, }, TupleLower { amt: usize, }, ReuseReturn, Return { amt: usize, }, VariantPayload,
}

Variants

GetArg

Fields

nth: usize

Acquires the specified parameter and places it on the stack. Depending on the context this may refer to wasm parameters or interface types parameters.

AddrOf

Takes the value off the top of the stack and writes it into linear memory. Pushes the address in linear memory as an i32.

I32FromChar

Converts an interface type char value to a 32-bit integer representing the unicode scalar value.

I64FromU64

Converts an interface type u64 value to a wasm i64.

I64FromS64

Converts an interface type s64 value to a wasm i64.

I32FromU32

Converts an interface type u32 value to a wasm i32.

I32FromS32

Converts an interface type s32 value to a wasm i32.

I32FromUsize

Converts a language-specific usize value to a wasm i32.

I32FromU16

Converts an interface type u16 value to a wasm i32.

I32FromS16

Converts an interface type s16 value to a wasm i32.

I32FromU8

Converts an interface type u8 value to a wasm i32.

I32FromS8

Converts an interface type s8 value to a wasm i32.

I32FromChar8

Converts a language-specific C char value to a wasm i32.

I32FromPointer

Converts a language-specific pointer value to a wasm i32.

I32FromConstPointer

Converts a language-specific pointer value to a wasm i32.

I32FromHandle

Fields

ty: &'a NamedType

Converts a language-specific handle value to a wasm i32.

I32FromBitflags

Fields

ty: &'a NamedType

Converts a language-specific record-of-bools to the packed representation as an i32.

I64FromBitflags

Fields

ty: &'a NamedType

Converts a language-specific record-of-bools to the packed representation as an i64.

ListPointerLength

Converts an interface type list into its pointer/length, pushing them both on the stack.

ListFromPointerLength

Fields

ty: &'a TypeRef

Pops two i32 values from the stack and creates a list from them of the specified type. The first operand is the pointer in linear memory to the start of the list and the second operand is the length.

F32FromIf32

Conversion an interface type f32 value to a wasm f32.

This may be a noop for some implementations, but it’s here in case the native language representation of f32 is different than the wasm representation of f32.

F64FromIf64

Conversion an interface type f64 value to a wasm f64.

This may be a noop for some implementations, but it’s here in case the native language representation of f64 is different than the wasm representation of f64.

CallWasm

Fields

module: &'a str
name: &'a str
results: &'a [WasmType]

Represents a call to a raw WebAssembly API. The module/name are provided inline as well as the types if necessary.

CallInterface

Fields

module: &'a str
func: &'a InterfaceFunc

Same as CallWasm, except the dual where an interface is being called rather than a raw wasm function.

S8FromI32

Converts a native wasm i32 to an interface type s8.

This will truncate the upper bits of the i32.

U8FromI32

Converts a native wasm i32 to an interface type u8.

This will truncate the upper bits of the i32.

S16FromI32

Converts a native wasm i32 to an interface type s16.

This will truncate the upper bits of the i32.

U16FromI32

Converts a native wasm i32 to an interface type u16.

This will truncate the upper bits of the i32.

S32FromI32

Converts a native wasm i32 to an interface type s32.

U32FromI32

Converts a native wasm i32 to an interface type u32.

S64FromI64

Converts a native wasm i64 to an interface type s64.

U64FromI64

Converts a native wasm i64 to an interface type u64.

CharFromI32

Converts a native wasm i32 to an interface type char.

It’s safe to assume that the i32 is indeed a valid unicode code point.

Char8FromI32

Converts a native wasm i32 to a language-specific C char.

This will truncate the upper bits of the i32.

UsizeFromI32

Converts a native wasm i32 to a language-specific usize.

If32FromF32

Converts a native wasm f32 to an interface type f32.

If64FromF64

Converts a native wasm f64 to an interface type f64.

HandleFromI32

Fields

ty: &'a NamedType

Converts a native wasm i32 to an interface type handle.

PointerFromI32

Fields

ty: &'a TypeRef

Converts a native wasm i32 to a language-specific pointer.

ConstPointerFromI32

Fields

ty: &'a TypeRef

Converts a native wasm i32 to a language-specific pointer.

BitflagsFromI32

Fields

ty: &'a NamedType

Converts a native wasm i32 to a language-specific record-of-bools.

BitflagsFromI64

Fields

ty: &'a NamedType

Converts a native wasm i64 to a language-specific record-of-bools.

ReturnPointerGet

Fields

n: usize

Acquires the return pointer n and pushes an i32 on the stack.

Implementations of Bindgen may have Bindgen::allocate_space called to reserve space in memory for the result of a computation to get written. This instruction acquires a pointer to the space reserved in allocate_space.

Load

Fields

ty: &'a NamedType

Loads the interface types value from an i32 pointer popped from the stack.

Store

Fields

ty: &'a NamedType

Stores an interface types value into linear memory. The first operand is the value to store and the second operand is the pointer in linear memory to store it at.

ResultLift

Pops a native wasm i32 from the stack, as well as two blocks internally from the code generator.

If the value is 0 then the first “ok” block value should be used. If the value is anything else then the second “err” block value should be used, and the value is used as the error enum.

Note that this is a special instruction matching the current ABI of WASI and intentionally differs from the type-level grammar of interface types results.

ResultLower

Fields

ok: Option<&'a TypeRef>
err: Option<&'a TypeRef>

Pops a native interface value from the stack as well as two blocks internally from the code generator.

A match is performed on the value popped and the corresponding block for ok/err is used depending on value. This pushes a single i32 onto the stack representing the error code for this result.

Note that like ResultLift this is specialized to the current WASI ABI.

EnumLift

Fields

ty: &'a NamedType

Converts a native wasm i32 to an interface type enum value.

It’s guaranteed that the interface type integer value is within range for this enum’s type. Additionally ty is guaranteed to be enum-like as a Variant where all case arms have no associated type with them. The purpose of this instruction is to convert a native wasm integer into the enum type for the interface.

EnumLower

Fields

ty: &'a NamedType

Converts an interface types enum value into a wasm i32.

TupleLift

Fields

amt: usize

Creates a tuple from the top n elements on the stack, pushing the tuple onto the stack.

TupleLower

Fields

amt: usize

Splits a tuple at the top of the stack into its n components, pushing them all onto the stack.

ReuseReturn

This is a special instruction specifically for the original ABI of WASI. The raw return i32 of a function is re-pushed onto the stack for reuse.

Return

Fields

amt: usize

Returns amt values on the stack. This is always the last instruction.

VariantPayload

This is a special instruction used at the entry of blocks used as part of ResultLower, representing that the payload of that variant being matched on should be pushed onto the stack.

Implementations

How many operands does this instruction pop from the stack?

How many results does this instruction push onto the stack?

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.