(
&mut self,
store: &mut StoreOpaque,
module: &Module,
args: impl Iterator<Item = &'b CoreDef>,
)
| 948 | } |
| 949 | |
| 950 | fn build_imports<'b>( |
| 951 | &mut self, |
| 952 | store: &mut StoreOpaque, |
| 953 | module: &Module, |
| 954 | args: impl Iterator<Item = &'b CoreDef>, |
| 955 | ) -> Result<&OwnedImports, OutOfMemory> { |
| 956 | self.core_imports.clear(); |
| 957 | self.core_imports.reserve(module)?; |
| 958 | let mut imports = module.compiled_module().module().imports(); |
| 959 | |
| 960 | for arg in args { |
| 961 | // The general idea of Wasmtime is that at runtime type-checks for |
| 962 | // core wasm instantiations internally within a component are |
| 963 | // unnecessary and superfluous. Naturally though mistakes may be |
| 964 | // made, so double-check this property of wasmtime in debug mode. |
| 965 | |
| 966 | if cfg!(debug_assertions) { |
| 967 | let (imp_module, imp_name, expected) = imports.next().unwrap(); |
| 968 | self.assert_type_matches(store, module, arg, imp_module, imp_name, expected); |
| 969 | } |
| 970 | |
| 971 | // The unsafety here should be ok since the `export` is loaded |
| 972 | // directly from an instance which should only give us valid export |
| 973 | // items. |
| 974 | let export = lookup_vmdef(store, self.id, arg); |
| 975 | self.core_imports.push_export(store, &export)?; |
| 976 | } |
| 977 | debug_assert!(imports.next().is_none()); |
| 978 | |
| 979 | Ok(&self.core_imports) |
| 980 | } |
| 981 | |
| 982 | fn assert_type_matches( |
| 983 | &self, |
no test coverage detected