WIP
This commit is contained in:
parent
415e1d63e3
commit
d5342a0a6a
|
@ -1,13 +0,0 @@
|
||||||
//! Roundtrip utility.
|
|
||||||
|
|
||||||
use std::io::{Read, Write};
|
|
||||||
use waffle::Module;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _ = env_logger::try_init();
|
|
||||||
let mut bytes = vec![];
|
|
||||||
std::io::stdin().read_to_end(&mut bytes).unwrap();
|
|
||||||
let module = Module::from_wasm_bytes(&bytes).unwrap();
|
|
||||||
let new_bytes = module.to_wasm_bytes();
|
|
||||||
std::io::stdout().write(&new_bytes[..]).unwrap();
|
|
||||||
}
|
|
|
@ -23,6 +23,13 @@ enum Command {
|
||||||
#[structopt(help = "Wasm file to parse")]
|
#[structopt(help = "Wasm file to parse")]
|
||||||
wasm: PathBuf,
|
wasm: PathBuf,
|
||||||
},
|
},
|
||||||
|
#[structopt(name = "roundtrip", about = "Round-trip Wasm through IR")]
|
||||||
|
RoundTrip {
|
||||||
|
#[structopt(help = "Wasm file to parse", short = "i")]
|
||||||
|
input: PathBuf,
|
||||||
|
#[structopt(help = "Wasm file to produce", short = "o")]
|
||||||
|
output: PathBuf,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
|
@ -41,6 +48,13 @@ fn main() -> Result<()> {
|
||||||
let module = Module::from_wasm_bytes(&bytes[..])?;
|
let module = Module::from_wasm_bytes(&bytes[..])?;
|
||||||
println!("{:?}", module);
|
println!("{:?}", module);
|
||||||
}
|
}
|
||||||
|
Command::RoundTrip { input, output } => {
|
||||||
|
let bytes = std::fs::read(input)?;
|
||||||
|
debug!("Loaded {} bytes of Wasm data", bytes.len());
|
||||||
|
let module = Module::from_wasm_bytes(&bytes[..])?;
|
||||||
|
let produced = module.to_wasm_bytes();
|
||||||
|
std::fs::write(output, &produced[..])?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue