Skip to main content

Module traversal

Module traversal 

Source
Expand description

Compile-time support for the for construct (for_traversal.md §4): element typing, body-to-child-program lowering, and the metadata a parent program carries for each traversal and producer.

A for body compiles once, at parent compile time, into the interpreter’s child PolydatProgram keyed by the statement’s lexical position, and once per other engine, at the first activation on that engine (for_traversal.md §5.1). Its element names become IterationExtern inputs typed from the comprehension’s sources; outer wires it references become cascade externs typed from the parent’s manifest. Activation otherwise only allocates state over that program.

Structs§

BodySource
A traversal body as its parent compiled it: the child file and the compiler settings the parent used, so the same body compiles on any engine, once, keyed by the engine as the interpreter’s program is keyed by the body’s position (for_traversal.md §5.1).
Producer
A producer binding, name := for ..., recorded on the program that declares it so traversals over name resolve at compile time.
Traversal
A compiled traversal: one for statement and the child program its body lowered to.

Functions§

child_file
Build the child file for a traversal body: an implicit cycle input, one extern per element, one cascade extern per outer wire the body references and the parent exposes, then the body itself. Returns the file and the cascade list.
element_types
Type each element name of a comprehension from its source, per for_traversal.md §3.3. probe types a generator call expression the way the enclosing compiler would.
resolve_source
Resolve a traversal’s source to a comprehension: inline text as is, a producer reference to the producer bound in the same scope, and a derivation to the base producer with its filter and order applied.
resolve_source_with
resolve_source under a validation mode (comprehension_forms.md §5.8): a strict compile refuses a degenerate composition, a permissive one returns it as a warning for the compile event log.
strip_for_forms
Split a parsed file into the statements the parent compiles directly, the for statements to lower into child programs, and the producer bindings to record. Order within each group is preserved.