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§
- Body
Source - 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 overnameresolve at compile time. - Traversal
- A compiled traversal: one
forstatement and the child program its body lowered to.
Functions§
- child_
file - Build the child file for a traversal body: an implicit
cycleinput, 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.
probetypes 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
forstatements to lower into child programs, and the producer bindings to record. Order within each group is preserved.