mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
Merge branch 'trunk' into add-list-dropLast
This commit is contained in:
commit
a4b5b81d60
48 changed files with 1242 additions and 693 deletions
|
@ -1,7 +1,9 @@
|
|||
use crate::ident::{Ident, ModuleName};
|
||||
use crate::module_err::{IdentIdNotFound, ModuleIdNotFound, ModuleResult};
|
||||
use roc_collections::all::{default_hasher, MutMap, SendMap};
|
||||
use roc_ident::IdentStr;
|
||||
use roc_region::all::Region;
|
||||
use snafu::OptionExt;
|
||||
use std::collections::HashMap;
|
||||
use std::{fmt, u32};
|
||||
|
||||
|
@ -253,6 +255,30 @@ impl Interns {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_module_ident_ids<'a>(
|
||||
all_ident_ids: &'a MutMap<ModuleId, IdentIds>,
|
||||
module_id: &ModuleId,
|
||||
) -> ModuleResult<&'a IdentIds> {
|
||||
all_ident_ids
|
||||
.get(module_id)
|
||||
.with_context(|| ModuleIdNotFound {
|
||||
module_id: format!("{:?}", module_id),
|
||||
all_ident_ids: format!("{:?}", all_ident_ids),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_module_ident_ids_mut<'a>(
|
||||
all_ident_ids: &'a mut MutMap<ModuleId, IdentIds>,
|
||||
module_id: &ModuleId,
|
||||
) -> ModuleResult<&'a mut IdentIds> {
|
||||
all_ident_ids
|
||||
.get_mut(module_id)
|
||||
.with_context(|| ModuleIdNotFound {
|
||||
module_id: format!("{:?}", module_id),
|
||||
all_ident_ids: "I could not return all_ident_ids here because of borrowing issues.",
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
lazy_static! {
|
||||
/// This is used in Debug builds only, to let us have a Debug instance
|
||||
|
@ -621,6 +647,17 @@ impl IdentIds {
|
|||
pub fn get_name(&self, id: IdentId) -> Option<&Ident> {
|
||||
self.by_id.get(id.0 as usize)
|
||||
}
|
||||
|
||||
pub fn get_name_str_res(&self, ident_id: IdentId) -> ModuleResult<&str> {
|
||||
Ok(self
|
||||
.get_name(ident_id)
|
||||
.with_context(|| IdentIdNotFound {
|
||||
ident_id,
|
||||
ident_ids_str: format!("{:?}", self),
|
||||
})?
|
||||
.as_inline_str()
|
||||
.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
// BUILTINS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue