diff --git a/components/lox-compile/src/compile.rs b/components/lox-compile/src/compile.rs index cce0dc2..c445982 100644 --- a/components/lox-compile/src/compile.rs +++ b/components/lox-compile/src/compile.rs @@ -28,7 +28,7 @@ fn compile_expr(db: &dyn crate::Db, expr: &syntax::Expr, chunk: &mut Chunk) { } else { chunk.emit_byte(Code::False) } - }, + } syntax::Expr::NilLiteral => todo!(), syntax::Expr::BinaryOp(left, op, right) => { compile_expr(db, left, chunk); diff --git a/components/lox-execute/src/execute.rs b/components/lox-execute/src/execute.rs index 31783ea..03b6f28 100644 --- a/components/lox-execute/src/execute.rs +++ b/components/lox-execute/src/execute.rs @@ -1,9 +1,13 @@ use lox_compile::compile; -use lox_ir::{input_file::InputFile, bytecode}; +use lox_ir::{bytecode, input_file::InputFile}; use crate::vm::VM; -pub fn execute_file(db: &impl crate::Db, input_file: InputFile, step_inspect: Option) { +pub fn execute_file( + db: &impl crate::Db, + input_file: InputFile, + step_inspect: Option, +) { let chunk = compile::compile_file(db, input_file); let mut vm = VM::new(chunk); vm.interpret(step_inspect) diff --git a/components/lox-execute/src/vm.rs b/components/lox-execute/src/vm.rs index 04065b4..2c1fee5 100644 --- a/components/lox-execute/src/vm.rs +++ b/components/lox-execute/src/vm.rs @@ -82,7 +82,9 @@ impl VM { // `step_inspect` is a callback that is called after each instruction is executed. // It is useful for debugging. pub fn interpret(&mut self, mut step_inspect: Option) - where F: FnMut(bytecode::Code, &VM) { + where + F: FnMut(bytecode::Code, &VM), + { loop { if self.chunk.len() <= self.ip { break; @@ -115,10 +117,10 @@ impl VM { } bytecode::Code::True => { self.push(true); - }, + } bytecode::Code::False => { self.push(false); - }, + } } if let Some(step_inspect) = &mut step_inspect { step_inspect(instruction, self); @@ -136,7 +138,10 @@ impl VM { self.stack.pop().unwrap() } - fn push(&mut self, value: T) where T: Into { + fn push(&mut self, value: T) + where + T: Into, + { self.stack.push(value.into()); } } diff --git a/src/main.rs b/src/main.rs index a1542c2..0a9ee17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,7 +48,7 @@ impl TestCase { } use expect_test::expect_file; -use lox_ir::{diagnostic::Diagnostics, input_file::InputFile, word::Word, bytecode}; +use lox_ir::{bytecode, diagnostic::Diagnostics, input_file::InputFile, word::Word}; #[salsa::db( lox_parse::Jar,