full refactor on linker and verifier to become more JVM-like

This commit is contained in:
2026-03-24 13:40:30 +00:00
parent e486c1980e
commit c6411fd53c
17 changed files with 701 additions and 237 deletions
+8 -4
View File
@@ -439,7 +439,11 @@ use prometeu_abi::virtual_machine::Value;
let args_count = Syscall::from_u32(id).expect(&format!("Invalid syscall id: 0x{:08X}", id)).args_count();
let mut args = Vec::new();
for _ in 0..args_count {
args.push(vm.pop().unwrap());
// Protege contra underflow/erros de pilha durante testes
match vm.pop() {
Ok(v) => args.push(v),
Err(e) => return Err(VmFault::Panic(e)),
}
}
args.reverse();
let mut ret = HostReturn::new(&mut vm.operand_stack);
@@ -703,7 +707,7 @@ use prometeu_abi::virtual_machine::Value;
let recent = os.log_service.get_recent(1);
assert_eq!(recent[0].msg, "Tagged Log");
assert_eq!(recent[0].tag, 42);
assert_eq!(vm.pop().unwrap(), Value::Null);
// Syscall de log é void: não empurra valor na pilha
// 6. GFX Syscall return test
vm.push(Value::Int64(1)); // color_idx
@@ -1347,7 +1351,7 @@ impl NativeInterface for PrometeuOS {
_ => return Err(VmFault::Trap(prometeu_bytecode::abi::TRAP_TYPE, "Expected string message".into())),
};
self.syscall_log_write(level, 0, msg)?;
ret.push_null();
// void
Ok(())
}
// LOG_WRITE_TAG(level, tag, msg)
@@ -1359,7 +1363,7 @@ impl NativeInterface for PrometeuOS {
_ => return Err(VmFault::Trap(prometeu_bytecode::abi::TRAP_TYPE, "Expected string message".into())),
};
self.syscall_log_write(level, tag, msg)?;
ret.push_null();
// void
Ok(())
}