Expand description
Runtime evaluator — walks an algebra Comprehension AST
against a Lookup scope (a PolydatKernel or a Layered
view) to produce typed coordinate tuples.
§Why this is separate from the static IR interpreter
The static IR interpreter (super::ir::interpreter) walks
a compiled stack-machine program over fully-statically-
resolvable Source variants (IntRange, Literal). It
has no notion of a runtime parent kernel, which is correct
for the consumption surfaces it serves
(comprehension_forms.md §9.5).
Runtime comprehension evaluation is fundamentally different:
- Source-text evaluation requires the parent kernel.
Source::Generator { expr: "pre_{outer}" }andSource::WorkloadParamList { name }resolve against the parent kernel’s chain —{outer}substitution viainterpolate_via_kernel,kernel.lookup(name)for workload params. - Cartesian is dependent-tuple, not independent. Clause
N’s spec text may reference iter-vars from clauses
1..N-1. Prior-axis values are layered in front of the
scope (
Layered) so each clause evaluates against the correct context: the dependent product of comprehension_forms.md §3.2. - Filter predicates evaluate against per-tuple scopes.
A
CompiledPredicateparses the predicate once and tests each tuple: its boolean structure over the tuple’s values directly, and any richer sub-expression interpolated against aLayeredview of the scope and evaluated as a Polydat expression, charged to the scope’s ledger.
All three rest on the kernel’s own primitives; this evaluator is the algebra-typed entry point to them.
§What this owns
evaluate_indexed is the public surface:
(algebra AST + scope) → IndexedTuples, the tuples addressed by
position and computed when asked for; evaluate_for_iteration
computes them all. The tuples carry polydat Values, which the
caller binds into a kernel over the body’s program, one per tuple.
evaluate_for_iteration_materialized is the reference the
index-addressed evaluator is held to: every node materializes.
Order modifiers route through Strategy::select
(comprehension_forms.md §10.7.8): each node returns its tuples
paired with the IndexFn they satisfy, and the Order node
selects positions from that shape and the tuple count. An order
over a filter selects through Strategy::select_surviving, ranking
the survivors by their positions in the filter’s input (§5 V5). V4
fires again at this site, against the evaluated shape. An order’s
own output is addressed through its selection, one axis as long as
the selection (§3.6), so an order over an order selects from it.
§What this does NOT own
- Per-iteration kernel construction. The evaluator returns
tuples; the caller binds each into a kernel over the body’s
program —
TraversalStreamfor aforstatement, the renderer for a tile’s projection.
Structs§
- Clause
Yield - Internal walker state — the scope the recursive walker resolves names against, so it does not thread it through every call. What one leaf clause yielded over a whole traversal.
- Evaluated
Iteration - A traversal’s tuples, and what each leaf clause yielded reaching
them (
ClauseYield), in the tree order of the comprehension. - Indexed
Tuples - A comprehension’s tuples addressed by position: each tuple is
computed from its position when asked for (
evaluate_indexed). - None
Reads - Per leaf clause, the names whose reads of None made an evaluation of its source yield nothing (comprehension_forms.md §5 V3, none_semantics.md Rule 1): the names the source read, after composition, that nothing binds or that are bound to None, each with which of the two it was. A host that holds an unbound name in a source as an error reads it here.
Enums§
- Runtime
Error - Errors the runtime evaluator surfaces.
Functions§
- evaluate_
for_ iteration - Evaluate a comprehension against a scope and produce the typed coordinate-tuple list.
- evaluate_
for_ iteration_ materialized - The reference evaluator: every node materializes its tuples, and a cartesian evaluates each later axis once per tuple of the axes before it.
- evaluate_
for_ iteration_ materialized_ with_ none_ reads evaluate_for_iteration_materialized, and the clauses’ None reads asevaluate_for_iteration_with_none_readsreports them; the equivalence harness compares the two.- evaluate_
for_ iteration_ reported evaluate_for_iteration, and what each leaf clause yielded on the way (ClauseYield).- evaluate_
for_ iteration_ with_ none_ reads evaluate_for_iteration_reported, and for each clause the names whose reads of None made an evaluation of its source yield nothing (NoneReads).- evaluate_
indexed - Evaluate a comprehension against a scope to its tuples addressed by position (comprehension_forms.md §10.2 R2).
Type Aliases§
- Runtime
Tuple - Runtime tuple type — polydat-Value-based to preserve Ext
typing (Partition / Json / etc.) through the iteration
pipeline. The algebra layer’s
TupleusesTupleValuewhich is scalar-only; thisRuntimeTupleis what the executor actually wants for per-iteration kernel binding viaPolydatKernel::for_iteration.