VariableInstruction

Enum VariableInstruction 

Source
pub enum VariableInstruction {
    LocalGet(LocalIndex),
    LocalSet(LocalIndex),
    LocalTee(LocalIndex),
    GlobalGet(GlobalIndex),
    GlobalSet(GlobalIndex),
}
Expand description

Variable instructions are concerned with access to local or global variables. These instructions get or set the values of variables, respectively. The π—…π—ˆπ–Όπ–Ίπ—….𝗍𝖾𝖾 instruction is like π—…π—ˆπ–Όπ–Ίπ—….π—Œπ–Ύπ— but also returns its argument.

See https://webassembly.github.io/spec/core/syntax/instructions.html#variable-instructions

Β§Examples

use wasm_ast::{VariableInstruction, Instruction, ValueType};

assert_eq!(
    Instruction::Variable(VariableInstruction::LocalGet(0)),
    VariableInstruction::LocalGet(0).into()
);
assert_eq!(
    Instruction::Variable(VariableInstruction::LocalSet(1)),
    VariableInstruction::LocalSet(1).into()
);
assert_eq!(
    Instruction::Variable(VariableInstruction::LocalTee(1)),
    VariableInstruction::LocalTee(1).into()
);
assert_eq!(
    Instruction::Variable(VariableInstruction::GlobalGet(0)),
    VariableInstruction::GlobalGet(0).into()
);
assert_eq!(
    Instruction::Variable(VariableInstruction::GlobalSet(1)),
    VariableInstruction::GlobalSet(1).into()
);

VariantsΒ§

Β§

LocalGet(LocalIndex)

local.get localidx Get the value of a local variable.

Β§

LocalSet(LocalIndex)

local.set localidx Set the value of a local variable.

Β§

LocalTee(LocalIndex)

local.tee localidx The π—…π—ˆπ–Όπ–Ίπ—….𝗍𝖾𝖾 instruction is like π—…π—ˆπ–Όπ–Ίπ—….π—Œπ–Ύπ— but also returns its argument.

Β§

GlobalGet(GlobalIndex)

global.get globalidx Get the value of a global variable.

Β§

GlobalSet(GlobalIndex)

global.set globalidx Set the value of a global variable.

Trait ImplementationsΒ§

SourceΒ§

impl Clone for VariableInstruction

SourceΒ§

fn clone(&self) -> VariableInstruction

Returns a duplicate of the value. Read more
1.0.0 Β· SourceΒ§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
SourceΒ§

impl Debug for VariableInstruction

SourceΒ§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
SourceΒ§

impl From<VariableInstruction> for Instruction

SourceΒ§

fn from(instruction: VariableInstruction) -> Self

Converts to this type from the input type.
SourceΒ§

impl PartialEq for VariableInstruction

SourceΒ§

fn eq(&self, other: &VariableInstruction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 Β· SourceΒ§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
SourceΒ§

impl Copy for VariableInstruction

SourceΒ§

impl Eq for VariableInstruction

SourceΒ§

impl StructuralPartialEq for VariableInstruction

Auto Trait ImplementationsΒ§

Blanket ImplementationsΒ§

SourceΒ§

impl<T> Any for T
where T: 'static + ?Sized,

SourceΒ§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
SourceΒ§

impl<T> Borrow<T> for T
where T: ?Sized,

SourceΒ§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
SourceΒ§

impl<T> BorrowMut<T> for T
where T: ?Sized,

SourceΒ§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
SourceΒ§

impl<T> CloneToUninit for T
where T: Clone,

SourceΒ§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

πŸ”¬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
SourceΒ§

impl<T> From<T> for T

SourceΒ§

fn from(t: T) -> T

Returns the argument unchanged.

SourceΒ§

impl<T, U> Into<U> for T
where U: From<T>,

SourceΒ§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

SourceΒ§

impl<T> ToOwned for T
where T: Clone,

SourceΒ§

type Owned = T

The resulting type after obtaining ownership.
SourceΒ§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
SourceΒ§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
SourceΒ§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

SourceΒ§

type Error = Infallible

The type returned in the event of a conversion error.
SourceΒ§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
SourceΒ§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

SourceΒ§

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

The type returned in the event of a conversion error.
SourceΒ§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.