Skip to content

Commit

Permalink
fix(decompile): solidity postprocessing things
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Becker committed Jan 27, 2024
1 parent 9cd9e44 commit ca28e40
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/src/decompile/out/postprocessers/solidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn convert_access_to_variable(line: &str) -> Result<String, Error> {

// safe to unwrap since we know these indices exist
let memloc = format!(
"storage{}",
"storage[{}]",
storage_access
.get(storage_range)
.expect("impossible case: failed to get storage access after check")
Expand Down Expand Up @@ -591,30 +591,39 @@ fn cleanup(
}

// Find and convert all castings

cleaned = convert_bitmask_to_casting(&cleaned).unwrap_or(cleaned);

// Remove all repetitive casts

cleaned = simplify_casts(&cleaned);

// Remove all unnecessary parentheses

cleaned = simplify_parentheses(&cleaned, 0).unwrap_or(cleaned);

// Convert all memory[] and storage[] accesses to variables, also removes unused variables

cleaned = convert_access_to_variable(&cleaned).unwrap_or(cleaned);

// Use variable names where possible

cleaned = replace_expression_with_var(&cleaned).unwrap_or(cleaned);

// Move all outer casts in instantiation to the variable declaration

cleaned = move_casts_to_declaration(&cleaned).unwrap_or(cleaned);

// Inherit or infer types from expressions

cleaned = inherit_infer_mem_type(&cleaned).unwrap_or(cleaned);

// Replace resolved errors and events

cleaned = replace_resolved(&cleaned, all_resolved_errors, all_resolved_events);

// Simplify arithmatic

cleaned = simplify_arithmatic(&cleaned);

cleaned
Expand Down

0 comments on commit ca28e40

Please sign in to comment.