Struct Executor

Source
pub struct Executor { /* private fields */ }
Expand description

Main VM executor that combines all execution components

Provides a high-level interface for executing bytecode by integrating stack management, heap management, variable management, and instruction execution into a single, cohesive system.

Implementations§

Source§

impl Executor

Source

pub fn new() -> Self

Creates a new executor with default components

Initializes the executor with new instances of all required components: stack manager, heap manager, variable manager, and instruction executor.

§Returns

A new executor ready for bytecode execution

§Examples
use jetcrab::vm::executor::Executor;

let mut executor = Executor::new();
Source

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

Executes bytecode with the provided constants

Runs the complete execution cycle for the given bytecode, using the provided constants array for constant lookups.

§Arguments
  • bytecode - The bytecode to execute
  • constants - Array of constant values
§Returns
  • Ok(()) - Execution completed successfully
  • Err(ExecutionError) - Execution failed
§Examples
let bytecode = Bytecode::new();
let constants = vec![Value::Number(42.0)];
executor.execute(&bytecode, &constants)?;
Source

pub fn stack(&self) -> &Stack

Gets read-only access to the VM stack

Provides access to the current state of the execution stack for inspection and debugging purposes.

Source

pub fn stack_mut(&mut self) -> &mut Stack

Gets mutable access to the VM stack

Provides write access to the execution stack for direct manipulation and testing purposes.

Source

pub fn heap(&self) -> &Heap

Gets read-only access to the VM heap

Provides access to the current state of the execution heap for inspection and debugging purposes.

Source

pub fn heap_mut(&mut self) -> &mut Heap

Gets mutable access to the VM heap

Provides write access to the execution heap for direct manipulation and testing purposes.

Trait Implementations§

Source§

impl Default for Executor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.