Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Remove duplicated match statement for Directive::Log #79

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions acvm/src/pwg/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,43 +206,6 @@ pub fn solve_directives(

println!("{output_witnesses_string}");

Ok(())
}
Directive::Log(info) => {
let witnesses = match info {
LogInfo::FinalizedOutput(output_string) => {
println!("{output_string}");
return Ok(());
}
LogInfo::WitnessOutput(witnesses) => witnesses,
};

if witnesses.len() == 1 {
let witness = &witnesses[0];
let log_value = witness_to_value(initial_witness, *witness)?;
println!("{}", log_value.to_hex());

return Ok(());
}

// If multiple witnesses are to be fetched for a log directive,
// it assumed that an array is meant to be printed to standard output
//
// Collect all field element values corresponding to the given witness indices
// and convert them to hex strings.
let mut elements_as_hex = Vec::with_capacity(witnesses.len());
for witness in witnesses {
let element = witness_to_value(initial_witness, *witness)?;
elements_as_hex.push(element.to_hex());
}

// Join all of the hex strings using a comma
let comma_separated_elements = elements_as_hex.join(",");

let output_witnesses_string = "[".to_owned() + &comma_separated_elements + "]";

println!("{output_witnesses_string}");

Ok(())
}
}
Expand Down