pub struct SubcontextBuilder<P> { /* private fields */ }Expand description
Module-matter accumulator. Construction is gated by
ScopeKernel::subcontext_builder — the parent is the only
way in.
Implementations§
Source§impl<P> SubcontextBuilder<P>
impl<P> SubcontextBuilder<P>
Sourcepub fn with_compile_options(&mut self, options: CompileOptions) -> &mut Self
pub fn with_compile_options(&mut self, options: CompileOptions) -> &mut Self
SRD-67 Phase 3 bridge hook: route the legacy
compile_polydat_with_libs knobs (lib paths, strict mode,
required-output filter, workload dir, context label)
through the builder. Synthesisers that previously called
compile_polydat_with_libs directly fold those calls into a
single with_compile_options(...) invocation; the do-loop
bridge leaves this at its default and finalize uses
compile_ast_with_options.
Sourcepub fn mark_inherited_outputs(&mut self, names: Vec<String>) -> &mut Self
pub fn mark_inherited_outputs(&mut self, names: Vec<String>) -> &mut Self
SRD-67 Phase 2 bridge hook: declare names whose outputs
the body emits purely to cascade values from an outer
scope to descendants (so they don’t double up the parent’s
iter-coord, etc.). The compiled kernel will have these
names flagged via mark_inherited_outputs before its
program Arc is shared.
Set from PolydatMatter’s inherited_outputs by
PolydatKernel::build_subscope; explicit-import callers leave this
empty.
Sourcepub fn parent(&self) -> &Arc<ScopeKernel<P>> ⓘ
pub fn parent(&self) -> &Arc<ScopeKernel<P>> ⓘ
Borrow the parent kernel — used by tests / advanced callers that need to inspect parent state during build.
Sourcepub fn import(&mut self, spec: ImportSpec) -> &mut Self
pub fn import(&mut self, spec: ImportSpec) -> &mut Self
Declare an import.
Sourcepub fn export(&mut self, spec: ExportSpec) -> &mut Self
pub fn export(&mut self, spec: ExportSpec) -> &mut Self
Declare an export.
Sourcepub fn body(&mut self, fragment: BodyFragment) -> &mut Self
pub fn body(&mut self, fragment: BodyFragment) -> &mut Self
Append a body fragment. Multiple fragments are concatenated in registration order at finalize.
Sourcepub fn context(&mut self, ctx: SourceContext) -> &mut Self
pub fn context(&mut self, ctx: SourceContext) -> &mut Self
Set the diagnostic context. Replaces any prior context.
Sourcepub fn register_pull(&mut self, consumer: Arc<dyn PullConsumer>) -> &mut Self
pub fn register_pull(&mut self, consumer: Arc<dyn PullConsumer>) -> &mut Self
Register a PullConsumer. Per SRD-67 §“Decision 7”
this is the single init-time accumulator surface;
the surface a host’s fixture adapter registers through.
Sourcepub fn add_result_bindings(
&mut self,
source: &str,
) -> Result<&mut Self, ContractViolation>
pub fn add_result_bindings( &mut self, source: &str, ) -> Result<&mut Self, ContractViolation>
SRD-67 Phase 5 — fold a SRD-66 result: source block
into this child’s module matter. Single entry point for
result-bindings kernel-driven path; applies the closure-
binding economy (Rule 5) to magic externs and lets the
existing finalize Rule 2 rewrite fire when result-LHS
names collide with parent shared exports.
source is Polydat source — the same <name> := <expr> form
bindings: accepts. Both string-shape (ResultSpec::String)
and map-shape (ResultSpec::Map { name, source } flattened
to <name> := <source>) end up here.
What this method does:
- Parses
sourceintoVec<Statement>. - Walks the body’s free identifiers; for each magic
pre-bound name (
body,count,ok) the source references but doesn’t already declare locally, prepends anextern <name>: <type>declaration so finalize compiles cleanly. Names not in the magic set fall through to the standard import / cascade / auto-extern path. - Records each
<name> := <expr>LHS as an export, so Rule 2 fires when the parent has a matchingsharedexport. The body fragment is appended; finalize’s existing rewrite is the load-bearing path.
Path expressions (map-shape entries with no := in the
source) are NOT supported here — the caller flattens them
to <name> := <source> and the Polydat compiler rejects them
as unbound-identifier failures, surfacing the SRD-66
“deferred until structural body wire lands” diagnostic.
Sourcepub fn finalize(self) -> Result<ScopeModule<Child<P>>, ContractViolation>
pub fn finalize(self) -> Result<ScopeModule<Child<P>>, ContractViolation>
Close the builder. Validates the import contract against the parent’s exports, compiles the body, and seals the pull consumers into the artifact.
SRD-67 Phase 2 — Rule 2 (write-through rewrite): when a
child export name collides with a parent shared export,
the body’s X := <expr> is rewritten before compile to:
extern X: <type>— opens an input slot the parent’sSharedCellattaches to viamaterialize_wiring_from_outer.__write_X := <expr>— a synthetic local computation that produces the value to write through.
At spawn time, the spawned child carries a write-through
binding (X, __write_X); per-cycle eval pulls
__write_X and stores its value through the child’s
input slot for X, which propagates to the cell.
Auto Trait Implementations§
impl<P> !RefUnwindSafe for SubcontextBuilder<P>
impl<P> !UnwindSafe for SubcontextBuilder<P>
impl<P> Freeze for SubcontextBuilder<P>
impl<P> Send for SubcontextBuilder<P>
impl<P> Sync for SubcontextBuilder<P>
impl<P> Unpin for SubcontextBuilder<P>
impl<P> UnsafeUnpin for SubcontextBuilder<P>
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