diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-01-27 12:04:23 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-01-27 12:04:36 +0100 |
| commit | 1de53730bce0bd3f9de89db1da7c19b7889b9a75 (patch) | |
| tree | e2746f4853a5a8e99f32e8c52d6e4b4f411c1933 /src/model/scope.rs | |
| parent | 13efa128c855637a7fe3351a4579383359d1be1b (diff) | |
Symbol values and modules
Diffstat (limited to 'src/model/scope.rs')
| -rw-r--r-- | src/model/scope.rs | 9 |
1 files changed, 9 insertions, 0 deletions
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) |
