mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-25 04:31:57 +00:00
data inspection example
This commit is contained in:
25
examples/data.rs
Normal file
25
examples/data.rs
Normal file
@ -0,0 +1,25 @@
|
||||
extern crate parity_wasm;
|
||||
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let args = env::args().collect::<Vec<_>>();
|
||||
if args.len() != 2 {
|
||||
println!("Usage: {} somefile.wasm", args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
let module = parity_wasm::deserialize_file(&args[1]).expect("Failed to load module");
|
||||
|
||||
let data_section = module.data_section().expect("no data section in module");
|
||||
|
||||
println!("Data segments: {}", data_section.entries().len());
|
||||
|
||||
let mut index = 0;
|
||||
for entry in data_section.entries() {
|
||||
println!(" Entry #{}", index);
|
||||
println!(" init: {}", entry.offset().code()[0]);
|
||||
println!(" size: {}", entry.value().len());
|
||||
index += 1;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user