Translates a `CoreDef`, a definition of a core wasm item, to an [`Export`] which is the runtime core wasm definition.
(
store: &mut StoreOpaque,
id: ComponentInstanceId,
def: &CoreDef,
)
| 577 | /// Translates a `CoreDef`, a definition of a core wasm item, to an |
| 578 | /// [`Export`] which is the runtime core wasm definition. |
| 579 | pub(crate) fn lookup_vmdef( |
| 580 | store: &mut StoreOpaque, |
| 581 | id: ComponentInstanceId, |
| 582 | def: &CoreDef, |
| 583 | ) -> vm::Export { |
| 584 | match def { |
| 585 | CoreDef::Export(e) => lookup_vmexport(store, id, e), |
| 586 | CoreDef::Trampoline(idx) => { |
| 587 | let funcref = store |
| 588 | .store_data_mut() |
| 589 | .component_instance_mut(id) |
| 590 | .trampoline_func_ref(*idx); |
| 591 | // SAFETY: the `funcref` is owned by `store` and is valid within |
| 592 | // that store, so it's safe to create a `Func`. |
| 593 | vm::Export::Function(unsafe { crate::Func::from_vm_func_ref(store.id(), funcref) }) |
| 594 | } |
| 595 | CoreDef::InstanceFlags(idx) => { |
| 596 | let id = StoreComponentInstanceId::new(store.id(), id); |
| 597 | vm::Export::Global(crate::Global::from_component_flags(id, *idx)) |
| 598 | } |
| 599 | CoreDef::UnsafeIntrinsic(intrinsic) => { |
| 600 | let funcref = store |
| 601 | .store_data_mut() |
| 602 | .component_instance_mut(id) |
| 603 | .unsafe_intrinsic_func_ref(*intrinsic); |
| 604 | // SAFETY: as above, the `funcref` is owned by `store` and is valid |
| 605 | // within that store, so it's safe to create a `Func`. |
| 606 | vm::Export::Function(unsafe { crate::Func::from_vm_func_ref(store.id(), funcref) }) |
| 607 | } |
| 608 | CoreDef::TaskMayBlock => vm::Export::Global(crate::Global::from_task_may_block( |
| 609 | StoreComponentInstanceId::new(store.id(), id), |
| 610 | )), |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | /// Translates a `CoreExport<T>`, an export of some core instance within |
| 615 | /// this component, to the actual runtime definition of that item. |
no test coverage detected