forked from AbleOS/holey-bytes
VM exceptions
This commit is contained in:
parent
859e14daa6
commit
fce7a96e50
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue