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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.