mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 02:17:58 +00:00
Cursed implementation of allowing missing imports on wasmtime (#4730)
* Quick and dirty impl. * Clean up * Check the signatures. * Fix tests. * Apply suggestions from code review Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Ignore non function members. Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
e4f3e85585
commit
2421576f91
@@ -51,6 +51,24 @@ pub fn checked_range(offset: usize, len: usize, max: usize) -> Option<Range<usiz
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert from a parity wasm FunctionType to wasm interface's Signature.
|
||||
pub fn convert_parity_wasm_signature(func_ty: &parity_wasm::elements::FunctionType) -> Signature {
|
||||
fn convert_value_type(val_ty: parity_wasm::elements::ValueType) -> ValueType {
|
||||
use parity_wasm::elements::ValueType::*;
|
||||
match val_ty {
|
||||
I32 => ValueType::I32,
|
||||
I64 => ValueType::I64,
|
||||
F32 => ValueType::F32,
|
||||
F64 => ValueType::F64,
|
||||
}
|
||||
}
|
||||
|
||||
Signature::new(
|
||||
func_ty.params().iter().cloned().map(convert_value_type).collect::<Vec<_>>(),
|
||||
func_ty.return_type().map(convert_value_type),
|
||||
)
|
||||
}
|
||||
|
||||
/// Convert a wasm_interface Signature into a cranelift_codegen Signature.
|
||||
pub fn cranelift_ir_signature(signature: Signature, call_conv: &isa::CallConv) -> ir::Signature {
|
||||
ir::Signature {
|
||||
|
||||
Reference in New Issue
Block a user