Load derived member impls into derived module for mono

This commit is contained in:
Ayaz Hafiz 2022-06-21 18:11:45 -04:00
parent a8006d225e
commit e8fb186d79
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
9 changed files with 168 additions and 25 deletions

View file

@ -102,6 +102,18 @@ impl DerivedSymbols {
*symbol
}
pub fn iter_all(&self) -> impl Iterator<Item = (&DeriveKey, &Symbol)> {
self.map.iter()
}
/// Generate a unique symbol. This should only be used when generating code inside the Derived
/// module; other modules should use [`Self::get_or_insert`] to generate a symbol for a derived
/// ability member usage.
pub fn gen_unique(&mut self) -> Symbol {
let ident_id = self.derived_ident_ids.gen_unique();
Symbol::new(ModuleId::DERIVED, ident_id)
}
/// Steal all created derived ident Ids.
/// After this is called, [`Self::get_or_insert`] may no longer be called.
pub fn steal(&mut self) -> IdentIds {
@ -110,11 +122,22 @@ impl DerivedSymbols {
#[cfg(debug_assertions)]
{
debug_assert!(!self.stolen);
self.stolen = true;
}
ident_ids
}
pub fn return_ident_ids(&mut self, ident_ids: IdentIds) {
#[cfg(debug_assertions)]
{
debug_assert!(self.stolen);
self.stolen = false;
}
self.derived_ident_ids = ident_ids;
}
}
/// Thread-sharable [`DerivedMethods`].