clean up
This commit is contained in:
parent
7eb2e5d75b
commit
c80260e780
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user