This commit is contained in:
Nilton Constantino
2026-02-02 19:57:04 +00:00
parent b6912c4369
commit b4deaa243e
19 changed files with 66 additions and 136 deletions
+14 -2
View File
@@ -6,6 +6,7 @@ use prometeu_core::virtual_machine::{LogicalFrameEndingReason, VirtualMachine};
use prometeu_core::Hardware;
use std::fs;
use std::path::Path;
use prometeu_bytecode::BytecodeLoader;
struct MockNative;
impl NativeInterface for MockNative {
@@ -37,10 +38,21 @@ fn test_canonical_cartridge_heartbeat() {
}
let pbc_bytes = fs::read(pbc_path).expect("Failed to read canonical PBC. Did you run the generation test?");
// Determine numeric entrypoint PC from the compiled module exports
let module = BytecodeLoader::load(&pbc_bytes).expect("Failed to parse PBC");
let func_idx = module
.exports
.iter()
.find(|e| e.symbol == "src/main/modules:frame")
.map(|e| e.func_idx as usize)
.expect("Entrypoint symbol not found in exports");
let entry_pc = module.functions[func_idx].code_offset as usize;
let entry_pc_str = entry_pc.to_string();
let mut vm = VirtualMachine::new(vec![], vec![]);
vm.initialize(pbc_bytes, "src/main/modules:frame").expect("Failed to initialize VM with canonical cartridge");
vm.prepare_call("src/main/modules:frame");
vm.initialize(pbc_bytes, &entry_pc_str).expect("Failed to initialize VM with canonical cartridge");
vm.prepare_call(&entry_pc_str);
let mut native = MockNative;
let mut hw = Hardware::new();