pub struct ScopeKernel { /* private fields */ }Expand description
A scope kernel and the interpreter program it stands for.
Implementations§
Source§impl ScopeKernel
impl ScopeKernel
Sourcepub fn root(
interpreter: PolydatKernel,
image: Option<Arc<dyn KernelProgram>>,
) -> Self
pub fn root( interpreter: PolydatKernel, image: Option<Arc<dyn KernelProgram>>, ) -> Self
A root scope compiled from source: interpreter is the compiled
kernel, and image the fiber engine’s program for the same source
and options, when it can stand in for interpreter’s program
(crate::fiber_engine::source_image).
Sourcepub fn compile(source: &str) -> Result<Self, String>
pub fn compile(source: &str) -> Result<Self, String>
A root scope compiled from source with default options
(crate::bindings::compile_scope_kernel).
Sourcepub fn build_under(
parent: &dyn Kernel,
matter: SourceMatter,
) -> Result<Self, String>
pub fn build_under( parent: &dyn Kernel, matter: SourceMatter, ) -> Result<Self, String>
A child scope built from source matter under parent — the
any-engine form of build_subscope (native_scope_trees.md §5):
the matter finalizes to a module, which is instantiated under
parent. Strict mode refuses a const that silently fell through
to an outer value, as build_subscope does.
Sourcepub fn synthesize_under(
parent: &ScopeKernel,
matter: SourceMatter,
) -> Result<Self, String>
pub fn synthesize_under( parent: &ScopeKernel, matter: SourceMatter, ) -> Result<Self, String>
Self::build_under a parent scope, then write each of the
parent’s input values into the child’s input of the same name —
how every synthesized scope (phase, for_each, do-loop, op
template) is built. A value the child’s input refuses is an error.
Sourcepub fn bind_under(
&self,
parent: &dyn Kernel,
bindings: &[(String, Value)],
) -> Result<Self, String>
pub fn bind_under( &self, parent: &dyn Kernel, bindings: &[(String, Value)], ) -> Result<Self, String>
Another instance of this scope’s program under parent, with
bindings written into its inputs first — the any-engine form of
for_iteration(canonical, parent, bindings), and of
build_subscope with program matter.
Sourcepub fn fork(&self) -> Self
pub fn fork(&self) -> Self
A copy of this scope with its state — inputs, outputs, cells shared (native_scope_trees.md §4): a fiber’s starting kernel, an activation scope, a probe that leaves this one undisturbed.
Sourcepub fn program(&self) -> &Arc<PolydatProgram> ⓘ
pub fn program(&self) -> &Arc<PolydatProgram> ⓘ
The interpreter program this scope stands for: what synthesis and checkpoint identity read.
Sourcepub fn image(&self) -> &Arc<dyn KernelProgram> ⓘ
pub fn image(&self) -> &Arc<dyn KernelProgram> ⓘ
The program the running kernel is on.
Sourcepub fn module(&self) -> Option<&Arc<OpTemplateModule>>
pub fn module(&self) -> Option<&Arc<OpTemplateModule>>
The module a source-built scope finalized to, from which each fiber instantiates its own kernel with the module’s write-throughs.
Sourcepub fn into_kernel(self) -> Box<dyn Kernel>
pub fn into_kernel(self) -> Box<dyn Kernel>
The running kernel, for a holder of a bare dyn Kernel — an
adapter’s canonical kernel. Its program_id is this scope’s.
Sourcepub fn kernel_mut(&mut self) -> &mut dyn Kernel
pub fn kernel_mut(&mut self) -> &mut dyn Kernel
The running kernel, mutably.
Sourcepub fn lookup(&self, name: &str) -> Option<Value>
pub fn lookup(&self, name: &str) -> Option<Value>
A name’s value in this scope without evaluating anything: a
const’s value, an input, a value the build folded. A computed
output is not a scope value, before or after a pull, on any
engine; Self::pull_value evaluates one.
Sourcepub fn pull_value(&self, name: &str) -> Option<Value>
pub fn pull_value(&self, name: &str) -> Option<Value>
A name’s value, evaluating a computed output on a fork so this
scope’s state is undisturbed: Self::lookup first, then a pull.
Sourcepub fn scope_values(&self) -> Vec<(String, Value)>
pub fn scope_values(&self) -> Vec<(String, Value)>
The values this scope’s inputs hold, by name, for writing into other kernels: every input with a value except a const’s slot, which only initialization writes (each kernel the values go into initializes its own consts from them).
Trait Implementations§
Source§impl Debug for ScopeKernel
impl Debug for ScopeKernel
Source§impl Deref for ScopeKernel
impl Deref for ScopeKernel
Source§impl DerefMut for ScopeKernel
impl DerefMut for ScopeKernel
Source§impl From<PolydatKernel> for ScopeKernel
impl From<PolydatKernel> for ScopeKernel
Source§fn from(kernel: PolydatKernel) -> Self
fn from(kernel: PolydatKernel) -> Self
An interpreter kernel as a scope: a kernel standing outside the tree’s construction (a test fixture, a probe) that a scope is bound under.
Source§impl Lookup for ScopeKernel
impl Lookup for ScopeKernel
Source§impl ProgramKernel for ScopeKernel
impl ProgramKernel for ScopeKernel
Source§fn split_program(&mut self) -> (&mut dyn Kernel, Arc<PolydatProgram>)
fn split_program(&mut self) -> (&mut dyn Kernel, Arc<PolydatProgram>)
Source§impl WireSource for ScopeKernel
WireSource over &ScopeKernel — covers names that the kernel’s
lookup API already exposes (inputs, scope-init constants,
shared-cell-backed values). Computed outputs that require a
memoizing pull(&mut state, …) evaluation are NOT covered here
and return None from get; the SRD-68 Push 2 work introduces a
richer WireSource impl that owns the per-fiber kernel handle
with interior mutability and can pull outputs at cycle time.
impl WireSource for ScopeKernel
WireSource over &ScopeKernel — covers names that the kernel’s
lookup API already exposes (inputs, scope-init constants,
shared-cell-backed values). Computed outputs that require a
memoizing pull(&mut state, …) evaluation are NOT covered here
and return None from get; the SRD-68 Push 2 work introduces a
richer WireSource impl that owns the per-fiber kernel handle
with interior mutability and can pull outputs at cycle time.
For Push 1 this &ScopeKernel impl is the additive baseline: every
existing call site that gets handed a NullWireSource continues
working unchanged, and code that wants kernel-side reads via the
trait can use it for the names lookup already answers.
Source§fn get(&self, name: &str) -> Option<Value>
fn get(&self, name: &str) -> Option<Value>
name in this kernel’s scope. Returns the current
value (cloned, owned) or None when the name is not
declared here. Callers do not retry against another kernel
— a None is the resolution result, full stop.Source§fn names(&self) -> Box<dyn Iterator<Item = String> + '_>
fn names(&self) -> Box<dyn Iterator<Item = String> + '_>
Source§fn write(&self, _name: &str, _value: Value) -> WriteOutcome
fn write(&self, _name: &str, _value: Value) -> WriteOutcome
value into the named input slot of this kernel.
Returns WriteOutcome::Stored when the slot exists and
the value was written, WriteOutcome::NoSlot when the
kernel’s program has no input slot named name. Read moreSource§fn reset(&self, _name: &str) -> WriteOutcome
fn reset(&self, _name: &str) -> WriteOutcome
Value::None on a typed
slot, where every downstream consumer would have to be
None-aware. Default impl returns NoSlot (read-only
sources have nothing to reset).Auto Trait Implementations§
impl !RefUnwindSafe for ScopeKernel
impl !UnwindSafe for ScopeKernel
impl Freeze for ScopeKernel
impl Send for ScopeKernel
impl Sync for ScopeKernel
impl Unpin for ScopeKernel
impl UnsafeUnpin for ScopeKernel
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