Enum witx::Instruction [−][src]
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
Acquires the specified parameter and places it on the stack. Depending on the context this may refer to wasm parameters or interface types parameters.
Fields of GetArg
nth: usize
Takes the value off the top of the stack and writes it into linear
memory. Pushes the address in linear memory as an i32
.
Converts an interface type char
value to a 32-bit integer
representing the unicode scalar value.
Converts an interface type u64
value to a wasm i64
.
Converts an interface type s64
value to a wasm i64
.
Converts an interface type u32
value to a wasm i32
.
Converts an interface type s32
value to a wasm i32
.
Converts a language-specific usize
value to a wasm i32
.
Converts an interface type u16
value to a wasm i32
.
Converts an interface type s16
value to a wasm i32
.
Converts an interface type u8
value to a wasm i32
.
Converts an interface type s8
value to a wasm i32
.
Converts a language-specific C char
value to a wasm i32
.
Converts a language-specific pointer value to a wasm i32
.
Converts a language-specific pointer value to a wasm i32
.
Converts a language-specific handle value to a wasm i32
.
Fields of I32FromHandle
ty: &'a NamedType
Converts a language-specific record-of-bools to the packed
representation as an i32
.
Fields of I32FromBitflags
ty: &'a NamedType
Converts a language-specific record-of-bools to the packed
representation as an i64
.
Fields of I64FromBitflags
ty: &'a NamedType
Converts an interface type list into its pointer/length, pushing them both on the stack.
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.
Fields of ListFromPointerLength
ty: &'a TypeRef
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
.
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
.
Represents a call to a raw WebAssembly API. The module/name are provided inline as well as the types if necessary.
Same as CallWasm
, except the dual where an interface is being
called rather than a raw wasm function.
Fields of CallInterface
module: &'a str
func: &'a InterfaceFunc
Converts a native wasm i32
to an interface type s8
.
This will truncate the upper bits of the i32
.
Converts a native wasm i32
to an interface type u8
.
This will truncate the upper bits of the i32
.
Converts a native wasm i32
to an interface type s16
.
This will truncate the upper bits of the i32
.
Converts a native wasm i32
to an interface type u16
.
This will truncate the upper bits of the i32
.
Converts a native wasm i32
to an interface type s32
.
Converts a native wasm i32
to an interface type u32
.
Converts a native wasm i64
to an interface type s64
.
Converts a native wasm i64
to an interface type u64
.
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.
Converts a native wasm i32
to a language-specific C char
.
This will truncate the upper bits of the i32
.
Converts a native wasm i32
to a language-specific usize
.
Converts a native wasm f32
to an interface type f32
.
Converts a native wasm f64
to an interface type f64
.
Converts a native wasm i32
to an interface type handle
.
Fields of HandleFromI32
ty: &'a NamedType
Converts a native wasm i32
to a language-specific pointer.
Fields of PointerFromI32
ty: &'a TypeRef
Converts a native wasm i32
to a language-specific pointer.
Fields of ConstPointerFromI32
ty: &'a TypeRef
Converts a native wasm i32
to a language-specific record-of-bools.
Fields of BitflagsFromI32
ty: &'a NamedType
Converts a native wasm i64
to a language-specific record-of-bools.
Fields of BitflagsFromI64
ty: &'a NamedType
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
.
Fields of ReturnPointerGet
n: usize
Loads the interface types value from an i32
pointer popped from
the stack.
Fields of Load
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.
Fields of Store
ty: &'a NamedType
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.
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.
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.
Fields of EnumLift
ty: &'a NamedType
Converts an interface types enum value into a wasm i32
.
Fields of EnumLower
ty: &'a NamedType
Creates a tuple from the top n
elements on the stack, pushing the
tuple onto the stack.
Fields of TupleLift
amt: usize
Splits a tuple at the top of the stack into its n
components,
pushing them all onto the stack.
Fields of TupleLower
amt: usize
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.
Returns amt
values on the stack. This is always the last
instruction.
Fields of Return
amt: usize
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?