added domains into crates

This commit is contained in:
2026-03-24 13:40:34 +00:00
parent 1135514508
commit bddd588464
222 changed files with 751 additions and 790 deletions
@@ -0,0 +1,30 @@
use crate::call_frame::CallFrame;
use prometeu_bytecode::abi::{TrapInfo, TRAP_INVALID_LOCAL};
use prometeu_bytecode::FunctionMeta;
/// Computes the absolute stack index for the start of the current frame's locals (including args).
pub fn local_base(frame: &CallFrame) -> usize {
frame.stack_base
}
/// Computes the absolute stack index for a given local slot.
pub fn local_index(frame: &CallFrame, slot: u32) -> usize {
frame.stack_base + slot as usize
}
/// Validates that a local slot index is within the valid range for the function.
/// Range: 0 <= slot < (param_slots + local_slots)
pub fn check_local_slot(meta: &FunctionMeta, slot: u32, opcode: u16, pc: u32) -> Result<(), TrapInfo> {
let limit = meta.param_slots as u32 + meta.local_slots as u32;
if slot < limit {
Ok(())
} else {
Err(TrapInfo {
code: TRAP_INVALID_LOCAL,
opcode,
message: format!("Local slot {} out of bounds for function (limit {})", slot, limit),
pc,
span: None,
})
}
}