Skip to content

Commit

Permalink
Corrected locals disassembly indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
awelc committed Dec 30, 2024
1 parent 4a028e9 commit eccb15e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions external-crates/move/crates/move-disassembler/src/disassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,10 @@ impl<'a> Disassembler<'a> {
return Ok(());
};

let params_len = self.source_mapper.bytecode.signature_at(parameters).0.len();

any_writeln!(buffer, " {{")?;
self.disassemble_locals(buffer, function_source_map, code.locals)?;
self.disassemble_locals(buffer, function_source_map, code.locals, params_len)?;
self.disassemble_bytecode(buffer, function_source_map, &name, parameters, code)?;
self.disassemble_jump_tables(buffer, code)?;
any_writeln!(buffer, "}}")
Expand All @@ -564,15 +566,21 @@ impl<'a> Disassembler<'a> {
buffer: &mut impl Write,
function_source_map: &FunctionSourceMap,
locals_idx: SignatureIndex,
parameter_len: usize,
) -> Result<()> {
if !self.options.print_locals {
return Ok(());
}

let signature = self.source_mapper.bytecode.signature_at(locals_idx);
for (local_idx, (name, _)) in function_source_map.locals.iter().enumerate() {
any_write!(buffer, "L{local_idx}:\t{name}: ")?;
self.disassemble_type_for_local(buffer, function_source_map, local_idx, signature)?;
any_write!(buffer, "L{}:\t{}: ", local_idx + parameter_len, name)?;
self.disassemble_type_for_local(
buffer,
function_source_map,
parameter_len + local_idx,
signature,
)?;
any_writeln!(buffer)?;
}

Expand Down

0 comments on commit eccb15e

Please sign in to comment.