pub struct BindingScope { /* private fields */ }Expand description
Typed scope for a phase’s Polydat Kernel compilation.
Built by the executor from structured inputs, validated for scope rules, then emitted as a single Polydat source string.
Implementations§
Source§impl BindingScope
impl BindingScope
Sourcepub fn ingest_polydat_source(&mut self, source: &str, origin: BindingOrigin)
pub fn ingest_polydat_source(&mut self, source: &str, origin: BindingOrigin)
Ingest bindings from a BindingsDef::PolydatSource, classifying each
line by the given origin. Extracts coordinates and handles all
Polydat declaration forms (init, shared, final, cursor, extern, plain).
A “line” here is a logical line: physical newlines inside
unbalanced ()/[]/{} or inside a string literal are
absorbed into the current binding. This is what lets multi-line
expressions like
rate_adjust := control_set("rate",
to_f64(control_u64("rate")) * 1.05)survive the later split-on-\n in Self::emit: we rejoin
them onto one physical line so the downstream parser sees a
complete expression.
Sourcepub fn add_iteration_var(&mut self, name: &str, value: &str)
pub fn add_iteration_var(&mut self, name: &str, value: &str)
Add an iteration variable from for_each.
Iteration variables are declared as extern ports rather
than init-time bindings (SRD 18b §“Iteration variables as
scope outputs”). The runtime sets the extern’s value
before the leaf kernel executes, so we no longer
text-substitute literal values into the Polydat source. The
type is inferred from the current iteration’s value:
numeric strings get u64/f64, anything else is String.
Sourcepub fn add_extern(&mut self, name: &str, type_name: &str)
pub fn add_extern(&mut self, name: &str, type_name: &str)
Add an auto-extern declaration from the outer scope manifest.
Sourcepub fn add_param_binding(&mut self, name: &str, value: &str)
pub fn add_param_binding(&mut self, name: &str, value: &str)
Add a workload param binding as a final (compile-time
constant) binding so the compiler folds the literal value
and the assembler treats references as const args rather
than wire inputs. The const modifier matches the M3.6
contract: workload params are immutable for the run, so
downstream nodes consume them as constants.
String values are emitted as quoted Polydat string literals
with embedded " and \ escaped, so JSON-shaped param
values ({"a": 1}, {'class': 'SimpleStrategy'},
arbitrary nested quotes) round-trip through GK
compilation unchanged. Numeric and boolean values are
emitted as bare literals.
Sourcepub fn add_inline_expr(&mut self, name: &str, expr: &str)
pub fn add_inline_expr(&mut self, name: &str, expr: &str)
Add an inline expression binding.
Sourcepub fn add_required_output(&mut self, name: &str)
pub fn add_required_output(&mut self, name: &str)
Register a name referenced by an op template (for DCE).
Sourcepub fn add_config_ref(&mut self, name: &str)
pub fn add_config_ref(&mut self, name: &str)
Register a config expression reference (for DCE).
Sourcepub fn defined_names(&self) -> HashSet<String>
pub fn defined_names(&self) -> HashSet<String>
All names defined in this scope (all origins).
Sourcepub fn extern_names(&self) -> HashSet<String>
pub fn extern_names(&self) -> HashSet<String>
All extern names in this scope.
Sourcepub fn required_outputs(&self) -> Vec<String>
pub fn required_outputs(&self) -> Vec<String>
The combined required outputs (template refs + config refs).
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate scope rules. Returns Ok(()) if valid, or a
descriptive error explaining the violation and its provenance.
Sourcepub fn emit(&self) -> String
pub fn emit(&self) -> String
Emit the validated scope as a single Polydat source string.
Entries are ordered:
- Coordinates declaration
- Extern declarations
- Init declarations (iteration variables)
- Inherited/Phase bindings (deduplicated by name)
- ParamExpansion bindings
- InlineExpr bindings
- Op-level bindings (new names only)
Each name is emitted exactly once. The first occurrence wins; subsequent duplicates with the same definition are suppressed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BindingScope
impl RefUnwindSafe for BindingScope
impl Send for BindingScope
impl Sync for BindingScope
impl Unpin for BindingScope
impl UnsafeUnpin for BindingScope
impl UnwindSafe for BindingScope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more