| 1 |
use anyhow::Result; |
| 2 |
use std::env; |
| 3 |
use wasmparser::{Parser, Payload}; |
| 4 |
|
| 5 |
fn main() -> Result<()> { |
| 6 |
let args = env::args().collect::<Vec<_>>(); |
| 7 |
if args.len() != 2 { |
| 8 |
println!("Usage: {} in.wasm", args[0]); |
| 9 |
return Ok(()); |
| 10 |
} |
| 11 |
|
| 12 |
let buf: Vec<u8> = std::fs::read(&args[1])?; |
| 13 |
for payload in Parser::new(0).parse_all(&buf) { |
| 14 |
match payload? { |
| 15 |
Payload::Version { .. } => { |
| 16 |
println!("====== Module"); |
| 17 |
} |
| 18 |
Payload::ExportSection(s) => { |
| 19 |
for export in s { |
| 20 |
let export = export?; |
| 21 |
println!(" Export {} {:?}", export.name, export.kind); |
| 22 |
} |
| 23 |
} |
| 24 |
Payload::ImportSection(s) => { |
| 25 |
for import in s { |
| 26 |
let import = import?; |
| 27 |
println!(" Import {}::{}", import.module, import.name); |
| 28 |
} |
| 29 |
} |
| 30 |
_other => { |
| 31 |
// println!("found payload {:?}", _other); |
| 32 |
} |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
Ok(()) |
| 37 |
} |