Struct InstructionExecutorImpl

Source
pub struct InstructionExecutorImpl<S, H, V>{ /* private fields */ }
Expand description

Concrete implementation of the instruction executor

Orchestrates VM execution by coordinating between stack, heap, and variable management systems. Provides the main execution loop that processes bytecode instructions sequentially.

§Type Parameters

  • S - Stack operations implementation
  • H - Heap operations implementation
  • V - Variable management implementation

§Examples

use jetcrab::vm::executor::instruction_executor::InstructionExecutorImpl;

let executor = InstructionExecutorImpl::new(
    my_stack_manager,
    my_heap_manager,
    my_variable_manager,
);

Implementations§

Source§

impl<S, H, V> InstructionExecutorImpl<S, H, V>

Source

pub fn new(stack_manager: S, heap_manager: H, variable_manager: V) -> Self

Creates a new instruction executor with the provided managers

Initializes the executor with concrete implementations for stack, heap, and variable management, along with default instances of frame, registers, builtins, and context cache.

§Arguments
  • stack_manager - Implementation for stack operations
  • heap_manager - Implementation for heap operations
  • variable_manager - Implementation for variable management
§Returns

A new instruction executor ready for bytecode execution

§Examples
let executor = InstructionExecutorImpl::new(
    StackManager::new(),
    HeapManager::new(),
    VariableManagerImpl::new(),
);
Source

pub fn stack_manager(&self) -> &S

Gets a reference to the stack manager

Provides read-only access to the stack manager for inspection of stack state without modification.

Source

pub fn stack_manager_mut(&mut self) -> &mut S

Gets a mutable reference to the stack manager

Provides write access to the stack manager for stack operations like push, pop, and other manipulations.

Source

pub fn heap_manager(&self) -> &H

Gets a reference to the heap manager

Provides read-only access to the heap manager for inspection of heap state and object access.

Source

pub fn heap_manager_mut(&mut self) -> &mut H

Gets a mutable reference to the heap manager

Provides write access to the heap manager for object allocation, deallocation, and garbage collection operations.

Source

pub fn variable_manager(&self) -> &V

Gets a reference to the variable manager

Provides read-only access to the variable manager for variable lookups and scope inspection.

Source

pub fn variable_manager_mut(&mut self) -> &mut V

Gets a mutable reference to the variable manager

Provides write access to the variable manager for variable assignment, scope management, and variable operations.

Trait Implementations§

Source§

impl<S, H, V> InstructionExecutor for InstructionExecutorImpl<S, H, V>

Source§

fn execute( &mut self, bytecode: &Bytecode, constants: &[Value], ) -> Result<(), ExecutionError>

Executes bytecode instructions sequentially

Processes bytecode instructions one by one, maintaining VM state through the managed components. Handles control flow changes, stack operations, heap management, and variable operations.

§Arguments
  • bytecode - The bytecode containing instructions to execute
  • constants - Array of constant values referenced by instructions
§Returns
  • Ok(()) - Execution completed successfully
  • Err(ExecutionError) - Execution failed with specific error
§Examples
let bytecode = Bytecode::new();
let constants = vec![Value::Number(42.0)];

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

Auto Trait Implementations§

§

impl<S, H, V> Freeze for InstructionExecutorImpl<S, H, V>
where S: Freeze, H: Freeze, V: Freeze,

§

impl<S, H, V> !RefUnwindSafe for InstructionExecutorImpl<S, H, V>

§

impl<S, H, V> !Send for InstructionExecutorImpl<S, H, V>

§

impl<S, H, V> !Sync for InstructionExecutorImpl<S, H, V>

§

impl<S, H, V> Unpin for InstructionExecutorImpl<S, H, V>
where S: Unpin, H: Unpin, V: Unpin,

§

impl<S, H, V> !UnwindSafe for InstructionExecutorImpl<S, H, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.