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
impl Executor
Sourcepub fn new() -> Self
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();Sourcepub fn execute(
&mut self,
bytecode: &Bytecode,
constants: &[Value],
) -> Result<(), ExecutionError>
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 executeconstants- Array of constant values
§Returns
Ok(())- Execution completed successfullyErr(ExecutionError)- Execution failed
§Examples
let bytecode = Bytecode::new();
let constants = vec![Value::Number(42.0)];
executor.execute(&bytecode, &constants)?;Sourcepub fn stack(&self) -> &Stack
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.
Sourcepub fn stack_mut(&mut self) -> &mut Stack
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.