gsh/evaluator/runner
The runner module orchestrates the compilation and execution pipeline
for the shell’s dynamically generated REPL modules.
It acts as the bridge between the host filesystem and the Erlang VM,
utilizing shellout to invoke the Gleam compiler for static analysis
and Erlang generation, and utilizing the runtime FFI to dynamically compile,
load, and execute the resulting code directly in memory.
Values
pub fn build_project() -> Result(String, #(Int, String))
Triggers a full compilation of the host workspace using the Gleam CLI.
This is invoked by the compile command in the REPL, allowing developers
to rebuild their background application and trigger Erlang VM hot-reloads
without dropping their active shell session.
pub fn run(
binding: option.Option(binding.Binding),
module_name: String,
) -> result.Evaluation
The core execution pipeline for evaluated code.
Execution Lifecycle:
- Isolated Compilation: Invokes
gleam compile-packagetargeting an isolatedbuild/dev/erlang/gsh_evaloutput directory. This ensures the REPL’s temporary files never corrupt or overwrite the host project’s build cache. - In-Memory Loading: Reads the resulting
.erlfile and uses Erlang’s native compiler FFI to compile it directly into RAM, bypassing.beamdisk I/O. - Execution: Invokes the dynamically loaded
gsh_entryfunction, capturing the evaluation success or gracefully intercepting Erlang VM runtime crashes.