[][src]Struct walrus::ir::WithSideEffects

pub struct WithSideEffects {
    pub before: Vec<ExprId>,
    pub value: ExprId,
    pub after: Vec<ExprId>,
}

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))

Fields

before: Vec<ExprId>

The stack-neutral, side-effecting operations before value

value: ExprId

The value.

after: Vec<ExprId>

The stack-neutral, side-effecting operations after value

Trait Implementations

impl Ast for WithSideEffects[src]

type Id = WithSideEffectsId

The identifier type for this AST node.

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

impl VisitMut for WithSideEffects[src]

impl Clone for WithSideEffects[src]

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

Performs copy-assignment from source. Read more

impl From<WithSideEffects> for Expr[src]

impl Debug for WithSideEffects[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

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

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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