Expand description
§Instruction Dispatcher
Central dispatcher that routes VM instructions to their appropriate handlers. This module provides the main execution logic that determines which handler should process each instruction type.
§Architecture
The dispatcher follows a pattern where each instruction type is mapped to a specific handler:
- Stack Operations: Handled by
StackOpsHandler - Arithmetic Operations: Handled by
ArithmeticHandler - Comparison Operations: Handled by
ComparisonHandler - Control Flow Operations: Handled by
ControlFlowHandler - Heap Operations: Handled by
HeapOpsHandler - Builtin Calls: Handled by
BuiltinCallsHandler
§Execution Flow
- Instruction is received with VM state
- Dispatcher matches instruction type
- Appropriate handler is called
- Result is returned (optional new instruction pointer)
§Usage
use jetcrab::vm::executor::instruction_dispatcher::InstructionDispatcher;
use jetcrab::vm::instructions::Instruction;
let result = InstructionDispatcher::execute_instruction(
&instruction,
&mut stack,
&mut heap,
&mut variables,
&mut frame,
&mut registers,
&mut builtins,
)?;Structs§
- Instruction
Dispatcher - Central instruction dispatcher for the VM