Expand description
§Arithmetic Handler
Handles all arithmetic operations in the VM including basic math operations, increment/decrement operations, and power operations.
§Operations Supported
- Basic Arithmetic: add, subtract, multiply, divide, modulo
- Power Operations: power (exponentiation)
- Increment/Decrement: increment, decrement
- Unary Operations: negate
§Error Handling
All operations return Result<(), ExecutionError> and handle:
- Stack underflow (insufficient operands)
- Division by zero
- Invalid numeric operations
§Usage
use jetcrab::vm::executor::instruction_handlers::ArithmeticHandler;
use jetcrab::vm::executor::traits::StackOperations;
let mut stack = MyStack::new();
stack.push(Value::Number(5.0));
stack.push(Value::Number(3.0));
ArithmeticHandler::add(&mut stack)?;
// Stack now contains: [8.0]Structs§
- Arithmetic
Handler - Handles arithmetic operations for the VM