the light is getting closer

This commit is contained in:
2025-05-04 04:12:56 -04:00
parent 5f36be9de9
commit 6583d47ef8
23 changed files with 1261 additions and 740 deletions

View File

@@ -4,7 +4,7 @@ pub struct NameStack<T>(Vec<HashMap<String, T>>);
impl<T> NameStack<T> {
pub fn new() -> Self {
Self(Vec::new())
Self(vec![HashMap::new()])
}
pub fn search(&self, name: &str) -> Option<&T> {
for level in self.0.iter().rev() {
@@ -14,4 +14,10 @@ impl<T> NameStack<T> {
}
None
}
pub fn push(&mut self) {
self.0.push(HashMap::new());
}
pub fn pop(&mut self) {
self.0.pop();
}
}