Enum lovm2_core::Instruction[][src]

pub enum Instruction {
    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(u16u8),
    LCall(u16u8),
    Ret,
    Interrupt(u16),
    Conv(u16),
    Import,
    NImport,
    Box,
    Slice,
    IterCreate,
    IterCreateRanged,
    IterHasNext,
    IterNext,
    IterReverse,
}

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

Call function with ident index, argn.

LCall(u16u8)

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

impl Clone for Instruction[src]

impl Copy for Instruction[src]

impl Debug for Instruction[src]

impl<'de> Deserialize<'de> for Instruction[src]

impl PartialEq<Instruction> for Instruction[src]

impl Serialize for Instruction[src]

impl StructuralPartialEq for Instruction[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.