Skip to content

Commit

Permalink
bump 0.0.34
Browse files Browse the repository at this point in the history
  • Loading branch information
memoryleak47 committed Nov 25, 2024
1 parent 26b3347 commit 28aa701
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "slotted-egraphs"
version = "0.0.33"
version = "0.0.34"
edition = "2021"
description = "E-Graphs with name binding"
license = "Apache-2.0 OR MIT"
Expand All @@ -15,7 +15,7 @@ trace = ["tracing/max_level_trace", "tracing/release_max_level_trace", "tracing"
features = ["explanations"]

[dependencies]
slotted-egraphs-derive = "=0.0.33"
slotted-egraphs-derive = "=0.0.34"
fnv = "1.0.7"
tracing = { version = "0.1", features = ["attributes"], optional = true }
symbol_table = { version = "0.3", features = ["global"] }
Expand Down
2 changes: 1 addition & 1 deletion slotted-egraphs-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "slotted-egraphs-derive"
description = "proc macros to implement slotted Languages"
version = "0.0.33"
version = "0.0.34"
edition = "2021"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/memoryleak47/slotted-egraphs/"
Expand Down
23 changes: 23 additions & 0 deletions slotted-egraphs-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub fn define_language(input: TokenStream1) -> TokenStream1 {
let from_syntax_arms1: Vec<TokenStream2> = ie.variants.iter().zip(&str_names).filter_map(|(x, n)| produce_from_syntax1(&name, &n, x)).collect();
let from_syntax_arms2: Vec<TokenStream2> = ie.variants.iter().zip(&str_names).filter_map(|(x, n)| produce_from_syntax2(&name, &n, x)).collect();

let slots_arms: Vec<TokenStream2> = ie.variants.iter().map(|x| produce_slots(&name, x)).collect();

quote! {
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
#ie
Expand Down Expand Up @@ -96,6 +98,12 @@ pub fn define_language(input: TokenStream1) -> TokenStream1 {
},
}
}

fn slots(&self) -> slotted_egraphs::HashSet<Slot> {
match self {
#(#slots_arms),*
}
}
}
}.to_token_stream().into()
}
Expand Down Expand Up @@ -257,3 +265,18 @@ fn produce_from_syntax2(name: &Ident, e: &Option<Expr>, v: &Variant) -> Option<T
}
})
}

fn produce_slots(name: &Ident, v: &Variant) -> TokenStream2 {
let variant_name = &v.ident;
let n = v.fields.len();
let fields: Vec<Ident> = (0..n).map(|x| Ident::new(&format!("a{x}"), proc_macro2::Span::call_site())).collect();
quote! {
#name::#variant_name(#(#fields),*) => {
let out = std::iter::empty();
#(
let out = out.chain(#fields .public_slot_occurrences_iter().copied());
)*
out.collect()
}
}
}
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ use std::error::Error;
use std::sync::Arc;
use std::ops::Deref;

pub(crate) type HashMap<K, V> = fnv::FnvHashMap<K, V>;
pub(crate) type HashSet<T> = fnv::FnvHashSet<T>;
#[doc(hidden)]
pub type HashMap<K, V> = fnv::FnvHashMap<K, V>;

#[doc(hidden)]
pub type HashSet<T> = fnv::FnvHashSet<T>;

pub use symbol_table::GlobalSymbol as Symbol;

Expand Down

0 comments on commit 28aa701

Please sign in to comment.