diff --git a/hbvm/src/vm/mod.rs b/hbvm/src/vm/mod.rs index 69fe6b6..40b4d62 100644 --- a/hbvm/src/vm/mod.rs +++ b/hbvm/src/vm/mod.rs @@ -36,7 +36,7 @@ macro_rules! load { *$self.reg_mut(tg) = $self .memory .load::<$size>($self.reg(a0).int() + offset) - .unwrap(); + .ok_or(Exception::LoadAccess)?; }}; } @@ -46,7 +46,7 @@ macro_rules! store { $self .memory .store::<$size>($self.reg(a0).int() + offset, *$self.reg(src)) - .unwrap(); + .map_err(|_| Exception::StoreAccess)?; }}; } @@ -74,11 +74,11 @@ impl<'a> Vm<'a> { Ok(unsafe { Self::new_unchecked(program) }) } - pub fn run(&mut self) { + pub fn run(&mut self) -> Result<(), Exception> { use hbbytecode::opcode::*; loop { let Some(&opcode) = self.program.get(self.pc) - else { return }; + else { return Ok(()) }; unsafe { match opcode {