MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / with_lower_context

Method with_lower_context

crates/wasmtime/src/runtime/component/func.rs:668–686  ·  view source on GitHub ↗

Creates a `LowerContext` using the configuration values of this lifted function. The `lower` closure provided should perform the actual lowering and return the result of the lowering operation which is then returned from this function as well.

(
        self,
        mut store: StoreContextMut<T>,
        lower: impl FnOnce(&mut LowerContext<T>, InterfaceType) -> Result<()>,
    )

Source from the content-addressed store, hash-verified

666 /// return the result of the lowering operation which is then returned from
667 /// this function as well.
668 pub(crate) fn with_lower_context<T>(
669 self,
670 mut store: StoreContextMut<T>,
671 lower: impl FnOnce(&mut LowerContext<T>, InterfaceType) -> Result<()>,
672 ) -> Result<()> {
673 let (options_idx, mut flags, ty, _) = self.abi_info(store.0);
674
675 // Perform the actual lowering, where while this is running the
676 // component is forbidden from calling imports.
677 unsafe {
678 debug_assert!(flags.may_leave());
679 flags.set_may_leave(false);
680 }
681 let mut cx = LowerContext::new(store.as_context_mut(), options_idx, self.instance);
682 let param_ty = InterfaceType::Tuple(cx.types[ty].params);
683 let result = lower(&mut cx, param_ty);
684 unsafe { flags.set_may_leave(true) };
685 result
686 }
687
688 /// Creates a `LiftContext` using the configuration values with this lifted
689 /// function.

Callers 3

call_rawMethod · 0.80
prepare_call_dynamicMethod · 0.80
prepare_callMethod · 0.80

Calls 6

abi_infoMethod · 0.80
set_may_leaveMethod · 0.80
TupleClass · 0.70
newFunction · 0.50
lowerFunction · 0.50
as_context_mutMethod · 0.45

Tested by

no test coverage detected