diff --git a/lunar_wave_vm/src/state.rs b/lunar_wave_vm/src/state.rs index 23bf773..6863a6f 100644 --- a/lunar_wave_vm/src/state.rs +++ b/lunar_wave_vm/src/state.rs @@ -261,7 +261,8 @@ impl State { /// Short form to get access to a register within our window pub fn reg (&self, i: u8) -> &Value { - &self.registers [self.stack_top.register_offset + i as usize] + let idx = self.stack_top.register_offset + i as usize; + &self.registers [idx] } pub fn reg_mut (&mut self, i: u8) -> &mut Value { @@ -487,18 +488,28 @@ impl State { true } - pub fn step (&mut self) -> Result