pub struct ConstExpr { /* private fields */ }
Expand description
A constant expression.
These are used to initialize globals, table elements, etc…
Implementations§
source§impl ConstExpr
impl ConstExpr
sourcepub fn new(ops: impl IntoIterator<Item = ConstOp>) -> Self
pub fn new(ops: impl IntoIterator<Item = ConstOp>) -> Self
Create a new const expression from the given opcodes.
Does not do any validation that the const expression is well-typed.
Panics if given zero opcodes.
sourcepub fn from_wasmparser(
expr: ConstExpr<'_>,
) -> WasmResult<(Self, SmallVec<[FuncIndex; 1]>)>
pub fn from_wasmparser( expr: ConstExpr<'_>, ) -> WasmResult<(Self, SmallVec<[FuncIndex; 1]>)>
Create a new const expression from a wasmparser
const expression.
Returns the new const expression as well as the escaping function
indices that appeared in ref.func
instructions, if any.
sourcepub fn provably_nonzero_i32(&self) -> bool
pub fn provably_nonzero_i32(&self) -> bool
Is this ConstExpr a provably nonzero integer value?
This must be conservative: if the expression might be zero,
it must return false
. It is always allowed to return false
for some expression kind that we don’t support. However, if it
returns true
, the expression must be actually nonzero.
We use this for certain table optimizations that rely on knowing for sure that index 0 is not referenced.
Trait Implementations§
source§impl<'de> Deserialize<'de> for ConstExpr
impl<'de> Deserialize<'de> for ConstExpr
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ConstExpr
impl StructuralPartialEq for ConstExpr
Auto Trait Implementations§
impl Freeze for ConstExpr
impl RefUnwindSafe for ConstExpr
impl Send for ConstExpr
impl Sync for ConstExpr
impl Unpin for ConstExpr
impl UnwindSafe for ConstExpr
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.