Skip to main content

Module program_bindings

Module program_bindings 

Source
Expand description

Program bindings on the tiers that compile a program ahead of time.

A ## To function reads and writes the bindings the program’s root declares: Set counter to counter + 1 inside ## To bump: moves the counter that Let mutable counter be 0. made. The tree-walker keeps them in one table (Interpreter::globals) and the VM as program globals. A tier that compiles ## Main into a main function has nowhere for them but that function’s locals, which no other function can name.

The rule for what a name means is the tree-walker’s (define_map, lookup, push_frame):

  • a Let at the program’s root defines a program binding; a Let inside a block of ## Main is that block’s, and no function sees it;
  • a function’s frame holds its parameters and its own Lets, block by block, and then the program’s bindings — never its caller’s locals;
  • Set x to v writes the innermost binding of x in scope, else the program’s.

The lift makes the program bindings some function reaches into the fields of ONE record, handed to every function that reaches them — directly or through a call — as a mutable parameter: the language’s own in-out convention. Every later pass then sees a field of a lent record, which a call may move, and never a local that moves behind its back. A program in which no function reaches a program binding is returned unchanged, statement for statement.

Structs§

Lifted
A program whose bindings are fields of PROGRAM_RECORD, with that record registered.

Constants§

PROGRAM_BINDING
The binding that holds it in ## Main, and the first parameter of every function that reaches it.
PROGRAM_RECORD
The record the lifted program bindings are fields of.

Functions§

lift_program_bindings
Lift the program bindings that functions reach into one lent record (see the module docs). Ok(None) when no function reaches one: the program needs nothing. Err names what this tier cannot express, in the author’s terms.