Skip to main content

Op

Enum Op 

Source
#[repr(u8)]
pub enum Op {
Show 60 variants Constant = 0, Nil = 1, True = 2, False = 3, GetVar = 4, DefLet = 5, DefVar = 6, SetVar = 7, Add = 8, Sub = 9, Mul = 10, Div = 11, Mod = 12, Negate = 13, Equal = 14, NotEqual = 15, Less = 16, Greater = 17, LessEqual = 18, GreaterEqual = 19, Not = 20, Jump = 21, JumpIfFalse = 22, JumpIfTrue = 23, Pop = 24, Call = 25, TailCall = 26, Return = 27, Closure = 28, BuildList = 29, BuildDict = 30, Subscript = 31, Slice = 32, GetProperty = 33, GetPropertyOpt = 34, SetProperty = 35, SetSubscript = 36, MethodCall = 37, MethodCallOpt = 38, Concat = 39, IterInit = 40, IterNext = 41, Pipe = 42, Throw = 43, TryCatchSetup = 44, PopHandler = 45, Parallel = 46, ParallelMap = 47, Spawn = 48, Import = 49, SelectiveImport = 50, DeadlineSetup = 51, DeadlineEnd = 52, BuildEnum = 53, MatchEnum = 54, PopIterator = 55, GetArgc = 56, CheckType = 57, Dup = 58, Swap = 59,
}
Expand description

Bytecode opcodes for the Harn VM.

Variants§

§

Constant = 0

Push a constant from the constant pool onto the stack.

§

Nil = 1

Push nil onto the stack.

§

True = 2

Push true onto the stack.

§

False = 3

Push false onto the stack.

§

GetVar = 4

Get a variable by name (from constant pool).

§

DefLet = 5

Define a new immutable variable. Pops value from stack.

§

DefVar = 6

Define a new mutable variable. Pops value from stack.

§

SetVar = 7

Assign to an existing mutable variable. Pops value from stack.

§

Add = 8

§

Sub = 9

§

Mul = 10

§

Div = 11

§

Mod = 12

§

Negate = 13

§

Equal = 14

§

NotEqual = 15

§

Less = 16

§

Greater = 17

§

LessEqual = 18

§

GreaterEqual = 19

§

Not = 20

§

Jump = 21

Jump unconditionally. arg: u16 offset.

§

JumpIfFalse = 22

Jump if top of stack is falsy. Does not pop. arg: u16 offset.

§

JumpIfTrue = 23

Jump if top of stack is truthy. Does not pop. arg: u16 offset.

§

Pop = 24

Pop top of stack (discard).

§

Call = 25

Call a function/builtin. arg: u8 = arg count. Name is on stack below args.

§

TailCall = 26

Tail call: like Call, but replaces the current frame instead of pushing a new one. Used for return f(x) to enable tail call optimization. For builtins, behaves like a regular Call (no frame to replace).

§

Return = 27

Return from current function. Pops return value.

§

Closure = 28

Create a closure. arg: u16 = chunk index in function table.

§

BuildList = 29

Build a list. arg: u16 = element count. Elements are on stack.

§

BuildDict = 30

Build a dict. arg: u16 = entry count. Key-value pairs on stack.

§

Subscript = 31

Subscript access: stack has [object, index]. Pushes result.

§

Slice = 32

Slice access: stack has [object, start_or_nil, end_or_nil]. Pushes sublist/substring.

§

GetProperty = 33

Property access. arg: u16 = constant index (property name).

§

GetPropertyOpt = 34

Optional property access (?.). Like GetProperty but returns nil instead of erroring when the object is nil. arg: u16 = constant index.

§

SetProperty = 35

Property assignment. arg: u16 = constant index (property name). Stack: [value] → assigns to the named variable’s property.

§

SetSubscript = 36

Subscript assignment. arg: u16 = constant index (variable name). Stack: [index, value] → assigns to variable[index] = value.

§

MethodCall = 37

Method call. arg1: u16 = constant index (method name), arg2: u8 = arg count.

§

MethodCallOpt = 38

Optional method call (?.). Like MethodCall but returns nil if the receiver is nil instead of dispatching. arg1: u16, arg2: u8.

§

Concat = 39

String concatenation of N parts. arg: u16 = part count.

§

IterInit = 40

Set up a for-in loop. Expects iterable on stack. Pushes iterator state.

§

IterNext = 41

Advance iterator. If exhausted, jumps. arg: u16 = jump offset. Pushes next value and the variable name is set via DefVar before the loop.

§

Pipe = 42

Pipe: pops [value, callable], invokes callable(value).

§

Throw = 43

Pop value, raise as error.

§

TryCatchSetup = 44

Push exception handler. arg: u16 = offset to catch handler.

§

PopHandler = 45

Remove top exception handler (end of try body).

§

Parallel = 46

Execute closure N times sequentially, push results as list. Stack: count, closure → result_list

§

ParallelMap = 47

Execute closure for each item in list, push results as list. Stack: list, closure → result_list

§

Spawn = 48

Store closure for deferred execution, push TaskHandle. Stack: closure → TaskHandle

§

Import = 49

Import a file. arg: u16 = constant index (path string).

§

SelectiveImport = 50

Selective import. arg1: u16 = path string, arg2: u16 = names list constant.

§

DeadlineSetup = 51

Pop duration value, push deadline onto internal deadline stack.

§

DeadlineEnd = 52

Pop deadline from internal deadline stack.

§

BuildEnum = 53

Build an enum variant value. arg1: u16 = constant index (enum name), arg2: u16 = constant index (variant name), arg3: u16 = field count. Fields are on stack.

§

MatchEnum = 54

Match an enum pattern. Checks enum_name + variant on the top of stack (dup’d match value). arg1: u16 = constant index (enum name), arg2: u16 = constant index (variant name). If match succeeds, pushes true; else pushes false.

§

PopIterator = 55

Pop the top iterator from the iterator stack (cleanup on break from for-in).

§

GetArgc = 56

Push the number of arguments passed to the current function call.

§

CheckType = 57

Runtime type check on a variable. arg1: u16 = constant index (variable name), arg2: u16 = constant index (expected type name). Throws a TypeError if the variable’s type doesn’t match.

§

Dup = 58

Duplicate top of stack.

§

Swap = 59

Swap top two stack values.

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 Eq 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more