-
Notifications
You must be signed in to change notification settings - Fork 830
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
feat(runtime) Cast and check CLI arguments to pass to the instance #281
Conversation
When the Wasm binary isn't an emscripten module, this patch does 5 things: 1. Check that the `main` function exists, 2. Check the signature (arity and types), 3. Cast the arguments into the correct Wasm value, 4. Pass the arguments to the instance, 5. Display the results. I'm not sure about the usage of `eprintln!`. It's probably something to update later, like the ability to pass a description message to `ExportWrongType`. Thoughts?
if args.len() != parameter_types.len() { | ||
Err(CallError::Resolve(ResolveError::Signature { | ||
expected: (*signature).clone(), | ||
found: args.iter().map(|_| Type::I32).collect(), |
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.
At this step, we don't know the type of the arguments yet. For the error, let's assume it's i32
.
Can you specify what type the arguments you pass in are? |
I think we can just try to cast it to what's expected and fail in case it's not possible. That way the way we do |
All arguments are I think it's the best way to handle casting from |
As discussed in private, I will change this PR to be |
1056: Integrate Ivan's arg parsing code into --invoke r=syrusakbary a=MarkMcCaskey Co-authored-by: Ivan Enderlin <[email protected]> Because #281 is on a branch on a fork, I made a new branch. Does arg parsing when using `--invoke` Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: Syrus Akbary <[email protected]>
This changes have been merged in #1056. Closing the PR |
When the Wasm binary isn't an emscripten module, this patch does 5 things:
main
function exists,I'm not sure about the usage of
eprintln!
. It's probably somethingto update later, like the ability to pass a description message to
ExportWrongType
.Thoughts?
Before:
After:
$ wasmer run nbody.wasm -- 7 result_0 = f64 : -0.16907367446575297
Test file: rust_nbody.wasm.zip