pub enum Opcode {
}Expand description
A single bytecode instruction.
Variants§
Push(u64)
Push a natural number onto the stack.
PushBool(bool)
Push a boolean onto the stack.
PushStr(String)
Push a string onto the stack.
PushNil
Push nil (unit) onto the stack.
Pop
Discard the top of the stack.
Dup
Duplicate the top of the stack.
Swap
Swap the top two stack elements.
Add
Add the top two naturals.
Sub
Subtract (second - top).
Mul
Multiply the top two naturals.
Div
Divide (second / top). Errors on division by zero.
Mod
Modulo (second % top). Errors on division by zero.
Eq
Equality comparison; pushes Bool.
Lt
Less-than comparison; pushes Bool.
Le
Less-than-or-equal comparison; pushes Bool.
Not
Boolean NOT.
And
Boolean AND.
Or
Boolean OR.
Jump(i32)
Unconditional jump by a signed offset from the next instruction.
JumpIf(i32)
Jump if the top of the stack is Bool(true) (pops the condition).
JumpIfNot(i32)
Jump if the top of the stack is Bool(false) (pops the condition).
Call(u32)
Call a function at position u32 in the chunk (simplified model).
Return
Return from the current function.
Load(u32)
Load local variable at index.
Store(u32)
Store top-of-stack into local variable at index (does not pop).
LoadGlobal(String)
Load a named global value.
MakeClosure(u32)
Create a closure over u32 captured values from the stack.
Apply
Apply a closure on the stack to the argument below it.
Halt
Stop execution.