pub struct EnvIndex {
pub name_idx: NameIndex,
pub type_idx: TypeIndex,
pub module_idx: ModuleIndex,
pub size: usize,
}Expand description
Composite index combining name, type, and module indices.
Provides a single entry point for all indexed lookups over a kernel
Environment. The index is append-only: names are inserted as
declarations are added, and ids are never recycled.
Fields§
§name_idx: NameIndexBidirectional name ↔ id mapping.
type_idx: TypeIndexIndex over sort level and Pi arity.
module_idx: ModuleIndexIndex grouping declarations by namespace.
size: usizeTotal number of indexed declarations (equals name_idx.len()).
Implementations§
Source§impl EnvIndex
impl EnvIndex
Sourcepub fn insert(&mut self, name: &str) -> u32
pub fn insert(&mut self, name: &str) -> u32
Insert a declaration name into all sub-indices and return its id.
The sort level is recorded as 0 and the arity as 0 for the base
call-site (callers that have type information should use the individual
sub-index methods directly after calling insert).
If the name already exists, its existing id is returned and size is
not incremented again.
Sourcepub fn lookup<'a>(&'a self, name: &str) -> Option<LookupResult<'a>>
pub fn lookup<'a>(&'a self, name: &str) -> Option<LookupResult<'a>>
Look up name and return a LookupResult on success.
Sourcepub fn by_namespace(&self, prefix: &str) -> Vec<u32>
pub fn by_namespace(&self, prefix: &str) -> Vec<u32>
Return all declaration ids whose namespace prefix equals prefix.
Sourcepub fn stats(&self) -> IndexStats
pub fn stats(&self) -> IndexStats
Return an IndexStats snapshot for this index.
by_kind is left empty; callers that track declaration kinds may
populate it externally.