Skip to main content

Op

Enum Op 

Source
#[repr(u8)]
pub enum Op {
Show 77 variants Constant = 0, True = 1, False = 2, Unit = 3, None = 4, Add = 5, Sub = 6, Mul = 7, Div = 8, Mod = 9, Neg = 10, BitAnd = 11, BitOr = 12, BitXor = 13, Shl = 14, Shr = 15, Eq = 16, NotEq = 17, Lt = 18, Gt = 19, LtEq = 20, GtEq = 21, Not = 22, And = 23, Or = 24, DefineLocal = 25, GetLocal = 26, SetLocal = 27, GetGlobal = 28, SetGlobal = 29, Jump = 30, JumpIfFalse = 31, Loop = 32, Call = 33, TailCall = 34, Return = 35, Pop = 36, Dup = 37, BuildList = 38, BuildTuple = 39, BuildDict = 40, GetField = 41, GetIndex = 42, SetField = 43, SetIndex = 44, MethodCall = 45, Closure = 46, WrapSome = 47, WrapOk = 48, WrapErr = 49, Try = 50, PushScope = 51, PopScope = 52, BuildFString = 53, Pipe = 54, MatchBegin = 55, MatchArm = 56, MatchEnd = 57, BuildRange = 58, ConstructStruct = 59, ConstructEnum = 60, IterInit = 61, IterNext = 62, ListAppend = 63, ListExtend = 64, DictInsert = 65, DictMerge = 66, IterDrop = 67, CheckType = 68, Slice = 69, DefineLocalSlot = 70, GetLocalSlot = 71, SetLocalSlot = 72, CallNamed = 73, TryBegin = 74, TryEnd = 75, Print = 76,
}
Expand description

VM opcodes — each is a single byte.

Variants§

§

Constant = 0

Push a constant from the constant pool onto the stack.

§

True = 1

Push common values without a constant pool lookup.

§

False = 2

§

Unit = 3

§

None = 4

§

Add = 5

§

Sub = 6

§

Mul = 7

§

Div = 8

§

Mod = 9

§

Neg = 10

§

BitAnd = 11

§

BitOr = 12

§

BitXor = 13

§

Shl = 14

§

Shr = 15

§

Eq = 16

§

NotEq = 17

§

Lt = 18

§

Gt = 19

§

LtEq = 20

§

GtEq = 21

§

Not = 22

§

And = 23

§

Or = 24

§

DefineLocal = 25

Define a variable in the current scope.

§

GetLocal = 26

Get a local variable by name.

§

SetLocal = 27

Set a local variable by name.

§

GetGlobal = 28

Get a global/captured variable by name.

§

SetGlobal = 29

Set a global variable.

§

Jump = 30

Unconditional jump forward.

§

JumpIfFalse = 31

Jump forward if top of stack is falsy (pops condition).

§

Loop = 32

Jump backward (for loops).

§

Call = 33

Call a function: pops func + args from stack.

§

TailCall = 34

Tail call: like Call but reuses the current frame (no stack growth).

§

Return = 35

Return from current function.

§

Pop = 36

Pop and discard the top value.

§

Dup = 37

Duplicate the top value.

§

BuildList = 38

Build a list from N values on stack.

§

BuildTuple = 39

Build a tuple from N values on stack.

§

BuildDict = 40

Build a dict from N key-value pairs on stack.

§

GetField = 41

Get field: pop object, push object.field.

§

GetIndex = 42

Index access: pop index, pop object, push object[index].

§

SetField = 43

Set field: pop value, pop object, mutate, push value.

§

SetIndex = 44

Set index: pop value, pop index, pop object, mutate, push value.

§

MethodCall = 45

Method call: pop args + receiver, push result.

§

Closure = 46

Create a closure from a function prototype.

§

WrapSome = 47

§

WrapOk = 48

§

WrapErr = 49

§

Try = 50

Try operator (?): unwrap Ok/Some or propagate Err/None.

§

PushScope = 51

§

PopScope = 52

§

BuildFString = 53

Build an f-string from N parts on stack.

§

Pipe = 54

Pipe operator: rearranges stack for function call.

§

MatchBegin = 55

Begin a match expression.

§

MatchArm = 56

Test a pattern against the match subject.

§

MatchEnd = 57

End match (cleanup).

§

BuildRange = 58

§

ConstructStruct = 59

§

ConstructEnum = 60

§

IterInit = 61

List comprehension iteration setup

§

IterNext = 62

§

ListAppend = 63

§

ListExtend = 64

Pop a list from TOS, extend the list below TOS with its items (for spread).

§

DictInsert = 65

§

DictMerge = 66

Merge a dict into the dict below it on the stack (for spread).

§

IterDrop = 67

Drop the current iterator (for break in for-loops).

§

CheckType = 68

Runtime type check: peek TOS, compare type against constant at u16 index.

§

Slice = 69

Slice access: pop end (or sentinel), pop start (or sentinel), pop object, push slice.

§

DefineLocalSlot = 70

Define a local in the slot array.

§

GetLocalSlot = 71

Get a local by slot index (relative to current frame base).

§

SetLocalSlot = 72

Set a local by slot index.

§

CallNamed = 73

Call with named arguments: u8 arg count, then u8 count of named pairs, each is u16 (arg position) + u16 (name constant)

§

TryBegin = 74

Begin a try block: push exception handler.

§

TryEnd = 75

End a try block (no error): pop handler, jump over catch.

§

Print = 76

Print (for testing/debugging)

Trait Implementations§

Source§

impl Clone for Op

Source§

fn clone(&self) -> Op

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 Op

Source§

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

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

impl PartialEq for Op

Source§

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

Source§

impl StructuralPartialEq for Op

Auto Trait Implementations§

§

impl Freeze for Op

§

impl RefUnwindSafe for Op

§

impl Send for Op

§

impl Sync for Op

§

impl Unpin for Op

§

impl UnsafeUnpin for Op

§

impl UnwindSafe for Op

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.