@@ -745,7 +745,7 @@ impl Analysis<SimpleMath> for ConstantFolding {
745745 egg::merge_max(to, from)
746746 }
747747
748- fn make(egraph: &mut EGraph<SimpleMath, Self>, enode: &SimpleMath) -> Self::Data {
748+ fn make(egraph: &mut EGraph<SimpleMath, Self>, enode: &SimpleMath, _id: Id ) -> Self::Data {
749749 let x = |i: &Id| egraph[*i].data;
750750 match enode {
751751 SimpleMath::Num(n) => Some(*n),
@@ -785,7 +785,7 @@ pub trait Analysis<L: Language>: Sized {
785785 /// The per-[`EClass`] data for this analysis.
786786 type Data : Debug ;
787787
788- /// Makes a new [`Analysis`] data for a given e-node.
788+ /// Makes a new [`Analysis`] data for a given e-node that will go into the given e-class .
789789 ///
790790 /// Note the mutable `egraph` parameter: this is needed for some
791791 /// advanced use cases, but most use cases will not need to mutate
@@ -795,7 +795,14 @@ pub trait Analysis<L: Language>: Sized {
795795 /// Doing so will create an infinite loop.
796796 ///
797797 /// Note that `enode`'s children may not be canonical
798- fn make ( egraph : & mut EGraph < L , Self > , enode : & L ) -> Self :: Data ;
798+ fn make ( egraph : & mut EGraph < L , Self > , enode : & L , id : Id ) -> Self :: Data ;
799+
800+ /// Same as [`Analysis::make`], but called during rebuilding.
801+ ///
802+ /// By default, it just calls `make`.
803+ fn remake ( egraph : & mut EGraph < L , Self > , enode : & L , id : Id ) -> Self :: Data {
804+ Self :: make ( egraph, enode, id)
805+ }
799806
800807 /// An optional hook that allows inspection before a [`union`] occurs.
801808 /// When explanations are enabled, it gives two ids that represent the two particular terms being unioned, not the canonical ids for the two eclasses.
@@ -862,7 +869,7 @@ pub trait Analysis<L: Language>: Sized {
862869
863870impl < L : Language > Analysis < L > for ( ) {
864871 type Data = ( ) ;
865- fn make ( _egraph : & mut EGraph < L , Self > , _enode : & L ) -> Self :: Data { }
872+ fn make ( _egraph : & mut EGraph < L , Self > , _enode : & L , _id : Id ) -> Self :: Data { }
866873 fn merge ( & mut self , _: & mut Self :: Data , _: Self :: Data ) -> DidMerge {
867874 DidMerge ( false , false )
868875 }
0 commit comments