feat(runtime-core) Allow dynamic signature for polymorphic host functions.

This patch adds a new field in `Func`: `signature`. It contains the
signature of the host function.

For non-polymorphic host functions, the signature is computed from the
`Args` and `Rets` implementation parameters at compile-time.

For polymorphic host functions though, to be fully dynamic, the
signature given to `new_polymorphic` is used in `Func` as the correct
signature.
This commit is contained in:
Ivan Enderlin
2020-02-17 15:43:14 +01:00
parent ad20a008e0
commit 2ee1e80f3b
2 changed files with 22 additions and 5 deletions

View File

@ -154,7 +154,7 @@ fn imported_functions_forms(test: &dyn Fn(&Instance)) {
Ok(n + 1)
}),
"callback_closure_polymorphic" => Func::<i32, i32, _>::new_polymorphic(
"callback_closure_polymorphic" => Func::new_polymorphic(
Arc::new(FuncSig::new(vec![Type::I32], vec![Type::I32])),
|_, params| -> Vec<Value> {
match params[0] {