clean up
This commit is contained in:
parent
7eb2e5d75b
commit
c80260e780
@ -105,8 +105,6 @@ mod tests {
|
||||
spec.is_terminator,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -950,28 +950,28 @@ impl VirtualMachine {
|
||||
Ok(entry)
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
let idx = gate_id as usize;
|
||||
if idx >= self.gate_pool.len() {
|
||||
return Err(self.trap(
|
||||
TRAP_INVALID_GATE,
|
||||
opcode,
|
||||
format!("Invalid gate id: {}", gate_id),
|
||||
pc,
|
||||
));
|
||||
}
|
||||
if !self.gate_pool[idx].alive {
|
||||
return Err(self.trap(
|
||||
TRAP_DEAD_GATE,
|
||||
opcode,
|
||||
format!("Dead gate id: {}", gate_id),
|
||||
pc,
|
||||
));
|
||||
}
|
||||
// This borrow is safe because we validated bounds and liveness without using closures.
|
||||
Ok(&mut self.gate_pool[idx])
|
||||
}
|
||||
// /// 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> {
|
||||
// let idx = gate_id as usize;
|
||||
// if idx >= self.gate_pool.len() {
|
||||
// return Err(self.trap(
|
||||
// TRAP_INVALID_GATE,
|
||||
// opcode,
|
||||
// format!("Invalid gate id: {}", gate_id),
|
||||
// pc,
|
||||
// ));
|
||||
// }
|
||||
// if !self.gate_pool[idx].alive {
|
||||
// return Err(self.trap(
|
||||
// TRAP_DEAD_GATE,
|
||||
// opcode,
|
||||
// format!("Dead gate id: {}", gate_id),
|
||||
// pc,
|
||||
// ));
|
||||
// }
|
||||
// // This borrow is safe because we validated bounds and liveness without using closures.
|
||||
// Ok(&mut self.gate_pool[idx])
|
||||
// }
|
||||
|
||||
pub fn trap(&self, code: u32, opcode: u16, message: String, pc: u32) -> LogicalFrameEndingReason {
|
||||
LogicalFrameEndingReason::Trap(self.program.create_trap(code, opcode, message, pc))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user