(args: ModuleInputArgs)
| 7 | use crate::load::load_module; |
| 8 | |
| 9 | pub fn run(args: ModuleInputArgs) -> Result<()> { |
| 10 | let loaded = load_module(&args.module)?; |
| 11 | let module = loaded.module; |
| 12 | |
| 13 | let imported_func_count = |
| 14 | module.imports.iter().filter(|import| matches!(import.kind, ImportKind::Function(_))).count() as u32; |
| 15 | |
| 16 | for (func_idx, func) in module.funcs.iter().enumerate() { |
| 17 | let global_idx = imported_func_count + func_idx as u32; |
| 18 | |
| 19 | let exports = module |
| 20 | .exports |
| 21 | .iter() |
| 22 | .filter(|export| export.kind == ExternalKind::Func && export.index == global_idx) |
| 23 | .map(|export| export.name.as_ref()) |
| 24 | .collect::<Vec<_>>(); |
| 25 | |
| 26 | let header = format!("func[{func_idx}]").blue().bold().to_string(); |
| 27 | if exports.is_empty() { |
| 28 | println!("{header}"); |
| 29 | } else { |
| 30 | println!("{header} {}", format!("exports={}", format!("{exports:?}").cyan()).bright_black()); |
| 31 | } |
| 32 | |
| 33 | for (ip, instr) in func.instructions.iter().enumerate() { |
| 34 | let instr = print_instr(instr); |
| 35 | println!(" {}: {}", print_ip(ip), instr); |
| 36 | } |
| 37 | println!(); |
| 38 | } |
| 39 | |
| 40 | Ok(()) |
| 41 | } |
| 42 | |
| 43 | fn print_ip(ip: usize) -> String { |
| 44 | let s = format!("{ip:04}"); |
nothing calls this directly
no test coverage detected