Skip to content

Commit

Permalink
[move] Fixed locals disassembly
Browse files Browse the repository at this point in the history
  • Loading branch information
awelc committed Dec 30, 2024
1 parent 1a27a82 commit 4a028e9
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions external-crates/move/crates/move-disassembler/src/disassembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,8 @@ 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, params_len)?;
self.disassemble_locals(buffer, function_source_map, code.locals)?;
self.disassemble_bytecode(buffer, function_source_map, &name, parameters, code)?;
self.disassemble_jump_tables(buffer, code)?;
any_writeln!(buffer, "}}")
Expand All @@ -566,30 +564,15 @@ 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(());
}

if function_source_map.locals.len() <= parameter_len {
return Ok(());
}

let signature = self.source_mapper.bytecode.signature_at(locals_idx);
for (local_idx, (name, _)) in function_source_map
.locals
.iter()
.skip(parameter_len)
.enumerate()
{
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,
parameter_len + local_idx,
signature,
)?;
self.disassemble_type_for_local(buffer, function_source_map, local_idx, signature)?;
any_writeln!(buffer)?;
}

Expand Down

0 comments on commit 4a028e9

Please sign in to comment.