Skip to content

Commit

Permalink
make fmt happy
Browse files Browse the repository at this point in the history
  • Loading branch information
xffxff committed Sep 19, 2023
1 parent 5de9456 commit 906a6e7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/lox-compile/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions components/lox-execute/src/execute.rs
Original file line number Diff line number Diff line change
@@ -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<impl FnMut(bytecode::Code, &VM)>) {
pub fn execute_file(
db: &impl crate::Db,
input_file: InputFile,
step_inspect: Option<impl FnMut(bytecode::Code, &VM)>,
) {
let chunk = compile::compile_file(db, input_file);
let mut vm = VM::new(chunk);
vm.interpret(step_inspect)
Expand Down
13 changes: 9 additions & 4 deletions components/lox-execute/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F>(&mut self, mut step_inspect: Option<F>)
where F: FnMut(bytecode::Code, &VM) {
where
F: FnMut(bytecode::Code, &VM),
{
loop {
if self.chunk.len() <= self.ip {
break;
Expand Down Expand Up @@ -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);
Expand All @@ -136,7 +138,10 @@ impl VM {
self.stack.pop().unwrap()
}

fn push<T>(&mut self, value: T) where T: Into<Value> {
fn push<T>(&mut self, value: T)
where
T: Into<Value>,
{
self.stack.push(value.into());
}
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 906a6e7

Please sign in to comment.