(out: &mut Vec<String>, function: &IrFunction, ctx: &DecompileContext)
| 88 | } |
| 89 | } |
| 90 | fn append_function(out: &mut Vec<String>, function: &IrFunction, ctx: &DecompileContext) { |
| 91 | out.push(format!( |
| 92 | "{}void {}()", |
| 93 | if function.is_function_public { |
| 94 | "public " |
| 95 | } else { |
| 96 | "" |
| 97 | }, |
| 98 | sanitize_identifier(function.function_name.as_str()) |
| 99 | )); |
| 100 | out.push("{".to_string()); |
| 101 | |
| 102 | let mut body_lines = Vec::<String>::new(); |
| 103 | append_function_body(&mut body_lines, function, ctx); |
| 104 | |
| 105 | let local_declarations = function |
| 106 | .variable_declarations |
| 107 | .iter() |
| 108 | .map(|declaration| { |
| 109 | let variable = require_variable(ctx, declaration.variable_address); |
| 110 | let name = variable.name.as_str(); |
| 111 | render_local_variable_declaration(variable, name, declaration.init_value.as_ref()) |
| 112 | }) |
| 113 | .collect::<Vec<_>>(); |
| 114 | |
| 115 | for declaration in &local_declarations { |
| 116 | out.push(declaration.clone()); |
| 117 | } |
| 118 | if !local_declarations.is_empty() && !body_lines.is_empty() { |
| 119 | out.push(String::new()); |
| 120 | } |
| 121 | |
| 122 | out.extend(body_lines); |
| 123 | out.push("}".to_string()); |
| 124 | } |
| 125 | |
| 126 | fn append_function_body(out: &mut Vec<String>, function: &IrFunction, ctx: &DecompileContext) { |
| 127 | let emit_indices = function |
no test coverage detected