Skip to content

Commit

Permalink
Display handlers in bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Jul 9, 2023
1 parent 7b84063 commit 8391c80
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions boa_engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ impl CodeBlock {
}

pub(crate) fn find_handler(&self, pc: u32) -> Option<&Handler> {
self.handlers
dbg!(self.handlers
.iter()
.rev()
.find(|&handler| handler.range.contains(&pc))
.find(|&handler| handler.range.contains(&pc)))
}
}

Expand Down Expand Up @@ -679,6 +679,25 @@ impl ToInternedString for CodeBlock {
let mut pc = 0;
let mut count = 0;
while pc < self.bytecode.len() {
for (i, handler) in self.handlers.iter().enumerate().rev() {
if pc == handler.range.start as usize {
f.push_str(&format!(
"\n# Handler {i} start: handler: {}\n",
handler.handler
));
}

if pc == handler.range.end as usize {
f.push_str(&format!(
"# Handler {i} end: handler: {}\n\n",
handler.handler
));
}

if pc == handler.handler as usize {
f.push('\n');
}
}
let opcode: Opcode = self.bytecode[pc].into();
let opcode = opcode.as_str();
let previous_pc = pc;
Expand Down

0 comments on commit 8391c80

Please sign in to comment.