nmbrs_runtime/scope_synth/mod.rs
1// Copyright 2024-2026 Jonathan Shook
2// SPDX-License-Identifier: Apache-2.0
3
4//! Scope-construction substrate for nmbrs-runtime.
5//!
6//! Module name disambiguates from the pre-existing
7//! [`crate::synthesis`] (which handles fiber/op synthesis). Here
8//! we handle **scope** synthesis — turning workload-shape intent
9//! (a comprehension, a do-loop, a phase, an op template) into a
10//! child [`polydat::kernel::PolydatKernel`].
11//!
12//! This module hosts the walking + Surface #7 helpers + scope-
13//! builder functions that drive [`polydat::kernel::subcontext::SubcontextBuilder`]
14//! to materialize new scope kernels. See
15//! `polydat/docs/design/comprehension_cutover_contact_surfaces.md`
16//! for the architectural framing.
17//!
18//! ## What's here
19//!
20//! - [`helpers`] — Surface #7: pure utilities for turning typed
21//! values, workload-param strings, and PortType variants into
22//! Polydat source literals / extern type names. Also the placeholder
23//! scanner used by every scope-builder walk.
24//!
25//! ## What's planned (PR 9c-1b in progress)
26//!
27//! - `cascade` — the shared cascade-extern walker that the four
28//! sister scope builders (`build_phase_scope_kernel`,
29//! `build_do_loop_scope_kernel`, `build_op_template_scope_kernel`,
30//! and the forthcoming `build_for_each_scope_kernel`) will
31//! consume in lieu of each reinventing the same walk.
32//! - `for_each` — the comprehension-specific iter-var emission +
33//! shared cascade walker invocation that replaces
34//! `polydat::iteration::comprehension::synthesize_for_each_scope`.
35//!
36//! ## What lives in `scope.rs` for now
37//!
38//! `build_phase_scope_kernel`, `build_do_loop_scope_kernel`,
39//! `build_op_template_scope_kernel`. These will migrate into this
40//! module (and refactor onto the shared cascade walker) as part of
41//! the same push.
42
43pub mod cascade;
44pub mod cascade_emit;
45pub mod for_each;
46pub mod helpers;
47
48pub use cascade::{CascadeInputs, CascadeOutputs, cascade_parent_into_source};
49pub use cascade_emit::emit_workload_param_chain_aware;
50pub use for_each::build_for_each_scope_kernel;
51pub use helpers::{
52 collect_leaf_placeholders, format_value_as_final_literal, format_value_as_polydat_literal,
53 format_workload_param_as_polydat_literal, port_type_to_extern_name, scan_one,
54 value_to_param_string, workload_param_type_name,
55};