22 lines
461 B
Rust
22 lines
461 B
Rust
use std::collections::HashMap;
|
|
|
|
use crate::ast::ItemId;
|
|
use crate::tokenizing::Location;
|
|
|
|
|
|
/// Maps top-level declarations to Locations in source code, to detect
|
|
/// multiply-defined top level items.
|
|
pub struct DeclLocations {
|
|
map: HashMap<ItemId, Location>
|
|
}
|
|
|
|
impl DeclLocations {
|
|
pub fn new() -> Self {
|
|
Self { map: HashMap::new() }
|
|
}
|
|
|
|
pub(crate) fn add_location(&mut self, id: &ItemId, loc: Location) {
|
|
self.map.insert(id.clone(), loc);
|
|
}
|
|
}
|