pub struct PolydatAssembler { /* private fields */ }Expand description
Builder for assembling a Polydat Kernel programmatically.
Implementations§
Source§impl PolydatAssembler
impl PolydatAssembler
Sourcepub fn new(input_names: Vec<String>) -> Self
pub fn new(input_names: Vec<String>) -> Self
Create a new assembler with the given coordinate names.
Sourcepub fn set_resources(&mut self, resources: ResourceScope)
pub fn set_resources(&mut self, resources: ResourceScope)
The resource scope every kernel built from this assembler reports
through Kernel::resources. A caller
that builds nodes itself hands each factory a
BuildContext over the same
scope, so the nodes and the kernel see one accessor.
Sourcepub fn set_cursor_schemas(&mut self, schemas: Vec<SourceSchema>)
pub fn set_cursor_schemas(&mut self, schemas: Vec<SourceSchema>)
Record the cursors the program declares, with the partitions the
compiler resolved for each. Every kernel built from this
assembler reports them through cursor_schemas and narrows one
through set_cursor.
Sourcepub fn cursor_schemas(&self) -> &[SourceSchema]
pub fn cursor_schemas(&self) -> &[SourceSchema]
The cursors the program declares.
Sourcepub fn set_strict_wires(&mut self, _strict_types: bool, strict_values: bool)
pub fn set_strict_wires(&mut self, _strict_types: bool, strict_values: bool)
Set the strict_types and strict_values pragmas
(graph_compiler.md §2). Under strict_values the resolver
checks constant sources at build and inserts value assertion
nodes on the other constrained wires. strict_types has no
effect: wires are statically typed, so a runtime type assertion
has nothing to catch. Both are off by default.
Sourcepub fn set_strict(&mut self, strict: bool)
pub fn set_strict(&mut self, strict: bool)
Strict mode, on every engine this assembler builds for: an
implicit type coercion, a config wire fed from a cycle-time
source, a nondeterministic node no volatile output
acknowledges, and a binding nothing reads are errors. Off by
default; the DSL sets it from its strict option.
Sourcepub fn set_jit_mode(&mut self, mode: JitMode)
pub fn set_jit_mode(&mut self, mode: JitMode)
Override the interpreter’s cone mode for this compile
(engines.md §2).
Unset means JitMode::Auto.
Sourcepub fn set_context(&mut self, source: &str, context: &str)
pub fn set_context(&mut self, source: &str, context: &str)
Set the source text and diagnostic context for this assembler. Called by the DSL compiler to attach the original Polydat source.
Sourcepub fn add_node(
&mut self,
name: impl Into<String>,
node: Box<dyn PolydatNode>,
inputs: Vec<WireRef>,
) -> &mut Self
pub fn add_node( &mut self, name: impl Into<String>, node: Box<dyn PolydatNode>, inputs: Vec<WireRef>, ) -> &mut Self
Add a node to the assembler with the given name and input wiring.
Sourcepub fn set_output_modifier(&mut self, name: &str, modifier: BindingModifier)
pub fn set_output_modifier(&mut self, name: &str, modifier: BindingModifier)
Set the binding modifier for a named output.
Sourcepub fn mark_const_output(&mut self, name: &str)
pub fn mark_const_output(&mut self, name: &str)
Mark an output as a const: a value fixed for the life of every
kernel built from this assembler. name is an output, or a node
when no output has the name.
A const whose value is known at build (it reads no input and no
nondeterministic node) folds there. Any other const is captured
when a kernel is initialized (crate::Kernel::init), the same
way on every engine: its expression is evaluated once and every
reader of it reads the captured value. See
crate::kernel::ConstInit.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
How many nodes the graph holds so far.
Sourcepub fn add_output(
&mut self,
name: impl Into<String>,
wire: WireRef,
) -> &mut Self
pub fn add_output( &mut self, name: impl Into<String>, wire: WireRef, ) -> &mut Self
Designate a wire as a named output variate.
Sourcepub fn add_input(
&mut self,
name: impl Into<String>,
default: Value,
port_type: PortType,
kind: InputKind,
) -> &mut Self
pub fn add_input( &mut self, name: impl Into<String>, default: Value, port_type: PortType, kind: InputKind, ) -> &mut Self
Declare an additional named input.
Added after coordinate inputs. Nodes wire to it via
WireRef::input(name) — same as coordinate inputs.
kind controls the lifecycle classification used by the
init-binding contract (see
crates/polydat/docs/design/evaluation_model.md
§“Effectively-Const Nodes”): IterationExtern for slots
populated by materialize_wiring_from_outer, ExternalWrite for slots
written by capture extraction.
Sourcepub fn set_input_type(&mut self, name: &str, port_type: PortType)
pub fn set_input_type(&mut self, name: &str, port_type: PortType)
Override a declared input’s port type. new seeds every
input_names entry with PortType::U64; this applies the type
from an input <name>: <type> declaration. No-op if the input
isn’t present.
Sourcepub fn set_input_origin(&mut self, name: &str, origin: TypeOrigin)
pub fn set_input_origin(&mut self, name: &str, origin: TypeOrigin)
Record how input name’s type was established: the compiler
marks an auto-extern Inferred, so input_variance can open it
(input_variance.md §3). add_input records Declared.
Sourcepub fn set_input_variance(&mut self, variance: InputVariance)
pub fn set_input_variance(&mut self, variance: InputVariance)
What resolve does with an input whose type was inferred.
Sourcepub fn input_names(&self) -> Vec<&str>
pub fn input_names(&self) -> Vec<&str>
Return the names of all inputs (coordinates + captures).
Sourcepub fn node_output_type(&self, name: &str) -> Option<PortType>
pub fn node_output_type(&self, name: &str) -> Option<PortType>
Query the output port type of a named node (first output).
Returns None if the node is not found or has no output
ports; callers surface the absence as a loud diagnostic
rather than silently substituting a default.
Sourcepub fn output_names(&self) -> Vec<&str>
pub fn output_names(&self) -> Vec<&str>
Return the names of declared outputs.
Sourcepub fn node_type_of(&self, name: &str) -> Option<String>
pub fn node_type_of(&self, name: &str) -> Option<String>
The node type a named node has, when the name is a node.
Sourcepub fn output_type(&self, name: &str) -> Option<PortType>
pub fn output_type(&self, name: &str) -> Option<PortType>
Look up the output port type of a named node.
Returns the first output port’s PortType if the node exists.
Sourcepub fn input_type(&self, name: &str) -> Option<PortType>
pub fn input_type(&self, name: &str) -> Option<PortType>
Look up the port type of a graph input by name.
Sourcepub fn wire_type(&self, wire: &WireRef) -> Option<PortType>
pub fn wire_type(&self, wire: &WireRef) -> Option<PortType>
Look up the produced port type of a WireRef. Returns None
if the wire’s source isn’t yet known to the assembler (e.g.
it points to a not-yet-added node — a bug in the binding
compiler if it happens).
Sourcepub fn compile(self) -> Result<PolydatKernel, AssemblyError>
pub fn compile(self) -> Result<PolydatKernel, AssemblyError>
Validate, resolve, and produce a Phase 1 runtime kernel.
Sourcepub fn compile_with_log(
self,
log: Option<&mut CompileEventLog>,
) -> Result<PolydatKernel, AssemblyError>
pub fn compile_with_log( self, log: Option<&mut CompileEventLog>, ) -> Result<PolydatKernel, AssemblyError>
Compile with diagnostic event logging.
Sourcepub fn compile_closures_raw(self) -> Result<CompiledKernelRaw, KernelError>
pub fn compile_closures_raw(self) -> Result<CompiledKernelRaw, KernelError>
The closure tier with no provenance, as its own type.
Sourcepub fn compile_native_raw(self) -> Result<HybridKernelRaw, KernelError>
pub fn compile_native_raw(self) -> Result<HybridKernelRaw, KernelError>
The native tier with no provenance, as its own type.
Sourcepub fn compile_pure_native_raw(self) -> Result<JitKernelRaw, KernelError>
pub fn compile_pure_native_raw(self) -> Result<JitKernelRaw, KernelError>
Pure native code with no provenance, as its own type.
Source§impl PolydatAssembler
impl PolydatAssembler
Sourcepub fn compile_with(
self,
engine: Engine,
) -> Result<Box<dyn Kernel>, KernelError>
pub fn compile_with( self, engine: Engine, ) -> Result<Box<dyn Kernel>, KernelError>
Build a kernel on engine: the interpreter, the closure tier,
the hybrid kernel, or pure native code, with the provenance mode
the engine names. Every engine accepts every program the
interpreter accepts, or refuses it with a reason naming the node
or construct (KernelError::Refused). The older constructors
(compile, try_compile*, compile_hybrid)
remain as aliases of this one for their engine.
Sourcepub fn compile_kernel(self) -> Result<Box<dyn Kernel>, KernelError>
pub fn compile_kernel(self) -> Result<Box<dyn Kernel>, KernelError>
Self::compile_with on Engine::default: compiled code, with
the JIT where the build has it.
Sourcepub fn compile_engine_with_log(
self,
engine: Engine,
log: Option<&mut CompileEventLog>,
) -> Result<Box<dyn Kernel>, KernelError>
pub fn compile_engine_with_log( self, engine: Engine, log: Option<&mut CompileEventLog>, ) -> Result<Box<dyn Kernel>, KernelError>
Self::compile_with with the compile event log, which
receives the assembly events for every engine.
Sourcepub fn compile_slots(
self,
engine: Engine,
) -> Result<Box<dyn SlotKernel>, KernelError>
pub fn compile_slots( self, engine: Engine, ) -> Result<Box<dyn SlotKernel>, KernelError>
Build on engine and keep the slot surface: the same kernel
Self::compile_with builds, typed as
SlotKernel so a caller can read
a buffer slot and evaluate one without boxing a Value.
For testing, measurement and diagnostics, where the layout is
the subject. Normative use is compile_with, which returns the
same kernel as Box<dyn Kernel>; a Box<dyn SlotKernel>
upcasts to one wherever the ordinary surface will do, so a
caller that wants both needs only this call.
Engine::Interpreter is refused, and cannot be anything else:
the interpreter holds typed Value buffers and has no slot to
name. Ask for a compiled engine, or use compile_with and the
Kernel trait, which every engine answers.
Sourcepub fn compile_slots_with_log(
self,
engine: Engine,
log: Option<&mut CompileEventLog>,
) -> Result<Box<dyn SlotKernel>, KernelError>
pub fn compile_slots_with_log( self, engine: Engine, log: Option<&mut CompileEventLog>, ) -> Result<Box<dyn SlotKernel>, KernelError>
Self::compile_slots with the compile event log. The kernel is
initialized before it is returned: its consts are evaluated.
Auto Trait Implementations§
impl !RefUnwindSafe for PolydatAssembler
impl !UnwindSafe for PolydatAssembler
impl Freeze for PolydatAssembler
impl Send for PolydatAssembler
impl Sync for PolydatAssembler
impl Unpin for PolydatAssembler
impl UnsafeUnpin for PolydatAssembler
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