Skip to content

Commit

Permalink
Disassembling a block before execution instead of after the compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
patbuc committed Jul 5, 2024
1 parent 7459a49 commit 0c97e90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ impl Compiler {
parser.end();

return if !(parser.had_error) {
let block = parser.blocks.pop();
#[cfg(feature = "disassemble")]
block.as_ref()?.disassemble_block();
block
parser.blocks.pop()
} else {
None
};
Expand Down
4 changes: 2 additions & 2 deletions src/vm/virtual_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ impl VirtualMachine {

#[inline(always)]
fn run(&mut self, mut block: Block) -> Result {
#[cfg(feature = "disassemble")]
block.disassemble_block();
loop {
// #[cfg(feature = "disassemble")]
// block.disassemble_instruction(self.ip);
match OpCode::from_u8(block.read_u8(self.ip)) {
OpCode::Return => {
let value = self.pop();
Expand Down

0 comments on commit 0c97e90

Please sign in to comment.