Skip to main content

Module helpers

Module helpers 

Source
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::Value becomes a fold-eligible GK literal,
  • how a workload-param string becomes a quoted-or-numeric GK literal,
  • how a polydat::ast::PortType becomes an extern declaration 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 Value as a Polydat source literal — strict variant. Returns None when 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 in None cases.
format_value_as_polydat_literal
Format a typed Value as 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 PortType to the extern declaration’s type keyword. Thin wrapper over PortType::to_keyword — the canonical str↔PortType table on the enum itself — so every synthesized extern <name>: <keyword> round-trips byte-cleanly back through the DSL parser.
scan_one
Scan one text for leaf {name} placeholders, inserting each into out. Companion to collect_leaf_placeholders for callers that already have a HashSet to grow incrementally.
value_to_param_string
Convert a scalar Value to its workload-param string form.
workload_param_type_name
Pick the Polydat port type for a workload-param string value.