Struct wasm_encoder::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 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

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 T)

🔬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.