1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00

refactor: fold brackets

This commit is contained in:
Natapat Samutpong 2022-01-27 12:44:11 +07:00
parent 93f8f57db8
commit bb86934b53

View file

@ -39,14 +39,10 @@ impl VM {
pub fn run(&mut self, instrs: Vec<Instr>, debug: bool) -> VMReturn {
'tco: loop {
self.instr_pointer += 1;
if self.instr_pointer - 1 == instrs.len() as isize {
return Ok(());
}
if self.instr_pointer - 1 == instrs.len() as isize { return Ok(()); }
let instr = &instrs[self.instr_pointer as usize - 1];
if debug {
println!("ptr: {} | stack: {:?} | curr: {}", self.instr_pointer - 1, &self.stack, &instr);
}
if debug { println!("ptr: {} | stack: {:?} | curr: {}", self.instr_pointer - 1, &self.stack, &instr); }
match instr {
Store { address, value, .. } => {
self.store(&address, &value)?;
@ -97,14 +93,10 @@ impl VM {
},
PopJumpIfFalse { to, .. } => {
let value = self.stack.pop().unwrap();
if !value.as_bool() {
self.instr_pointer = *to as isize - 1;
}
if !value.as_bool() { self.instr_pointer = *to as isize - 1; }
continue 'tco;
},
Return { .. } => {
return Ok(());
},
Return { .. } => return Ok(()),
};
}
}