diff --git a/src/serialize.rs b/src/serialize.rs index 59b423f4d..f2c4de214 100644 --- a/src/serialize.rs +++ b/src/serialize.rs @@ -1,7 +1,10 @@ use ordered_float::NotNan; use std::collections::VecDeque; -use crate::{util::HashMap, ArcSort, EGraph, Function, Symbol, TupleOutput, Value}; +use crate::{ + extract::Extractor, util::HashMap, ArcSort, EGraph, Function, Symbol, TermDag, TupleOutput, + Value, +}; pub struct SerializeConfig { // Maximumum number of functions to include in the serialized graph, any after this will be discarded @@ -312,7 +315,13 @@ impl EGraph { let op = if sort.is_container_sort() { sort.serialized_name(value).to_string() } else { - sort.make_expr(self, *value).1.to_string() + let mut termdag = TermDag::default(); + let extractor = Extractor::new(self, &mut termdag); + let (cost, term) = sort + .extract_term(self, *value, &extractor, &mut termdag) + .expect("Extraction should be successful since extractor has been fully initialized"); + + termdag.term_to_expr(&term).to_string() }; egraph.nodes.insert( node_id.clone(), diff --git a/src/sort/mod.rs b/src/sort/mod.rs index 97f7c8edf..f9f66a742 100644 --- a/src/sort/mod.rs +++ b/src/sort/mod.rs @@ -105,18 +105,6 @@ pub trait Sort: Any + Send + Sync + Debug { _extractor: &Extractor, _termdag: &mut TermDag, ) -> Option<(Cost, Term)>; - - /// Extracting an expression (with smallest cost) out of a primitive value. - /// The default implementation uses [`Sort::extract_term`]. - fn make_expr(&self, egraph: &EGraph, value: Value) -> (Cost, Expr) { - let mut termdag = TermDag::default(); - let extractor = Extractor::new(egraph, &mut termdag); - let (cost, term) = self - .extract_term(egraph, value, &extractor, &mut termdag) - .expect("Extraction should be successful since extractor has been fully initialized"); - - (cost, termdag.term_to_expr(&term)) - } } // Note: this trait is currently intended to be implemented on the