Module executor

Source
Expand description

§VM Executor Module

This module provides the execution engine for the JetCrab virtual machine. It handles instruction execution, control flow, and memory management through a modular architecture of specialized handlers.

§Architecture

The executor is built around several key components:

  • Instruction Handlers: Specialized modules for different types of operations
  • Instruction Dispatcher: Routes instructions to appropriate handlers
  • Traits: Define interfaces for stack, heap, and variable operations
  • Error Handling: Comprehensive error handling and recovery

§Usage

use jetcrab::vm::executor::{InstructionExecutor, InstructionExecutorImpl};
use jetcrab::vm::bytecode::Bytecode;
use jetcrab::vm::value::Value;

let mut executor = InstructionExecutorImpl::new();
let bytecode = Bytecode::new();
let constants = vec![Value::Number(42.0)];

match executor.execute(&bytecode, &constants) {
    Ok(()) => println!("Execution completed successfully"),
    Err(e) => eprintln!("Execution failed: {:?}", e),
}

Re-exports§

pub use error_handler::ExecutionError;
pub use instruction_dispatcher::InstructionDispatcher;
pub use instruction_executor::InstructionExecutorImpl;
pub use traits::HeapOperations;
pub use traits::InstructionExecutor;
pub use traits::StackOperations;
pub use traits::VariableManager;
pub use core::Executor;

Modules§

core
VM Executor Core
error_handler
Execution Error Handler
heap_manager
Heap Manager
instruction_dispatcher
Instruction Dispatcher
instruction_executor
Instruction Executor Implementation
instruction_handlers
Instruction Handlers Module
stack_manager
Stack Manager
traits
VM Execution Traits
variable_manager
Variable Manager