pub enum OpCode {
Show 26 variants
Constant,
Add,
Subtract,
Multiply,
Divide,
Negate,
Return,
Print,
GetVariable,
SetVariable,
Pop,
DefineFunction,
Call,
JumpIfFalse,
Jump,
BoolNot,
BoolAnd,
BoolOr,
Greater,
Less,
GreaterEqual,
LessEqual,
Equal,
NotEqual,
BeginScope,
EndScope,
}
Expand description
Operation codes for the bytecode interpreter
Variants§
Constant
Push a constant onto the stack
Add
Add the top two stack values
Subtract
Subtract the top stack value from the second stack value
Multiply
Multiply the top two stack values
Divide
Divide the second stack value by the top stack value
Negate
Negate the top stack value
Return
Return from the current function
Print the top stack value
GetVariable
Push the value of a variable onto the stack
SetVariable
Set a variable to the top stack value
Pop
Remove the top stack value
DefineFunction
Define a function
Call
Call a function
JumpIfFalse
Jump if the top stack value is false
Jump
Jump unconditionally
BoolNot
Negate a boolean value (logical NOT)
BoolAnd
Boolean AND operation
BoolOr
Boolean OR operation
Greater
Greater than comparison
Less
Less than comparison
GreaterEqual
Greater than or equal comparison
LessEqual
Less than or equal comparison
Equal
Equal comparison
NotEqual
Not equal comparison
BeginScope
Begin a new scope (save variable state)
EndScope
End the current scope (restore variable state)