Skip to content

Commit

Permalink
Add nodes field to EGraph (#291)
Browse files Browse the repository at this point in the history
* Added `nodes` field to `EGraph` to avoid storing nodes in `analysis` and `analysis_pending`

* eliminated `node` field of `ExplainNode` (used `EGraph.nodes` instead)

* serde

* serde

* Clarify `id_to_expr` and prevent `copy_with_unions` when explanations are disabled

* Added note that enode in `make` may not be canonical
  • Loading branch information
dewert99 authored Apr 3, 2024
1 parent c7e9284 commit 3231b86
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 214 deletions.
10 changes: 5 additions & 5 deletions src/eclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub struct EClass<L, D> {
/// Modifying this field will _not_ cause changes to propagate through the e-graph.
/// Prefer [`EGraph::set_analysis_data`] instead.
pub data: D,
/// The parent enodes and their original Ids.
pub(crate) parents: Vec<(L, Id)>,
/// The original Ids of parent enodes.
pub(crate) parents: Vec<Id>,
}

impl<L, D> EClass<L, D> {
Expand All @@ -37,9 +37,9 @@ impl<L, D> EClass<L, D> {
self.nodes.iter()
}

/// Iterates over the parent enodes of this eclass.
pub fn parents(&self) -> impl ExactSizeIterator<Item = (&L, Id)> {
self.parents.iter().map(|(node, id)| (node, *id))
/// Iterates over the non-canonical ids of parent enodes of this eclass.
pub fn parents(&self) -> impl ExactSizeIterator<Item = Id> + '_ {
self.parents.iter().copied()
}
}

Expand Down
Loading

0 comments on commit 3231b86

Please sign in to comment.