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
impl ConstExpr
sourcepub fn raw(bytes: impl IntoIterator<Item = u8>) -> Self
pub fn raw(bytes: impl IntoIterator<Item = u8>) -> Self
Create a constant expression with the specified raw encoding of instructions.
sourcepub fn global_get(index: u32) -> Self
pub fn global_get(index: u32) -> Self
Create a constant expression containing a single global.get
instruction.
sourcepub fn ref_null(ty: HeapType) -> Self
pub fn ref_null(ty: HeapType) -> Self
Create a constant expression containing a single ref.null
instruction.
sourcepub fn ref_func(func: u32) -> Self
pub fn ref_func(func: u32) -> Self
Create a constant expression containing a single ref.func
instruction.
sourcepub fn i32_const(value: i32) -> Self
pub fn i32_const(value: i32) -> Self
Create a constant expression containing a single i32.const
instruction.
sourcepub fn i64_const(value: i64) -> Self
pub fn i64_const(value: i64) -> Self
Create a constant expression containing a single i64.const
instruction.
sourcepub fn f32_const(value: f32) -> Self
pub fn f32_const(value: f32) -> Self
Create a constant expression containing a single f32.const
instruction.
sourcepub fn f64_const(value: f64) -> Self
pub fn f64_const(value: f64) -> Self
Create a constant expression containing a single f64.const
instruction.
sourcepub fn v128_const(value: i128) -> Self
pub fn v128_const(value: i128) -> Self
Create a constant expression containing a single v128.const
instruction.
sourcepub fn with_global_get(self, index: u32) -> Self
pub fn with_global_get(self, index: u32) -> Self
Add a global.get
instruction to this constant expression.
sourcepub fn with_ref_null(self, ty: HeapType) -> Self
pub fn with_ref_null(self, ty: HeapType) -> Self
Add a ref.null
instruction to this constant expression.
sourcepub fn with_ref_func(self, func: u32) -> Self
pub fn with_ref_func(self, func: u32) -> Self
Add a ref.func
instruction to this constant expression.
sourcepub fn with_i32_const(self, value: i32) -> Self
pub fn with_i32_const(self, value: i32) -> Self
Add an i32.const
instruction to this constant expression.
sourcepub fn with_i64_const(self, value: i64) -> Self
pub fn with_i64_const(self, value: i64) -> Self
Add an i64.const
instruction to this constant expression.
sourcepub fn with_f32_const(self, value: f32) -> Self
pub fn with_f32_const(self, value: f32) -> Self
Add a f32.const
instruction to this constant expression.
sourcepub fn with_f64_const(self, value: f64) -> Self
pub fn with_f64_const(self, value: f64) -> Self
Add a f64.const
instruction to this constant expression.
sourcepub fn with_v128_const(self, value: i128) -> Self
pub fn with_v128_const(self, value: i128) -> Self
Add a v128.const
instruction to this constant expression.
sourcepub fn with_i32_add(self) -> Self
pub fn with_i32_add(self) -> Self
Add an i32.add
instruction to this constant expression.
sourcepub fn with_i32_sub(self) -> Self
pub fn with_i32_sub(self) -> Self
Add an i32.sub
instruction to this constant expression.
sourcepub fn with_i32_mul(self) -> Self
pub fn with_i32_mul(self) -> Self
Add an i32.mul
instruction to this constant expression.
sourcepub fn with_i64_add(self) -> Self
pub fn with_i64_add(self) -> Self
Add an i64.add
instruction to this constant expression.
sourcepub fn with_i64_sub(self) -> Self
pub fn with_i64_sub(self) -> Self
Add an i64.sub
instruction to this constant expression.
sourcepub fn with_i64_mul(self) -> Self
pub fn with_i64_mul(self) -> Self
Add an i64.mul
instruction to this constant expression.
sourcepub fn get_ref_func(&self) -> Option<u32>
pub fn get_ref_func(&self) -> Option<u32>
Returns the function, if any, referenced by this global.