Module stack_ops

Source
Expand description

§Stack Operations Handler

Handles all stack manipulation operations in the VM including pushing, popping, duplicating, and other stack management operations.

§Operations Supported

  • Basic Operations: push, pop, peek
  • Duplication: dup, dup2
  • Rearrangement: swap, rot, over
  • Removal: drop, drop2, clear
  • Information: size, is_empty, depth
  • Advanced: reserve, truncate

§Stack Semantics

  • LIFO: Last In, First Out stack behavior
  • Type Safety: All operations maintain type safety
  • Bounds Checking: Prevents stack underflow/overflow
  • Performance: Optimized for common operations

§Usage

use jetcrab::vm::executor::instruction_handlers::StackOpsHandler;
use jetcrab::vm::executor::traits::StackOperations;

let mut stack = MyStack::new();
stack.push(Value::Number(42.0));
StackOpsHandler::dup(&mut stack)?;
// Stack now contains: [42.0, 42.0]

Structs§

StackOpsHandler
Handles stack operations for the VM