Skip to content

Commit

Permalink
Remove unconditional get_sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Fischman committed Oct 12, 2024
1 parent e754728 commit 91d252c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1477,11 +1477,6 @@ impl EGraph {
self.type_info.get_sort_by(pred)
}

/// Returns a sort based on the type
pub fn get_sort<S: Sort + Send + Sync>(&self) -> Option<Arc<S>> {
self.type_info.get_sort_by(|_| true)
}

/// Add a user-defined sort
pub fn add_arcsort(&mut self, arcsort: ArcSort) -> Result<(), TypeError> {
self.type_info.add_arcsort(arcsort, DUMMY_SPAN.clone())
Expand Down Expand Up @@ -1602,21 +1597,18 @@ mod tests {
fn test_user_defined_primitive() {
let mut egraph = EGraph::default();
egraph
.parse_and_run_program(
None,
"
(sort IntVec (Vec i64))
",
)
.parse_and_run_program(None, "(sort IntVec (Vec i64))")
.unwrap();
let i64_sort: Arc<I64Sort> = egraph.get_sort().unwrap();

let int_vec_sort: Arc<VecSort> = egraph
.get_sort_by(|s: &Arc<VecSort>| s.element_name() == i64_sort.name())
.get_sort_by(|s: &Arc<VecSort>| s.element_name() == I64Sort.name())
.unwrap();

egraph.add_primitive(InnerProduct {
ele: i64_sort,
ele: I64Sort.into(),
vec: int_vec_sort,
});

egraph
.parse_and_run_program(
None,
Expand Down
2 changes: 2 additions & 0 deletions src/sort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ use crate::*;

pub trait Sort: Any + Send + Sync + Debug {
fn name(&self) -> Symbol;

fn as_arc_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static>;

fn is_eq_sort(&self) -> bool {
false
}
Expand Down

0 comments on commit 91d252c

Please sign in to comment.