Skip to main content

Module traversal

Module traversal 

Source
Expand description

Compile-time support for the for construct (SRD 113 steps 2 and 3): element typing, body-to-child-program lowering, and the metadata a parent program carries for each traversal and producer.

A for body compiles exactly once, at parent compile time, into a child PolydatProgram keyed by the statement’s lexical position. 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 (step 4) only ever 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 (SRD 113 §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 SRD 113 §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.
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.