pub struct CompiledComprehension { /* private fields */ }Expand description
A comprehension that has been compiled to immutable IR and is ready to dispense. The single source of truth for the underlying program across the consumption surfaces.
Construction is via from_ast (compiles once) or
from_program (when the IR was compiled elsewhere).
Cloning a CompiledComprehension is cheap — just an
Arc::clone on the program.
Implementations§
Source§impl CompiledComprehension
impl CompiledComprehension
Sourcepub fn from_ast(ast: &Comprehension) -> Result<Self, ValidationError>
pub fn from_ast(ast: &Comprehension) -> Result<Self, ValidationError>
Compile an AST: validation (§5, V1–V9) first, then the §10 optimizer, then the AST → IR pass, once. Validation and optimization are stages of this compile (comprehension_forms.md §5, §9.4, §10.6): a tree that violates a V-axiom is refused here, and the §9.3 resource bounds hold for the program this returns.
Sourcepub fn from_ast_with(
ast: &Comprehension,
mode: Mode,
) -> Result<(Self, ValidationReport), ValidationError>
pub fn from_ast_with( ast: &Comprehension, mode: Mode, ) -> Result<(Self, ValidationReport), ValidationError>
from_ast under a validation mode
(comprehension_forms.md §5.8), with the validator’s report: in
Permissive mode a degenerate composition is a warning in the
report and the comprehension compiles; in Strict mode it is
the error. Context-free sources are flattened first
(§10.7.0): a generator that references no name is evaluated
here, in the empty scope, and validated as the literal of its
values.
The comprehension is compiled with no enclosing scope, so a name
it reads and does not bind is resolved nowhere (V3): in
Permissive mode it is a ValidationWarning::UnresolvedNames in
the report and reads None, and in Strict mode it is
ValidationError::V3UnresolvedNames. from_ast_in
compiles one bound in a scope.
Sourcepub fn from_ast_in(
ast: &Comprehension,
mode: Mode,
in_scope: &dyn Fn(&str) -> bool,
) -> Result<(Self, ValidationReport), ValidationError>
pub fn from_ast_in( ast: &Comprehension, mode: Mode, in_scope: &dyn Fn(&str) -> bool, ) -> Result<(Self, ValidationReport), ValidationError>
from_ast_with for a comprehension bound in
an enclosing scope, which has the names in_scope answers true
for, as a producer wire’s comprehension is (comprehension_forms.md
§5 V3, §9.5.2).
These surfaces supply no name. A name the enclosing scope does not
have either is resolved nowhere (V3): outside Strict mode it is
a ValidationWarning::UnresolvedNames in the report and reads
None, so a source reading one yields nothing and a predicate that
reads one for a tuple keeps it not; in Strict mode it is
ValidationError::V3UnresolvedNames. A name only that scope has
is one a for traversal captures when it opens and a stream cannot
see: a source reading one is ValidationError::ContextRequired, as
is a source reading an earlier axis, which only a traversal
evaluates, and a predicate reading one is
ValidationError::PredicateContextRequired.
Sourcepub fn from_program(program: Arc<Program>) -> Self
pub fn from_program(program: Arc<Program>) -> Self
Wrap an already-compiled program (tests use this for hand-built IR).
Sourcepub fn program(&self) -> &Program
pub fn program(&self) -> &Program
Access the underlying compiled program (immutable per comprehension_forms.md §9.1).
Sourcepub fn coordinate_stream(&self) -> CoordinateStream ⓘ
pub fn coordinate_stream(&self) -> CoordinateStream ⓘ
First-order surface (comprehension_forms.md §9.5).
Return a fresh CoordinateStream. Each call
allocates new per-streamer state; siblings share the
underlying IR but dispense independently per §9.5.2’s
independence contract.
Sourcepub fn scoped_kernel_stream<K: KernelScope>(
&self,
parent: K,
) -> ScopedKernelStream<K> ⓘ
pub fn scoped_kernel_stream<K: KernelScope>( &self, parent: K, ) -> ScopedKernelStream<K> ⓘ
Second-order surface (comprehension_forms.md §9.5).
Return a fresh ScopedKernelStream wrapping the
supplied parent kernel. Each advance() pulls one
coord tuple from the underlying IR and applies
parent.scope(&coords) to produce a
ScopedKernelInstance.
Independence: pulling from this stream does NOT
advance any CoordinateStream obtained from the
same CompiledComprehension.
Sourcepub fn scope_once<K: KernelScope>(
&self,
parent: &K,
coords: &Tuple,
) -> ScopedKernelInstance<K::Scoped>
pub fn scope_once<K: KernelScope>( &self, parent: &K, coords: &Tuple, ) -> ScopedKernelInstance<K::Scoped>
One-shot surface (comprehension_forms.md §9.5.3).
Apply parent.scope(coords) directly, without
constructing any streamer. Pure function — no
cursor consulted, no dispense state advanced. Used
for replay, debugging, and point queries where a
specific coord tuple is already known.
Trait Implementations§
Source§impl Clone for CompiledComprehension
impl Clone for CompiledComprehension
Auto Trait Implementations§
impl Freeze for CompiledComprehension
impl RefUnwindSafe for CompiledComprehension
impl Send for CompiledComprehension
impl Sync for CompiledComprehension
impl Unpin for CompiledComprehension
impl UnsafeUnpin for CompiledComprehension
impl UnwindSafe for CompiledComprehension
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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