Skip to main content

Module script

Module script 

Source
Expand description

The data a frontend produces and a backend consumes.

This is the interface that keeps frontends and backends independent. A frontend emits a ScriptPackage, whatever its input looks like. A backend turns the functions inside it into callable crate::function::Function values. Neither has to know the other.

§Shape of the data

ScriptPackage
  ScriptModule           name
    ScriptStruct         name, fields
    ScriptEnum           name, variants
    ScriptFunction       signature + Script
      ScriptOperation    the actual instructions

§Operations

ScriptOperation is deliberately small: define and move registers, call a function, branch, loop, return, suspend. That is the common set every frontend and backend can share. Anything more specific, such as pushing a literal, goes into ScriptOperation::Expression and the ScriptExpression type a frontend defines for itself.

§Loading

ScriptContentProvider is the other half. It fetches source by path, so a frontend can follow imports without knowing where they live.

Structs§

ExtensionContentProvider
Dispatches to another provider based on the file extension.
FileContentProvider
Loads scripts from the file system.
IgnoreContentProvider
A provider that loads nothing.
InlineExpression
A ready-made ScriptExpression built from a closure.
ScriptBuilder
Assembles a Script one operation at a time.
ScriptContent
One loaded source unit, as ScriptContentProvider::unpack_load returns it.
ScriptEnum
An enum a frontend produced.
ScriptEnumVariant
An enum variant as a frontend describes it.
ScriptFunction
A function a frontend produced: an unresolved signature and its operations.
ScriptFunctionParameter
A function parameter as a frontend describes it, by type query rather than by resolved type.
ScriptFunctionSignature
A function signature as a frontend describes it, with types still unresolved.
ScriptModule
A named group of types and functions, as a frontend produced it.
ScriptPackage
A whole compilation unit: the modules a frontend produced.
ScriptStruct
A struct a frontend produced.
ScriptStructField
A struct field as a frontend describes it, by type query rather than by resolved type.

Enums§

ExtensionContentProviderError
What can go wrong while routing by extension.
ScriptOperation
One instruction of a script.

Traits§

BytesContentParser
Turns raw file bytes into whatever a frontend works with.
ScriptContentProvider
Fetches script source by path.
ScriptExpression
The extra operations a frontend adds on top of the built-in set.
ScriptFunctionGenerator
A backend: turns script operations into a runnable function body.

Type Aliases§

Script
A straight list of operations, run from first to last.
ScriptHandle
A shared, finished Script.