Module scope

Source
Expand description

This module implements the scope-tracking logic of the Snix compiler.

Scoping in Nix is fairly complicated, there are features like mutually recursive bindings, with, upvalue capturing, and so on that introduce a fair bit of complexity.

Snix attempts to do as much of the heavy lifting of this at compile time, and leave the runtime to mostly deal with known stack indices. To do this, the compiler simulates where locals will be at runtime using the data structures implemented here.

Structs§

Local
Represents a single local already known to the compiler.
LocalIdx
The index of a local in the scope’s local array at compile time.
Scope
Represents a scope known during compilation, which can be resolved directly to stack indices.
Upvalue

Enums§

ByName 🔒
Helper struct for indexing over Scope::locals by name.
LocalName 🔒
LocalPosition
Represents the current position of an identifier as resolved in a scope.
UpvalueKind
Represents the different ways in which upvalues can be captured in closures or thunks.