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>) -> ConstExpr
pub fn new(ops: impl IntoIterator<Item = ConstOp>) -> ConstExpr
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<'_>,
) -> Result<(ConstExpr, SmallVec<[FuncIndex; 1]>), WasmError>
pub fn from_wasmparser( expr: ConstExpr<'_>, ) -> Result<(ConstExpr, SmallVec<[FuncIndex; 1]>), WasmError>
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<ConstExpr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ConstExpr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl Serialize for ConstExpr
impl Serialize for ConstExpr
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
)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.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§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more