mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Load derived member impls into derived module for mono
This commit is contained in:
parent
a8006d225e
commit
e8fb186d79
9 changed files with 168 additions and 25 deletions
|
@ -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`].
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue