jetcrab\vm\executor/
mod.rs

1//! # VM Executor Module
2//!
3//! This module provides the execution engine for the JetCrab virtual machine.
4//! It handles instruction execution, control flow, and memory management through
5//! a modular architecture of specialized handlers.
6//!
7//! ## Architecture
8//!
9//! The executor is built around several key components:
10//!
11//! - **Instruction Handlers**: Specialized modules for different types of operations
12//! - **Instruction Dispatcher**: Routes instructions to appropriate handlers
13//! - **Traits**: Define interfaces for stack, heap, and variable operations
14//! - **Error Handling**: Comprehensive error handling and recovery
15//!
16//! ## Usage
17//!
18//! ```rust
19//! use jetcrab::vm::executor::{InstructionExecutor, InstructionExecutorImpl};
20//! use jetcrab::vm::bytecode::Bytecode;
21//! use jetcrab::vm::value::Value;
22//!
23//! let mut executor = InstructionExecutorImpl::new();
24//! let bytecode = Bytecode::new();
25//! let constants = vec![Value::Number(42.0)];
26//!
27//! match executor.execute(&bytecode, &constants) {
28//!     Ok(()) => println!("Execution completed successfully"),
29//!     Err(e) => eprintln!("Execution failed: {:?}", e),
30//! }
31//! ```
32
33pub mod error_handler;
34pub mod instruction_dispatcher;
35pub mod instruction_handlers;
36pub mod instruction_executor;
37pub mod traits;
38pub mod stack_manager;
39pub mod heap_manager;
40pub mod variable_manager;
41
42pub use error_handler::ExecutionError;
43pub use instruction_dispatcher::InstructionDispatcher;
44pub use instruction_executor::InstructionExecutorImpl;
45pub use traits::{HeapOperations, InstructionExecutor, StackOperations, VariableManager};
46
47pub mod core;
48pub use core::Executor;