Expand description
Surface #7 helpers — pure utilities for translating between typed runtime values and Polydat source-text form.
These functions encode nmbrs-runtime’s Polydat source conventions:
- how a
polydat::ast::Valuebecomes a fold-eligible GK literal, - how a workload-param string becomes a quoted-or-numeric GK literal,
- how a
polydat::ast::PortTypebecomes anexterndeclaration type name, - how
{name}placeholders are scanned out of clause / body text.
They’re pure functions with no comprehension- or scope-
specific knowledge; the scope builders import them as walking
primitives. The polydat side retains parallel copies during
the cutover (still used by polydat::iteration::comprehension::synthesize_for_each_scope);
those copies retire when the legacy synthesis module is
deleted at the end of PR 9c-1b.
Functions§
- collect_
leaf_ placeholders - Collect every leaf
{name}placeholder from a list of clause spec texts. - format_
value_ as_ final_ literal - Format a typed
Valueas a Polydat source literal — strict variant. ReturnsNonewhen the value isn’t representable as a literal (Bytes,Json,Ext,Handle, vectors). Used by the for_each scope synthesizer when inlining const-folded parent outputs; falls back to extern cascade inNonecases. - format_
value_ as_ polydat_ literal - Format a typed
Valueas a Polydat source literal. - format_
workload_ param_ as_ polydat_ literal - Format a workload-param string value as a Polydat literal.
- port_
type_ to_ extern_ name - Map a Polydat
PortTypeto the extern declaration’s type keyword. Thin wrapper overPortType::to_keyword— the canonical str↔PortType table on the enum itself — so every synthesizedextern <name>: <keyword>round-trips byte-cleanly back through the DSL parser. - scan_
one - Scan one text for leaf
{name}placeholders, inserting each intoout. Companion tocollect_leaf_placeholdersfor callers that already have aHashSetto grow incrementally. - value_
to_ param_ string - Convert a scalar
Valueto its workload-param string form. - workload_
param_ type_ name - Pick the Polydat port type for a workload-param string value.