-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added invoke option to the command #968
Changes from 2 commits
7b3093f
d0960dc
be1f192
f3b7c6b
3d36360
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,10 @@ struct Run { | |
)] | ||
backend: Backend, | ||
|
||
/// Invoke a specified function | ||
#[structopt(long = "invoke", short = "i")] | ||
invoke: Option<String>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⛳️ Consider: #[structopt(long = "invoke", short = "i", default = "main")]
invoke: String This is less flexible, but for the code as it is now, this is a cleaner solution There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like that much, because depending on the integration you use (emscripten, wasi, ...) the default might vary. Will go through the other approach |
||
|
||
/// Emscripten symbol map | ||
#[structopt(long = "em-symbol-map", parse(from_os_str), group = "emscripten")] | ||
em_symbol_map: Option<PathBuf>, | ||
|
@@ -683,8 +687,12 @@ fn execute_wasm(options: &Run) -> Result<(), String> { | |
args.push(Value::I32(x)); | ||
} | ||
|
||
let invoke_fn = match options.invoke.as_ref() { | ||
Some(fun) => fun, | ||
_ => "main", | ||
}; | ||
syrusakbary marked this conversation as resolved.
Show resolved
Hide resolved
|
||
instance | ||
.dyn_func("main") | ||
.dyn_func(&invoke_fn) | ||
.map_err(|e| format!("{:?}", e))? | ||
.call(&args) | ||
.map_err(|e| format!("{:?}", e))?; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "specify the name of the start function" or "of the main function" of something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not a main function, but a raw function that you might want to invoke.