pub struct ExprPool { /* private fields */ }Expand description
Process-wide shared hash-consing pool (spec §8.1/§12.4): maps content hash → ExprId.
The central store is append-only (the symbolic layer is acyclic and resident), concurrency-safe.
Implementations§
Source§impl ExprPool
impl ExprPool
pub fn new() -> ExprPool
Sourcepub fn global() -> &'static ExprPool
pub fn global() -> &'static ExprPool
Process-wide shared instance (OnceLock): the interpreter and the symbolic engine share one pool.
Sourcepub fn intern(&self, data: ExprData) -> ExprId
pub fn intern(&self, data: ExprData) -> ExprId
Intern flow (spec §8.1): content hash → local cache → global pool → append-allocate and write
back to both caches. The same ExprData always yields the same ExprId.
pub fn get(&self, id: ExprId) -> Option<ExprData>
pub fn symbol(&self, id: SymbolId) -> ExprId
pub fn integer(&self, n: i64) -> ExprId
pub fn real(&self, x: f64) -> ExprId
pub fn number(&self, n: &Number) -> ExprId
pub fn const_number(&self, id: ExprId) -> Option<Number>
pub fn is_const_zero(&self, id: ExprId) -> bool
pub fn is_const_one(&self, id: ExprId) -> bool
Sourcepub fn add(&self, items: &[ExprId]) -> ExprId
pub fn add(&self, items: &[ExprId]) -> ExprId
Raw Add node (no simplification), stored in canonical order (spec §8.4).
Sourcepub fn mul(&self, items: &[ExprId]) -> ExprId
pub fn mul(&self, items: &[ExprId]) -> ExprId
Raw Mul node (no simplification), stored in canonical order (spec §8.4).
pub fn pow(&self, base: ExprId, exp: ExprId) -> ExprId
pub fn apply(&self, f: ExprId, args: &[ExprId]) -> ExprId
Sourcepub fn add_n(&self, items: &[ExprId]) -> ExprId
pub fn add_n(&self, items: &[ExprId]) -> ExprId
Level 0/1 addition simplification (spec §8.3): Add flattening, constant merging, x+0→x;
the result is sorted in canonical order (numbers/constants → symbols → composite nodes, spec §8.4).
Sourcepub fn mul_n(&self, items: &[ExprId]) -> ExprId
pub fn mul_n(&self, items: &[ExprId]) -> ExprId
Level 0/1 multiplication simplification (spec §8.3): Mul flattening, constant merging, 0*x→0, 1*x→x.
pub fn add2(&self, a: ExprId, b: ExprId) -> ExprId
pub fn mul2(&self, a: ExprId, b: ExprId) -> ExprId
Sourcepub fn pow2(&self, base: ExprId, exp: ExprId) -> ExprId
pub fn pow2(&self, base: ExprId, exp: ExprId) -> ExprId
Level 0/1 power simplification (spec §8.3): x^0→1, x^1→x, 1^x→1, plus constant folding at the same level.