#[repr(u8)]pub enum Op {
Show 55 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,
GetProperty = 32,
SetProperty = 33,
SetSubscript = 34,
MethodCall = 35,
Concat = 36,
IterInit = 37,
IterNext = 38,
Pipe = 39,
Throw = 40,
TryCatchSetup = 41,
PopHandler = 42,
Parallel = 43,
ParallelMap = 44,
Spawn = 45,
Import = 46,
SelectiveImport = 47,
DeadlineSetup = 48,
DeadlineEnd = 49,
BuildEnum = 50,
MatchEnum = 51,
PopIterator = 52,
Dup = 53,
Swap = 54,
}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.
GetProperty = 32
Property access. arg: u16 = constant index (property name).
SetProperty = 33
Property assignment. arg: u16 = constant index (property name). Stack: [value] → assigns to the named variable’s property.
SetSubscript = 34
Subscript assignment. arg: u16 = constant index (variable name). Stack: [index, value] → assigns to variable[index] = value.
MethodCall = 35
Method call. arg1: u16 = constant index (method name), arg2: u8 = arg count.
Concat = 36
String concatenation of N parts. arg: u16 = part count.
IterInit = 37
Set up a for-in loop. Expects iterable on stack. Pushes iterator state.
IterNext = 38
Advance iterator. If exhausted, jumps. arg: u16 = jump offset. Pushes next value and the variable name is set via DefVar before the loop.
Pipe = 39
Pipe: pops [value, callable], invokes callable(value).
Throw = 40
Pop value, raise as error.
TryCatchSetup = 41
Push exception handler. arg: u16 = offset to catch handler.
PopHandler = 42
Remove top exception handler (end of try body).
Parallel = 43
Execute closure N times sequentially, push results as list. Stack: count, closure → result_list
ParallelMap = 44
Execute closure for each item in list, push results as list. Stack: list, closure → result_list
Spawn = 45
Store closure for deferred execution, push TaskHandle. Stack: closure → TaskHandle
Import = 46
Import a file. arg: u16 = constant index (path string).
SelectiveImport = 47
Selective import. arg1: u16 = path string, arg2: u16 = names list constant.
DeadlineSetup = 48
Pop duration value, push deadline onto internal deadline stack.
DeadlineEnd = 49
Pop deadline from internal deadline stack.
BuildEnum = 50
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 = 51
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 = 52
Pop the top iterator from the iterator stack (cleanup on break from for-in).
Dup = 53
Duplicate top of stack.
Swap = 54
Swap top two stack values.
Trait Implementations§
impl Copy for Op
impl Eq for Op
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.