Module instruction_dispatcher

Source
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

  1. Instruction is received with VM state
  2. Dispatcher matches instruction type
  3. Appropriate handler is called
  4. 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§

InstructionDispatcher
Central instruction dispatcher for the VM