Enum witx::Instruction[][src]

pub enum Instruction<'a> {
Show 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

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

Show fields

Fields of GetArg

nth: usize
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

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

Show fields

Fields of I32FromHandle

ty: &'a NamedType
I32FromBitflags

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

Show fields

Fields of I32FromBitflags

ty: &'a NamedType
I64FromBitflags

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

Show fields

Fields of I64FromBitflags

ty: &'a NamedType
ListPointerLength

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

ListFromPointerLength

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.

Show fields

Fields of ListFromPointerLength

ty: &'a TypeRef
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

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

Show fields

Fields of CallWasm

module: &'a strname: &'a strparams: &'a [WasmType]results: &'a [WasmType]
CallInterface

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

Show fields

Fields of CallInterface

module: &'a strfunc: &'a InterfaceFunc
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

Converts a native wasm i32 to an interface type handle.

Show fields

Fields of HandleFromI32

ty: &'a NamedType
PointerFromI32

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

Show fields

Fields of PointerFromI32

ty: &'a TypeRef
ConstPointerFromI32

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

Show fields

Fields of ConstPointerFromI32

ty: &'a TypeRef
BitflagsFromI32

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

Show fields

Fields of BitflagsFromI32

ty: &'a NamedType
BitflagsFromI64

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

Show fields

Fields of BitflagsFromI64

ty: &'a NamedType
ReturnPointerGet

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.

Show fields

Fields of ReturnPointerGet

n: usize
Load

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

Show fields

Fields of Load

ty: &'a NamedType
Store

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.

Show fields

Fields of Store

ty: &'a NamedType
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

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.

Show fields

Fields of ResultLower

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

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.

Show fields

Fields of EnumLift

ty: &'a NamedType
EnumLower

Converts an interface types enum value into a wasm i32.

Show fields

Fields of EnumLower

ty: &'a NamedType
TupleLift

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

Show fields

Fields of TupleLift

amt: usize
TupleLower

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

Show fields

Fields of TupleLower

amt: usize
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

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

Show fields

Fields of Return

amt: usize
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

Performs the conversion.

Performs the conversion.

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.