Precompiler

sealed interface Precompiler<C : Precompiler.Configuration, I, O>

Precompiler

Describes the concept of a "precompiler," which is used by Elide to transform input code material (either source code or bytecode) into a form that is supported by the runtime or more efficiently consumed by the runtime.

Precompilers are typically implemented to transform code written in a high-level language (e.g., TypeScript, Kotlin) into code which is directly executable by a language engine (e.g. JavaScript, JVM bytecode).

Two major types of precompilers are supported by Elide:

  • SourcePrecompiler: Responsible for transforming a String of source code into another String of source code. This is the base type for transformation cases like the TypeScript example above.

  • BytecodePrecompiler: Responsible for transforming a String of source code into a ByteBuffer of bytecode. This is the base type for transformation cases like the Kotlin example above.

In all cases, precompiler steps run immediately after code is loaded and immediately before it is evaluated for execution. Precompilers are only loaded once per run and are only loaded if needed.

Parameters

C

Configuration type for this precompiler.

I

Input type accepted by this precompiler.

O

Output type produced by this precompiler.

Inheritors

Types

Link copied to clipboard
interface BundleInfo

Base interface for precompiled bundles of code.

Link copied to clipboard

Accepts code in the form of a simple String, and is expected to return transformed code in the form of a file which acts as an executable bundle (for example, a JAR).

Link copied to clipboard

Accepts code in the form of a simple String, and is expected to return transformed code in the form of a buffer containing raw bytecode which is directly executable by the runtime.

Link copied to clipboard
interface Configuration

Base interface for precompiler configurations.

Link copied to clipboard
data class PrecompileSourceInfo(val name: String, val path: Path? = null) : Record

Holds information about the source code being precompiled.

Link copied to clipboard

Represents a request from the engine to precompile source code.

Link copied to clipboard
interface Provider<T : Precompiler<*, *, *>> : Supplier<T>

Generic provider of a precompiler instance; used for service loading.

Link copied to clipboard

Accepts code in the form of a simple String, and is expected to return transformed code in the form of a String which is directly executable by the runtime.

Functions

Link copied to clipboard
abstract operator fun invoke(req: Precompiler.PrecompileSourceRequest<C>, input: I): O?

Invoke this precompiler, producing an output of shape O for an input of shape I.

Link copied to clipboard
open suspend fun precompile(req: Precompiler.PrecompileSourceRequest<C>, input: I): O?

Precompile the input using this precompiler.

Link copied to clipboard

Precompile using the provided inputs,