diff --git a/src/interpreter/instructions/mod.rs b/src/interpreter/instructions/mod.rs index 909d886..9882532 100644 --- a/src/interpreter/instructions/mod.rs +++ b/src/interpreter/instructions/mod.rs @@ -222,10 +222,10 @@ where MemoryView: wasm::structures::MemoryView, Instance: wasm::structures::Instance, { - let func_inputs = local_import.inputs(); + let func_inputs = local_import.arguments(); for (func_input_arg, value) in func_inputs.iter().zip(values.iter()) { - is_value_compatible_to_type(instance, &func_input_arg, value, instruction)?; + is_value_compatible_to_type(instance, &func_input_arg.ty, value, instruction)?; } Ok(()) @@ -363,7 +363,7 @@ pub(crate) mod tests { self.outputs.len() } - fn inputs(&self) -> &[InterfaceType] { + fn arguments(&self) -> &[InterfaceType] { &self.inputs } @@ -391,7 +391,7 @@ pub(crate) mod tests { self.outputs.len() } - fn inputs(&self) -> &[InterfaceType] { + fn arguments(&self) -> &[InterfaceType] { &self.inputs } diff --git a/src/interpreter/wasm/structures.rs b/src/interpreter/wasm/structures.rs index d3be40e..66b1985 100644 --- a/src/interpreter/wasm/structures.rs +++ b/src/interpreter/wasm/structures.rs @@ -3,6 +3,7 @@ use crate::types::RecordType; use crate::{types::InterfaceType, values::InterfaceValue}; use std::{cell::Cell, ops::Deref}; +use crate::ast::FunctionArg; pub trait TypedIndex: Copy + Clone { fn new(index: usize) -> Self; @@ -43,7 +44,7 @@ impl LocalImportIndex for FunctionIndex { pub trait Export { fn inputs_cardinality(&self) -> usize; fn outputs_cardinality(&self) -> usize; - fn inputs(&self) -> &[InterfaceType]; + fn arguments(&self) -> &[FunctionArg]; fn outputs(&self) -> &[InterfaceType]; fn call(&self, arguments: &[InterfaceValue]) -> Result, ()>; } @@ -51,7 +52,7 @@ pub trait Export { pub trait LocalImport { fn inputs_cardinality(&self) -> usize; fn outputs_cardinality(&self) -> usize; - fn inputs(&self) -> &[InterfaceType]; + fn arguments(&self) -> &[FunctionArg]; fn outputs(&self) -> &[InterfaceType]; fn call(&self, arguments: &[InterfaceValue]) -> Result, ()>; } @@ -88,7 +89,7 @@ impl Export for () { 0 } - fn inputs(&self) -> &[InterfaceType] { + fn arguments(&self) -> &[FunctionArg] { &[] } @@ -110,7 +111,7 @@ impl LocalImport for () { 0 } - fn inputs(&self) -> &[InterfaceType] { + fn arguments(&self) -> &[FunctionArg] { &[] } diff --git a/src/types.rs b/src/types.rs index 444667d..6317487 100644 --- a/src/types.rs +++ b/src/types.rs @@ -4,7 +4,7 @@ use crate::vec1::Vec1; use serde::{Deserialize, Serialize}; /// Represents the types supported by WIT. -#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)] pub enum InterfaceType { /// A 8-bits signed integer. S8, @@ -57,7 +57,7 @@ pub enum InterfaceType { } /// Represents a record field type. -#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)] pub struct RecordFieldType { // TODO: make name optional to support structures with anonymous fields in Rust /// A field name.