Instruction

Enum Instruction 

Source
pub enum Instruction {
Show 45 variants LPush(u16), GPush(u16), CPush(u16), LMove(u16), GMove(u16), Drop, Dup, Get, RGet, Set, Add, Sub, Mul, Div, Pow, Rem, Shl, Shr, And, Or, XOr, Not, Eq, Ne, Ge, Gt, Le, Lt, Jmp(u16), Jt(u16), Jf(u16), Call(u16, u8), LCall(u16, u8), Ret, Interrupt(u16), Conv(u16), Import, NImport, Box, Slice, IterCreate, IterCreateRanged, IterHasNext, IterNext, IterReverse,
}
Expand description

Definition of the bytecode

Variants§

§

LPush(u16)

Push local variable.

§

GPush(u16)

Push global variable.

§

CPush(u16)

Push constant.

§

LMove(u16)

Store into local variable.

§

GMove(u16)

Store into global variable.

§

Drop

Drops the value on top of stack.

§

Dup

Duplicates top of stack.

§

Get

Get first argument as key from second argument and push it.

§

RGet

Get first argument as key from second argument by reference and push it.

§

Set

Write second argument into first argument which must be a reference.

§

Add

= first + second

§

Sub

= first - second

§

Mul

= first * second

§

Div

= first / second

§

Pow

= first ** second

§

Rem

= first % second

§

Shl

Logical shift left first by second places.

§

Shr

Logical shift right first by second places.

§

And

Logical and for Bool, Bitwise and for Int.

§

Or

Logical or for Bool, Bitwise or for Int.

§

XOr

Logical xor for Bool, Bitwise xor for Int.

§

Not

Logical not for Bool, Bitwise not for Int.

§

Eq

= first == second

§

Ne

= first != second

§

Ge

= first >= second

§

Gt

= first > second

§

Le

= first <= second

§

Lt

= first < second

§

Jmp(u16)

Jump to instruction offset.

§

Jt(u16)

Jump to instruction offset if top of stack is true.

§

Jf(u16)

Jump to instruction offset if top of stack is false.

§

Call(u16, u8)

Call function with ident index, argn.

§

LCall(u16, u8)

Call a function in the same module.

§

Ret

Return early from a code object.

§

Interrupt(u16)

Trigger interrupt n.

§

Conv(u16)

Convert top of stack into type. See Value::type_id.

§

Import

Take top of stack as name of module to load and import functions without module prefix as well.

§

NImport

Take top of stack as name of module to import. Function name will be padded using the import hook.

§

Box

Turn the value on stack into a referenceable value. Lists and dicts are boxed deeply.

§

Slice

Create a new list from the first argument on stack. Second is starting index or nil, third is end index (exclusive) or nil.

§

IterCreate

Create a new iterator from the first argument on stack.

§

IterCreateRanged

Create a new ranged iterator using the first argument as from and second argument as to. on of the arguments is allowed to be nil.

§

IterHasNext

Consumes the iterator on top of stack and leaves a bool on top if the iterator has another element.

§

IterNext

Consumes the iterator on top of stack and returns the next value if any.

§

IterReverse

Consumes the iterator on top of stack and create a new one in reverse.

Trait Implementations§

Source§

impl Clone for Instruction

Source§

fn clone(&self) -> Instruction

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 Instruction

Source§

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

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

impl<'de> Deserialize<'de> for Instruction

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Instruction

Source§

fn eq(&self, other: &Instruction) -> 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 Serialize for Instruction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Instruction

Source§

impl StructuralPartialEq for Instruction

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,