wasm_encoder

Struct ConstExpr

Source
pub struct ConstExpr { /* private fields */ }
Expand description

A constant expression.

Usable in contexts such as offsets or initializers.

Implementations§

Source§

impl ConstExpr

Source

pub fn empty() -> Self

Create a new empty constant expression builder.

Source

pub fn raw(bytes: impl IntoIterator<Item = u8>) -> Self

Create a constant expression with the specified raw encoding of instructions.

Source

pub fn extended<'a>(insns: impl IntoIterator<Item = Instruction<'a>>) -> Self

Create a constant expression with the sequence of instructions

Source

pub fn global_get(index: u32) -> Self

Create a constant expression containing a single global.get instruction.

Source

pub fn ref_null(ty: HeapType) -> Self

Create a constant expression containing a single ref.null instruction.

Source

pub fn ref_func(func: u32) -> Self

Create a constant expression containing a single ref.func instruction.

Source

pub fn i32_const(value: i32) -> Self

Create a constant expression containing a single i32.const instruction.

Source

pub fn i64_const(value: i64) -> Self

Create a constant expression containing a single i64.const instruction.

Source

pub fn f32_const(value: f32) -> Self

Create a constant expression containing a single f32.const instruction.

Source

pub fn f64_const(value: f64) -> Self

Create a constant expression containing a single f64.const instruction.

Source

pub fn v128_const(value: i128) -> Self

Create a constant expression containing a single v128.const instruction.

Source

pub fn with_global_get(self, index: u32) -> Self

Add a global.get instruction to this constant expression.

Source

pub fn with_ref_null(self, ty: HeapType) -> Self

Add a ref.null instruction to this constant expression.

Source

pub fn with_ref_func(self, func: u32) -> Self

Add a ref.func instruction to this constant expression.

Source

pub fn with_i32_const(self, value: i32) -> Self

Add an i32.const instruction to this constant expression.

Source

pub fn with_i64_const(self, value: i64) -> Self

Add an i64.const instruction to this constant expression.

Source

pub fn with_f32_const(self, value: f32) -> Self

Add a f32.const instruction to this constant expression.

Source

pub fn with_f64_const(self, value: f64) -> Self

Add a f64.const instruction to this constant expression.

Source

pub fn with_v128_const(self, value: i128) -> Self

Add a v128.const instruction to this constant expression.

Source

pub fn with_i32_add(self) -> Self

Add an i32.add instruction to this constant expression.

Source

pub fn with_i32_sub(self) -> Self

Add an i32.sub instruction to this constant expression.

Source

pub fn with_i32_mul(self) -> Self

Add an i32.mul instruction to this constant expression.

Source

pub fn with_i64_add(self) -> Self

Add an i64.add instruction to this constant expression.

Source

pub fn with_i64_sub(self) -> Self

Add an i64.sub instruction to this constant expression.

Source

pub fn with_i64_mul(self) -> Self

Add an i64.mul instruction to this constant expression.

Source

pub fn get_ref_func(&self) -> Option<u32>

Returns the function, if any, referenced by this global.

Trait Implementations§

Source§

impl Clone for ConstExpr

Source§

fn clone(&self) -> ConstExpr

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConstExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Encode for ConstExpr

Source§

fn encode(&self, sink: &mut Vec<u8>)

Encode the type into the given byte sink.
Source§

impl<'a> TryFrom<ConstExpr<'a>> for ConstExpr

Available on crate feature wasmparser only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(const_expr: ConstExpr<'_>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.