Skip to main content

ScriptFunctionGenerator

Trait ScriptFunctionGenerator 

Source
pub trait ScriptFunctionGenerator<SE: ScriptExpression> {
    type Input;
    type Output;

    // Required method
    fn generate_function_body(
        script: ScriptHandle<'static, SE>,
        input: Self::Input,
    ) -> Option<(FunctionBody, Self::Output)>;

    // Provided method
    fn generate_function(
        function: &ScriptFunction<'static, SE>,
        registry: &Registry,
        input: Self::Input,
    ) -> Option<(Function, Self::Output)> { ... }
}
Expand description

A backend: turns script operations into a runnable function body.

A virtual machine implements this by keeping the operations and stepping through them. A transpiler could emit code instead. Input is whatever the backend needs to be given, Output whatever it wants to hand back.

Required Associated Types§

Source

type Input

Configuration the backend needs, passed through at install time.

Source

type Output

Anything the backend wants to return alongside the function.

Required Methods§

Source

fn generate_function_body( script: ScriptHandle<'static, SE>, input: Self::Input, ) -> Option<(FunctionBody, Self::Output)>

Builds a body from a script, or returns None when it cannot.

Provided Methods§

Source

fn generate_function( function: &ScriptFunction<'static, SE>, registry: &Registry, input: Self::Input, ) -> Option<(Function, Self::Output)>

Builds a whole function, resolving the signature against the registry.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§