introduce function name for LocalImport and Export

This commit is contained in:
vms 2020-11-06 23:27:30 +03:00
parent fe4206afc6
commit 6f9baea140
6 changed files with 21 additions and 9 deletions

2
Cargo.lock generated
View File

@ -161,7 +161,7 @@ checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]]
name = "wasmer-interface-types-fl"
version = "0.17.12"
version = "0.17.15"
dependencies = [
"log",
"nom",

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-interface-types-fl"
version = "0.17.12"
version = "0.17.15"
description = "WebAssembly Interface Types library for Wasmer"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]

View File

@ -130,8 +130,8 @@ pub enum InstructionErrorKind {
/// Failed to call a local or import function.
LocalOrImportCall {
/// The local or import function index that has been called.
function_index: u32,
/// The local or import function name that has been called.
function_name: String,
},
/// The memory doesn't exist.
@ -237,10 +237,10 @@ impl Display for InstructionErrorKind {
function_index, expected.0, expected.1, received.0, received.1,
),
Self::LocalOrImportCall { function_index } => write!(
Self::LocalOrImportCall { function_name } => write!(
formatter,
"failed while calling the local or import function `{}`",
function_index
function_name
),
Self::MemoryIsMissing { memory_index } => write!(

View File

@ -31,13 +31,13 @@ executable_instruction!(
super::check_function_signature(&**instance, local_or_import, &inputs, instruction.clone())?;
log::trace!("call-core: calling {} with arguments: {:?}", function_index, inputs);
log::trace!("call-core: calling {} with arguments: {:?}", local_or_import.name(), inputs);
let outputs = local_or_import.call(&inputs).map_err(|_| {
InstructionError::new(
instruction.clone(),
InstructionErrorKind::LocalOrImportCall {
function_index,
function_name: local_or_import.name().to_string(),
},
)
})?;

View File

@ -184,7 +184,9 @@ where
let outputs = local_or_import.call(&inputs).map_err(|_| {
InstructionError::new(
instruction.clone(),
InstructionErrorKind::LocalOrImportCall { function_index },
InstructionErrorKind::LocalOrImportCall {
function_name: local_or_import.name().to_string(),
},
)
})?;

View File

@ -43,6 +43,7 @@ impl LocalImportIndex for FunctionIndex {
}
pub trait Export {
fn name(&self) -> &str;
fn inputs_cardinality(&self) -> usize;
fn outputs_cardinality(&self) -> usize;
fn arguments(&self) -> &[FunctionArg];
@ -51,6 +52,7 @@ pub trait Export {
}
pub trait LocalImport {
fn name(&self) -> &str;
fn inputs_cardinality(&self) -> usize;
fn outputs_cardinality(&self) -> usize;
fn arguments(&self) -> &[FunctionArg];
@ -81,6 +83,10 @@ where
}
impl Export for () {
fn name(&self) -> &str {
""
}
fn inputs_cardinality(&self) -> usize {
0
}
@ -103,6 +109,10 @@ impl Export for () {
}
impl LocalImport for () {
fn name(&self) -> &str {
""
}
fn inputs_cardinality(&self) -> usize {
0
}