From a6bc1572df1a8ed7cc35204f65ab958a94996f14 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Tue, 19 Jul 2022 13:40:30 -0700 Subject: [PATCH] Improved a bit the function types and results --- lib/api/src/js/externals/function.rs | 7 +++---- lib/api/src/lib.rs | 1 - lib/api/src/sys/externals/function.rs | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/api/src/js/externals/function.rs b/lib/api/src/js/externals/function.rs index 4cece882026..f5ee117cef9 100644 --- a/lib/api/src/js/externals/function.rs +++ b/lib/api/src/js/externals/function.rs @@ -445,11 +445,10 @@ impl Function { Args: WasmTypeList, Rets: WasmTypeList, { - let vm_function = self.handle.get(store.as_store_ref().objects()); - + let ty = self.ty(store); // type check { - let expected = vm_function.ty.params(); + let expected = ty.params(); let given = Args::wasm_types(); if expected != given { @@ -462,7 +461,7 @@ impl Function { } { - let expected = vm_function.ty.results(); + let expected = ty.results(); let given = Rets::wasm_types(); if expected != given { diff --git a/lib/api/src/lib.rs b/lib/api/src/lib.rs index 98b29b2fff1..6a4686033ff 100644 --- a/lib/api/src/lib.rs +++ b/lib/api/src/lib.rs @@ -54,7 +54,6 @@ //! "#; //! //! let mut store = Store::default(); -//! let env = FunctionEnv::new(&mut store, ()); //! let module = Module::new(&store, &module_wat)?; //! // The module doesn't import anything, so we create an empty import object. //! let import_object = imports! {}; diff --git a/lib/api/src/sys/externals/function.rs b/lib/api/src/sys/externals/function.rs index aa6dcc9f9f8..c317b9648ca 100644 --- a/lib/api/src/sys/externals/function.rs +++ b/lib/api/src/sys/externals/function.rs @@ -530,11 +530,11 @@ impl Function { Args: WasmTypeList, Rets: WasmTypeList, { - let vm_function = self.handle.get(store.as_store_ref().objects()); + let ty = self.ty(store); // type check { - let expected = vm_function.signature.params(); + let expected = ty.params(); let given = Args::wasm_types(); if expected != given { @@ -547,7 +547,7 @@ impl Function { } { - let expected = vm_function.signature.results(); + let expected = ty.results(); let given = Rets::wasm_types(); if expected != given {