Module vm

Module vm 

Source
Expand description

This module implements the abstract/virtual machine that runs Snix bytecode.

The operation of the VM is facilitated by the Frame type, which controls the current execution state of the VM and is processed within the VM’s operating loop.

A VM is used by instantiating it with an initial Frame, then triggering its execution and waiting for the VM to return or yield an error.

ModulesΒ§

generators
This module implements generator logic for the VM. Generators are functions used during evaluation which can suspend their execution during their control flow, and request that the VM do something.
macros πŸ”’

StructsΒ§

CallFrame πŸ”’
ImportCache πŸ”’
The ImportCache holds the Value resulting from importing a certain file, so that the same file doesn’t need to be re-evaluated multiple times. Currently the real path of the imported file (determined using std::fs::canonicalize(), not to be confused with our crate::value::canon_path()) is used to identify the file, just like C++ Nix does.
PathImportCache πŸ”’
Path import cache, mapping absolute file paths to paths in the store.
RuntimeResult
The result of a VM’s runtime evaluation.
VM πŸ”’

EnumsΒ§

EvalMode
Specification for how to handle top-level values returned by evaluation
Frame πŸ”’
A frame represents an execution state of the VM. The VM has a stack of frames representing the nesting of execution inside of the VM, and operates on the frame at the top.

TraitsΒ§

GetSpan πŸ”’
Internal helper trait for taking a span from a variety of types, to make use of WithSpan (defined below) more ergonomic at call sites.
WithSpan πŸ”’
Internal helper trait for ergonomically converting from a Result<T, ErrorKind> to a Result<T, Error> using the current span of a call frame, and chaining the VM’s frame stack around it for printing a cause chain.

FunctionsΒ§

add_values πŸ”’
final_deep_force πŸ”’
Generator that retrieves the final value from the stack, and deep-forces it before returning.
resolve_with πŸ”’
Resolve a dynamically bound identifier (through with) by looking for matching values in the with-stacks carried at runtime.
run_lambda