Skip to main content

polydat_core/iteration/comprehension/ir/
mod.rs

1// Copyright 2024-2026 Jonathan Shook
2// SPDX-License-Identifier: Apache-2.0
3
4//! IR + compiler + interpreter — spec §9.1, §9.2, §9.3.
5//!
6//! The IR is a finite linear sequence of opcodes (the 8-op
7//! set in [`Op`]) that compiles from an optimized AST and
8//! executes via a stack-machine interpreter (`Interpreter`)
9//! or a stream-fusion compiler (future). Both interpretation
10//! models produce identical dispense sequences per spec §9.2.
11//!
12//! ## Module layout
13//!
14//! - [`op`] — the 8-opcode enum + supporting parameter types.
15//! - [`program`] — `#[non_exhaustive] Program` wrapper:
16//!   immutable, accessible by value (spec §9.1).
17//! - [`compile`](fn@compile) — bottom-up AST → IR walker.
18//! - [`interpreter`] — stack-machine interpreter; produces a
19//!   tuple stream that pulls lazily.
20//! - [`bounds`] — §9.3 closed-form peak-memory checker.
21
22pub mod bounds;
23pub mod compile;
24pub mod interpreter;
25pub mod op;
26pub mod program;
27
28pub use bounds::{Bound, ResourceBound, check_bounds};
29pub use compile::compile;
30pub use interpreter::{TupleStream, interpret};
31pub use op::{Op, OrderStreamingKind};
32pub use program::Program;