Rename wasmtime's --function to --invoke.

This highlights the similarity with the `invoke` command in `wast` files.
This commit is contained in:
Dan Gohman
2018-12-07 01:21:34 -05:00
parent a635861425
commit fe562297a7

View File

@@ -63,21 +63,22 @@ static LOG_FILENAME_PREFIX: &str = "cranelift.dbg.";
const USAGE: &str = " const USAGE: &str = "
Wasm runner. Wasm runner.
Takes a binary or text WebAssembly module and instantiates it, optionally Takes a binary (wasm) or text (wat) WebAssembly module and instantiates it,
allowing selected functions in it to be invoked. including calling the start function if one is present. Additional functions
given with --invoke are then called.
Usage: Usage:
wasmtime [-mopd] <file>... wasmtime [-omd] <file>...
wasmtime [-mopd] <file>... --function=<fn> wasmtime [-omd] <file>... --invoke=<fn>
wasmtime --help | --version wasmtime --help | --version
Options: Options:
--invoke=<fn> name of function to run
-o, --optimize runs optimization passes on the translated functions -o, --optimize runs optimization passes on the translated functions
-m, --memory interactive memory inspector after execution -m, --memory interactive memory inspector after execution
--function=<fn> name of function to run -d, --debug enable debug output on stderr/stdout
-h, --help print this help message -h, --help print this help message
--version print the Cranelift version --version print the Cranelift version
-d, --debug enable debug output on stderr/stdout
"; ";
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
@@ -86,7 +87,7 @@ struct Args {
flag_memory: bool, flag_memory: bool,
flag_optimize: bool, flag_optimize: bool,
flag_debug: bool, flag_debug: bool,
flag_function: Option<String>, flag_invoke: Option<String>,
} }
fn read_to_end(path: PathBuf) -> Result<Vec<u8>, io::Error> { fn read_to_end(path: PathBuf) -> Result<Vec<u8>, io::Error> {
@@ -150,7 +151,7 @@ fn handle_module(args: &Args, path: &Path, isa: &TargetIsa) -> Result<(), String
let mut code = Code::new(); let mut code = Code::new();
let mut world = InstanceWorld::new(&mut code, isa, &data, &mut resolver)?; let mut world = InstanceWorld::new(&mut code, isa, &data, &mut resolver)?;
if let Some(ref f) = args.flag_function { if let Some(ref f) = args.flag_invoke {
match world.invoke(&mut code, isa, &f, &[])? { match world.invoke(&mut code, isa, &f, &[])? {
ActionOutcome::Returned { .. } => {} ActionOutcome::Returned { .. } => {}
ActionOutcome::Trapped { message } => { ActionOutcome::Trapped { message } => {