Skip to main content

PolydatAssembler

Struct PolydatAssembler 

Source
pub struct PolydatAssembler { /* private fields */ }
Expand description

Builder for assembling a Polydat Kernel programmatically.

Implementations§

Source§

impl PolydatAssembler

Source

pub fn new(input_names: Vec<String>) -> Self

Create a new assembler with the given coordinate names.

Source

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.

Source

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.

Source

pub fn cursor_schemas(&self) -> &[SourceSchema]

The cursors the program declares.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_output_modifier(&mut self, name: &str, modifier: BindingModifier)

Set the binding modifier for a named output.

Source

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.

Source

pub fn node_count(&self) -> usize

How many nodes the graph holds so far.

Source

pub fn add_output( &mut self, name: impl Into<String>, wire: WireRef, ) -> &mut Self

Designate a wire as a named output variate.

Source

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.

Source

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.

Source

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.

Source

pub fn set_input_variance(&mut self, variance: InputVariance)

What resolve does with an input whose type was inferred.

Source

pub fn input_names(&self) -> Vec<&str>

Return the names of all inputs (coordinates + captures).

Source

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.

Source

pub fn output_names(&self) -> Vec<&str>

Return the names of declared outputs.

Source

pub fn node_type_of(&self, name: &str) -> Option<String>

The node type a named node has, when the name is a node.

Source

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.

Source

pub fn input_type(&self, name: &str) -> Option<PortType>

Look up the port type of a graph input by name.

Source

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).

Source

pub fn compile(self) -> Result<PolydatKernel, AssemblyError>

Validate, resolve, and produce a Phase 1 runtime kernel.

Source

pub fn compile_with_log( self, log: Option<&mut CompileEventLog>, ) -> Result<PolydatKernel, AssemblyError>

Compile with diagnostic event logging.

Source

pub fn compile_closures_raw(self) -> Result<CompiledKernelRaw, KernelError>

The closure tier with no provenance, as its own type.

Source

pub fn compile_native_raw(self) -> Result<HybridKernelRaw, KernelError>

The native tier with no provenance, as its own type.

Source

pub fn compile_pure_native_raw(self) -> Result<JitKernelRaw, KernelError>

Pure native code with no provenance, as its own type.

Source§

impl PolydatAssembler

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more