[][src]Enum walrus::ir::Expr

pub enum Expr {
    Block(Block),
    Call(Call),
    CallIndirect(CallIndirect),
    LocalGet(LocalGet),
    LocalSet(LocalSet),
    LocalTee(LocalTee),
    GlobalGet(GlobalGet),
    GlobalSet(GlobalSet),
    Const(Const),
    Binop(Binop),
    Unop(Unop),
    Select(Select),
    Unreachable(Unreachable),
    Br(Br),
    BrIf(BrIf),
    IfElse(IfElse),
    BrTable(BrTable),
    Drop(Drop),
    Return(Return),
    MemorySize(MemorySize),
    MemoryGrow(MemoryGrow),
    MemoryInit(MemoryInit),
    DataDrop(DataDrop),
    MemoryCopy(MemoryCopy),
    MemoryFill(MemoryFill),
    Load(Load),
    Store(Store),
    AtomicRmw(AtomicRmw),
    Cmpxchg(Cmpxchg),
    AtomicNotify(AtomicNotify),
    AtomicWait(AtomicWait),
    WithSideEffects(WithSideEffects),
}

An enum of all the different kinds of wasm expressions.

Note that the #[walrus_expr] macro rewrites this enum's variants from

This example is not tested
enum Expr {
    Variant { field: Ty, .. },
    ...
}

into

This example is not tested
enum Expr {
    Variant(Variant),
    ...
}

struct Variant {
    field: Ty,
    ...
}

Variants

Block(Block)

A block of multiple expressions, and also a control frame.

Call(Call)

call

CallIndirect(CallIndirect)

call_indirect

LocalGet(LocalGet)

local.get n

LocalSet(LocalSet)

local.set n

LocalTee(LocalTee)

local.tee n

GlobalGet(GlobalGet)

global.get n

GlobalSet(GlobalSet)

global.set n

Const(Const)

*.const

Binop(Binop)

Binary operations, those requiring two operands

Unop(Unop)

Unary operations, those requiring one operand

Select(Select)

select

Unreachable(Unreachable)

unreachable

Br(Br)

br

BrIf(BrIf)

br_if

IfElse(IfElse)

if ... else ... end

BrTable(BrTable)

br_table

Drop(Drop)

drop

Return(Return)

return

MemorySize(MemorySize)

memory.size

MemoryGrow(MemoryGrow)

memory.grow

MemoryInit(MemoryInit)

memory.init

DataDrop(DataDrop)

data.drop

MemoryCopy(MemoryCopy)

memory.copy

MemoryFill(MemoryFill)

memory.fill

Load(Load)

Loading a value from memory

Store(Store)

Storing a value to memory

AtomicRmw(AtomicRmw)

An atomic read/modify/write operation

Cmpxchg(Cmpxchg)

An atomic compare exchange operation

AtomicNotify(AtomicNotify)

The atomic.notify instruction to wake up threads

AtomicWait(AtomicWait)

The *.atomic.wait instruction to block threads

WithSideEffects(WithSideEffects)

A value followed by one or more stack-neutral, side-effecting expressions.

This allows us to express "stacky" and "non-tree-like" expressions such as:

;; Assuming `f` has type `[] -> i32` and potential side effects.
call $f
call $f
call $f
drop
i32.add

Without WithSideEffects, we would need to create a synthetic block with a temporary local like this:

(i32.added
  (call $f)
  (block
    (set_local $temp (call $f))
    (drop (call $f))
    (get_local $temp)
  end))

But using WithoutSideEffects we can represent this like so:

(i32.add
  (with_side_effects
    ;; value
    (call $f)
    ;; side_effects
    (drop (call $f)))
  (call $f))

Methods

impl Expr[src]

pub fn block_mut(&mut self) -> Option<&mut Block>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_block(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_block(&self) -> &Block[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_block_mut(&mut self) -> &mut Block[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn call_mut(&mut self) -> Option<&mut Call>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_call(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_call(&self) -> &Call[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_call_mut(&mut self) -> &mut Call[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn call_indirect_mut(&mut self) -> Option<&mut CallIndirect>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_call_indirect(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_call_indirect(&self) -> &CallIndirect[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_call_indirect_mut(&mut self) -> &mut CallIndirect[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn local_get_mut(&mut self) -> Option<&mut LocalGet>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_local_get(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_local_get(&self) -> &LocalGet[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_local_get_mut(&mut self) -> &mut LocalGet[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn local_set_mut(&mut self) -> Option<&mut LocalSet>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_local_set(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_local_set(&self) -> &LocalSet[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_local_set_mut(&mut self) -> &mut LocalSet[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn local_tee_mut(&mut self) -> Option<&mut LocalTee>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_local_tee(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_local_tee(&self) -> &LocalTee[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_local_tee_mut(&mut self) -> &mut LocalTee[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn global_get_mut(&mut self) -> Option<&mut GlobalGet>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_global_get(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_global_get(&self) -> &GlobalGet[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_global_get_mut(&mut self) -> &mut GlobalGet[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn global_set_mut(&mut self) -> Option<&mut GlobalSet>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_global_set(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_global_set(&self) -> &GlobalSet[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_global_set_mut(&mut self) -> &mut GlobalSet[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn const_mut(&mut self) -> Option<&mut Const>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_const(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_const(&self) -> &Const[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_const_mut(&mut self) -> &mut Const[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn binop_mut(&mut self) -> Option<&mut Binop>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_binop(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_binop(&self) -> &Binop[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_binop_mut(&mut self) -> &mut Binop[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unop_mut(&mut self) -> Option<&mut Unop>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_unop(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_unop(&self) -> &Unop[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_unop_mut(&mut self) -> &mut Unop[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn select_mut(&mut self) -> Option<&mut Select>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_select(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_select(&self) -> &Select[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_select_mut(&mut self) -> &mut Select[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unreachable_mut(&mut self) -> Option<&mut Unreachable>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_unreachable(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_unreachable(&self) -> &Unreachable[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_unreachable_mut(&mut self) -> &mut Unreachable[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn br_mut(&mut self) -> Option<&mut Br>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_br(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_br(&self) -> &Br[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_br_mut(&mut self) -> &mut Br[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn br_if_mut(&mut self) -> Option<&mut BrIf>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_br_if(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_br_if(&self) -> &BrIf[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_br_if_mut(&mut self) -> &mut BrIf[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn if_else_mut(&mut self) -> Option<&mut IfElse>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_if_else(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_if_else(&self) -> &IfElse[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_if_else_mut(&mut self) -> &mut IfElse[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn br_table_mut(&mut self) -> Option<&mut BrTable>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_br_table(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_br_table(&self) -> &BrTable[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_br_table_mut(&mut self) -> &mut BrTable[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn drop_mut(&mut self) -> Option<&mut Drop>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_drop(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_drop(&self) -> &Drop[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_drop_mut(&mut self) -> &mut Drop[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn return_mut(&mut self) -> Option<&mut Return>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_return(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_return(&self) -> &Return[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_return_mut(&mut self) -> &mut Return[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn memory_size_mut(&mut self) -> Option<&mut MemorySize>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_memory_size(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_memory_size(&self) -> &MemorySize[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_memory_size_mut(&mut self) -> &mut MemorySize[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn memory_grow_mut(&mut self) -> Option<&mut MemoryGrow>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_memory_grow(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_memory_grow(&self) -> &MemoryGrow[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_memory_grow_mut(&mut self) -> &mut MemoryGrow[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn memory_init_mut(&mut self) -> Option<&mut MemoryInit>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_memory_init(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_memory_init(&self) -> &MemoryInit[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_memory_init_mut(&mut self) -> &mut MemoryInit[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn data_drop_mut(&mut self) -> Option<&mut DataDrop>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_data_drop(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_data_drop(&self) -> &DataDrop[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_data_drop_mut(&mut self) -> &mut DataDrop[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn memory_copy_mut(&mut self) -> Option<&mut MemoryCopy>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_memory_copy(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_memory_copy(&self) -> &MemoryCopy[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_memory_copy_mut(&mut self) -> &mut MemoryCopy[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn memory_fill_mut(&mut self) -> Option<&mut MemoryFill>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_memory_fill(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_memory_fill(&self) -> &MemoryFill[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_memory_fill_mut(&mut self) -> &mut MemoryFill[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn load_mut(&mut self) -> Option<&mut Load>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_load(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_load(&self) -> &Load[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_load_mut(&mut self) -> &mut Load[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn store_mut(&mut self) -> Option<&mut Store>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_store(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_store(&self) -> &Store[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_store_mut(&mut self) -> &mut Store[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn atomic_rmw_mut(&mut self) -> Option<&mut AtomicRmw>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_atomic_rmw(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_atomic_rmw(&self) -> &AtomicRmw[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_atomic_rmw_mut(&mut self) -> &mut AtomicRmw[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn cmpxchg_mut(&mut self) -> Option<&mut Cmpxchg>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_cmpxchg(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_cmpxchg(&self) -> &Cmpxchg[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_cmpxchg_mut(&mut self) -> &mut Cmpxchg[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn atomic_notify_mut(&mut self) -> Option<&mut AtomicNotify>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_atomic_notify(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_atomic_notify(&self) -> &AtomicNotify[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_atomic_notify_mut(&mut self) -> &mut AtomicNotify[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn atomic_wait_mut(&mut self) -> Option<&mut AtomicWait>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_atomic_wait(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_atomic_wait(&self) -> &AtomicWait[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_atomic_wait_mut(&mut self) -> &mut AtomicWait[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

pub fn with_side_effects_mut(&mut self) -> Option<&mut WithSideEffects>[src]

If this expression is a #name, get an exclusive reference to it.

Returns None otherwise.

pub fn is_with_side_effects(&self) -> bool[src]

Is this expression a #name?

pub fn unwrap_with_side_effects(&self) -> &WithSideEffects[src]

Get a shared reference to the underlying #name.

Panics if this expression is not a #name.

pub fn unwrap_with_side_effects_mut(&mut self) -> &mut WithSideEffects[src]

Get an exclusive reference to the underlying #name.

Panics if this expression is not a #name.

impl Expr[src]

pub fn following_instructions_are_unreachable(&self) -> bool[src]

Are any instructions that follow this expression's instruction (within the current block) unreachable?

Returns true for unconditional branches (br, return, etc...) and unreachable. Returns false for all other "normal" instructions (i32.add, etc...).

Trait Implementations

impl<'expr> Visit<'expr> for Expr[src]

impl VisitMut for Expr[src]

impl Clone for Expr[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl From<Block> for Expr[src]

impl From<Call> for Expr[src]

impl From<CallIndirect> for Expr[src]

impl From<LocalGet> for Expr[src]

impl From<LocalSet> for Expr[src]

impl From<LocalTee> for Expr[src]

impl From<GlobalGet> for Expr[src]

impl From<GlobalSet> for Expr[src]

impl From<Const> for Expr[src]

impl From<Binop> for Expr[src]

impl From<Unop> for Expr[src]

impl From<Select> for Expr[src]

impl From<Unreachable> for Expr[src]

impl From<Br> for Expr[src]

impl From<BrIf> for Expr[src]

impl From<IfElse> for Expr[src]

impl From<BrTable> for Expr[src]

impl From<Drop> for Expr[src]

impl From<Return> for Expr[src]

impl From<MemorySize> for Expr[src]

impl From<MemoryGrow> for Expr[src]

impl From<MemoryInit> for Expr[src]

impl From<DataDrop> for Expr[src]

impl From<MemoryCopy> for Expr[src]

impl From<MemoryFill> for Expr[src]

impl From<Load> for Expr[src]

impl From<Store> for Expr[src]

impl From<AtomicRmw> for Expr[src]

impl From<Cmpxchg> for Expr[src]

impl From<AtomicNotify> for Expr[src]

impl From<AtomicWait> for Expr[src]

impl From<WithSideEffects> for Expr[src]

impl Debug for Expr[src]

Auto Trait Implementations

impl Send for Expr

impl Sync for Expr

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]