From 1de53730bce0bd3f9de89db1da7c19b7889b9a75 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 27 Jan 2023 12:04:23 +0100 Subject: Symbol values and modules --- src/model/scope.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/model/scope.rs') diff --git a/src/model/scope.rs b/src/model/scope.rs index bb0d4684..40307cba 100644 --- a/src/model/scope.rs +++ b/src/model/scope.rs @@ -108,6 +108,15 @@ impl Scope { self.0.insert(var.into(), Slot::new(value.into(), Kind::Captured)); } + /// Copy definitions from another scope that aren't yet defined in this one. + pub fn copy_from(&mut self, other: &Self) { + for (name, value) in other.iter() { + self.0 + .entry(name.clone()) + .or_insert_with(|| Slot::new(value.clone(), Kind::Normal)); + } + } + /// Try to access a variable immutably. pub fn get(&self, var: &str) -> Option<&Value> { self.0.get(var).map(Slot::read) -- cgit v1.2.3