Skip to content

Commit

Permalink
Fix buggy init local_count (#213)
Browse files Browse the repository at this point in the history
* Fix buggy init local_count

* remove commented-out line
  • Loading branch information
ejrgilbert authored Oct 3, 2024
1 parent d1287a0 commit 8c2125e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ir/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,14 @@ impl<'a> Module<'a> {
}
Payload::CodeSectionEntry(body) => {
let locals_reader = body.get_locals_reader()?;
let num_locals = locals_reader.get_count();
let locals = locals_reader.into_iter().collect::<Result<Vec<_>, _>>()?;
let mut num_locals = 0;
let locals: Vec<(u32, DataType)> = locals
.iter()
.map(|(idx, val_type)| (*idx, DataType::from(*val_type)))
.map(|(count, val_type)| {
num_locals += count;
(*count, DataType::from(*val_type))
})
.collect();

let instructions = body
Expand Down

0 comments on commit 8c2125e

Please sign in to comment.