Module tvix_eval::compiler::scope

source ·
Expand description

This module implements the scope-tracking logic of the Tvix 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.

Tvix 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§

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

Enums§

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