This commit is contained in:
bQUARKz 2026-02-10 13:31:15 +00:00
parent 7eb2e5d75b
commit c80260e780
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
2 changed files with 22 additions and 24 deletions

View File

@ -105,8 +105,6 @@ mod tests {
spec.is_terminator, spec.is_terminator,
spec.may_trap, spec.may_trap,
); );
// imm_bytes must be defined (0 is valid)
assert!(spec.imm_bytes >= 0, "imm_bytes must be defined for {op:?}");
count += 1; count += 1;
} }
} }

View File

@ -950,28 +950,28 @@ impl VirtualMachine {
Ok(entry) Ok(entry)
} }
/// Resolves a `GateId` to a mutable reference to its `GateEntry` or returns a trap reason. // /// Resolves a `GateId` to a mutable reference to its `GateEntry` or returns a trap reason.
fn resolve_gate_mut(&mut self, gate_id: GateId, opcode: u16, pc: u32) -> Result<&mut GateEntry, LogicalFrameEndingReason> { // fn resolve_gate_mut(&mut self, gate_id: GateId, opcode: u16, pc: u32) -> Result<&mut GateEntry, LogicalFrameEndingReason> {
let idx = gate_id as usize; // let idx = gate_id as usize;
if idx >= self.gate_pool.len() { // if idx >= self.gate_pool.len() {
return Err(self.trap( // return Err(self.trap(
TRAP_INVALID_GATE, // TRAP_INVALID_GATE,
opcode, // opcode,
format!("Invalid gate id: {}", gate_id), // format!("Invalid gate id: {}", gate_id),
pc, // pc,
)); // ));
} // }
if !self.gate_pool[idx].alive { // if !self.gate_pool[idx].alive {
return Err(self.trap( // return Err(self.trap(
TRAP_DEAD_GATE, // TRAP_DEAD_GATE,
opcode, // opcode,
format!("Dead gate id: {}", gate_id), // format!("Dead gate id: {}", gate_id),
pc, // pc,
)); // ));
} // }
// This borrow is safe because we validated bounds and liveness without using closures. // // This borrow is safe because we validated bounds and liveness without using closures.
Ok(&mut self.gate_pool[idx]) // Ok(&mut self.gate_pool[idx])
} // }
pub fn trap(&self, code: u32, opcode: u16, message: String, pc: u32) -> LogicalFrameEndingReason { pub fn trap(&self, code: u32, opcode: u16, message: String, pc: u32) -> LogicalFrameEndingReason {
LogicalFrameEndingReason::Trap(self.program.create_trap(code, opcode, message, pc)) LogicalFrameEndingReason::Trap(self.program.create_trap(code, opcode, message, pc))