dev/pbs #8

Merged
bquarkz merged 74 commits from dev/pbs into master 2026-02-03 15:28:31 +00:00
4 changed files with 7 additions and 3 deletions
Showing only changes of commit b6912c4369 - Show all commits

View File

@ -230,7 +230,6 @@ impl Linker {
// Final Exports map for ProgramImage (String -> func_idx)
// Only including exports from the ROOT project (the last one in build plan usually)
// Wait, the requirement says "emit final PBS v0 image".
// In PBS v0, exports are name -> func_id.
let mut final_exports = HashMap::new();
if let Some(root_module) = modules.last() {
@ -241,8 +240,9 @@ impl Linker {
}
}
}
// v0: Fallback export for entrypoint `src/main/modules:frame` (root module)
if !final_exports.contains_key("src/main/modules:frame") {
if !final_exports.iter().any(|(name, _)| name.ends_with(":frame")) {
if let Some(&root_offset) = module_function_offsets.last() {
if let Some((idx, _)) = combined_function_names.iter().find(|(i, name)| *i >= root_offset && name == "frame") {
final_exports.insert("src/main/modules:frame".to_string(), *idx);

View File

@ -67,7 +67,7 @@ fn test_integration_test01_link() {
let mut vm = VirtualMachine::default();
// Use initialize to load the ROM and resolve entrypoint
vm.initialize(unit.rom, "src/main/modules:frame").expect("Failed to initialize VM");
vm.initialize(unit.rom, "frame").expect("Failed to initialize VM");
let mut native = SimpleNative;
let mut hw = SimpleHardware::new();

View File

@ -160,6 +160,8 @@ impl VirtualMachine {
// Try to resolve symbol name via ProgramImage exports
if let Some(&func_idx) = program.exports.get(entrypoint) {
program.functions[func_idx as usize].code_offset as usize
} else if let Some(&func_idx) = program.exports.get(&format!("src/main/modules:{}", entrypoint)) {
program.functions[func_idx as usize].code_offset as usize
} else {
return Err(VmInitError::EntrypointNotFound);
}
@ -183,6 +185,8 @@ impl VirtualMachine {
(addr, idx)
} else if let Some(&func_idx) = self.program.exports.get(entrypoint) {
(self.program.functions[func_idx as usize].code_offset as usize, func_idx as usize)
} else if let Some(&func_idx) = self.program.exports.get(&format!("src/main/modules:{}", entrypoint)) {
(self.program.functions[func_idx as usize].code_offset as usize, func_idx as usize)
} else {
(0, 0)
};