Rename define_function to define_function_with_control_plane (#6165)

And add a define_function convenience function which uses a default
control plane.
This commit is contained in:
bjorn3
2023-04-06 18:14:13 +02:00
committed by GitHub
parent 5ba0d696b7
commit e1812b611b
8 changed files with 48 additions and 28 deletions

View File

@@ -654,11 +654,29 @@ pub trait Module {
///
/// Returns the size of the function's code and constant data.
///
/// Unlike [`define_function_with_control_plane`] this uses a default [`ControlPlane`] for
/// convenience.
///
/// Note: After calling this function the given `Context` will contain the compiled function.
///
/// [`define_function_with_control_plane`]: Self::define_function_with_control_plane
fn define_function(
&mut self,
func: FuncId,
ctx: &mut Context,
) -> ModuleResult<ModuleCompiledFunction> {
self.define_function_with_control_plane(func, ctx, &mut ControlPlane::default())
}
/// Define a function, producing the function body from the given `Context`.
///
/// Returns the size of the function's code and constant data.
///
/// Note: After calling this function the given `Context` will contain the compiled function.
fn define_function_with_control_plane(
&mut self,
func: FuncId,
ctx: &mut Context,
ctrl_plane: &mut ControlPlane,
) -> ModuleResult<ModuleCompiledFunction>;
@@ -762,9 +780,17 @@ impl<M: Module> Module for &mut M {
&mut self,
func: FuncId,
ctx: &mut Context,
) -> ModuleResult<ModuleCompiledFunction> {
(**self).define_function(func, ctx)
}
fn define_function_with_control_plane(
&mut self,
func: FuncId,
ctx: &mut Context,
ctrl_plane: &mut ControlPlane,
) -> ModuleResult<ModuleCompiledFunction> {
(**self).define_function(func, ctx, ctrl_plane)
(**self).define_function_with_control_plane(func, ctx, ctrl_plane)
}
fn define_function_bytes(