Enum Instruction

Source
pub enum Instruction {
Show 34 variants Nop, Push(Value), Drop, Clone, Call(usize), SetMp(isize), RelToAddr(isize), Ret, Exit, Jmp(usize), JmpFalse(usize), SetVarImm(Pointer), SetVar, GetVar, Cast(Type), Neg, Not, Add, Sub, Mul, Pow, Div, Rem, Eq, Ne, Lt, Gt, Le, Ge, Shl, Shr, BitOr, BitAnd, BitXor,
}

Variants§

§

Nop

Does nothing.

§

Push(Value)

Adds a new constant to stack.

§

Drop

Pops the top-most value off the stack and discards the value.

§

Clone

Clones the top value on the stack: […, top] -> […, top, top].

§

Call(usize)

Calls a function (specified by index).

§

SetMp(isize)

Adjusts the memory pointer by the given offset.

§

RelToAddr(isize)

Pushes a pointer which points to the absolute address of the given relative offset.

§

Ret

Returns from the current function call.

§

Exit

Special instruction for exit calls.

§

Jmp(usize)

Jumps to the specified index.

§

JmpFalse(usize)

Jumps to the specified index if the value on the stack is false.

§

SetVarImm(Pointer)

Pops the top of the stack in order to use it as the variable’s value. Saves this value at the specified memory location.

§

SetVar

Pops the top value from the stack in order to use it as the variable’s value. Then pops the second value from the stack which is a pointer. Saves this value at the memory location specified by the pointer.

§

GetVar

Pops the top value from the stack because it is a pointer specifying the target memory address. The value saved at this address is then loaded and pushed onto the stack.

§

Cast(Type)

Cast the current item on the stack to the specified type.

§

Neg

§

Not

§

Add

§

Sub

§

Mul

§

Pow

§

Div

§

Rem

§

Eq

§

Ne

§

Lt

§

Gt

§

Le

§

Ge

§

Shl

§

Shr

§

BitOr

§

BitAnd

§

BitXor

Trait Implementations§

Source§

impl Debug for Instruction

Source§

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

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

impl Display for Instruction

Source§

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

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

impl From<InfixOp> for Instruction

Source§

fn from(src: InfixOp) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<AssignOp> for Instruction

Source§

type Error = ()

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

fn try_from(src: AssignOp) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<PrefixOp> for Instruction

Source§

type Error = ()

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

fn try_from(src: PrefixOp) -> Result<Self, Self::Error>

Performs the conversion.

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.