#[repr(u8)]pub enum Op {
Show 82 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,
ImportGlob = 73,
CallNamed = 74,
TryBegin = 75,
TryEnd = 76,
SpawnCall = 77,
SpawnCallNamed = 78,
AwaitTask = 79,
SelectTasks = 80,
Print = 81,
}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.
ImportGlob = 73
Import every entry from a module dict on TOS into the current env scope.
CallNamed = 74
Call with named arguments: u8 arg count, then u8 count of named pairs, each is u16 (arg position) + u16 (name constant)
TryBegin = 75
Begin a try block: push exception handler.
TryEnd = 76
End a try block (no error): pop handler, jump over catch.
SpawnCall = 77
Spawn a function call as an async runtime task: pops func + args, pushes AsyncTask.
SpawnCallNamed = 78
Spawn a function call with named arguments as an async runtime task.
AwaitTask = 79
Await an AsyncTask by parking this VM continuation on the runtime future table.
SelectTasks = 80
Race N AsyncTask handles and push (winner_index, value) when one completes.
Print = 81
Print (for testing/debugging)