(
store: &mut StoreOpaque,
module: &Module,
imports: &[Extern],
)
| 209 | } |
| 210 | |
| 211 | fn typecheck_externs( |
| 212 | store: &mut StoreOpaque, |
| 213 | module: &Module, |
| 214 | imports: &[Extern], |
| 215 | ) -> Result<OwnedImports> { |
| 216 | for import in imports { |
| 217 | if !import.comes_from_same_store(store) { |
| 218 | bail!("cross-`Store` instantiation is not currently supported"); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | typecheck(module, imports, |cx, ty, item| { |
| 223 | let item = DefinitionType::from(store, item); |
| 224 | cx.definition(ty, &item) |
| 225 | })?; |
| 226 | |
| 227 | // When pushing functions into `OwnedImports` it's required that their |
| 228 | // `wasm_call` fields are all filled out. This `module` is guaranteed |
| 229 | // to have any trampolines necessary for functions so register the |
| 230 | // module with the store and then attempt to fill out any outstanding |
| 231 | // holes. |
| 232 | // |
| 233 | // Note that under normal operation this shouldn't do much as the list |
| 234 | // of funcs-with-holes should generally be empty. As a result the |
| 235 | // process of filling this out is not super optimized at this point. |
| 236 | let (modules, engine, breakpoints) = store.modules_and_engine_and_breakpoints_mut(); |
| 237 | modules.register_module(module, engine, breakpoints)?; |
| 238 | let (funcrefs, modules) = store.func_refs_and_modules(); |
| 239 | funcrefs.fill(modules); |
| 240 | |
| 241 | let mut owned_imports = OwnedImports::new(module)?; |
| 242 | for import in imports { |
| 243 | owned_imports.push(import, store)?; |
| 244 | } |
| 245 | Ok(owned_imports) |
| 246 | } |
| 247 | |
| 248 | /// Internal function to create an instance and run the start function. |
| 249 | /// |
nothing calls this directly
no test coverage detected