use std::collections::BTreeMap;
use std::sync::Arc;
pub(super) type Bindings = BTreeMap<Box<str>, Arc<str>>;
#[derive(Default)]
pub(super) struct ReceiverScope {
bindings: Bindings,
}
impl ReceiverScope {
pub(super) fn enter(&mut self) -> Bindings {
std::mem::take(&mut self.bindings)
}
pub(super) fn leave(&mut self, restored: Bindings) {
self.bindings = restored;
}
pub(super) fn record(&mut self, name: Box<str>, type_name: Arc<str>) {
self.bindings.insert(name, type_name);
}
pub(super) fn lookup(&self, receiver: &str) -> Option<Arc<str>> {
self.bindings.get(receiver).cloned()
}
}