This commit is contained in:
2026-03-24 13:40:37 +00:00
parent 650f1e0716
commit 46146993aa
4 changed files with 80 additions and 103 deletions
@@ -5,6 +5,7 @@ use crate::{HostContext, NativeInterface};
use prometeu_bytecode::isa::core::CoreOpCode as OpCode;
use prometeu_bytecode::ProgramImage;
use prometeu_bytecode::Value;
use crate::heap::Heap;
use prometeu_bytecode::{
TRAP_BAD_RET_SLOTS, TRAP_DIV_ZERO, TRAP_INVALID_FUNC, TRAP_INVALID_SYSCALL, TRAP_OOB,
TRAP_STACK_UNDERFLOW, TRAP_TYPE, TrapInfo,
@@ -83,7 +84,7 @@ pub struct VirtualMachine {
/// The loaded executable (Bytecode + Constant Pool), that is the ROM translated.
pub program: ProgramImage,
/// Heap Memory: Dynamic allocation pool.
pub heap: Vec<Value>,
pub heap: Heap,
/// Total virtual cycles consumed since the VM started.
pub cycles: u64,
/// Stop flag: true if a `HALT` opcode was encountered.
@@ -114,7 +115,7 @@ impl VirtualMachine {
None,
std::collections::HashMap::new(),
),
heap: Vec::new(),
heap: Heap::new(),
cycles: 0,
halted: false,
breakpoints: std::collections::HashSet::new(),
@@ -135,7 +136,7 @@ impl VirtualMachine {
self.operand_stack.clear();
self.call_stack.clear();
self.globals.clear();
self.heap.clear();
self.heap = Heap::new();
self.cycles = 0;
self.halted = true; // execution is impossible until a successful load