From f95c6ee2390df1810c7b4ffd500f54fe2faa7110 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 18 May 2025 11:48:04 -0400 Subject: [PATCH] cl-interpret: Add convenience function for binding variables --- compiler/cl-interpret/src/env.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/cl-interpret/src/env.rs b/compiler/cl-interpret/src/env.rs index 89d7bd4..4731674 100644 --- a/compiler/cl-interpret/src/env.rs +++ b/compiler/cl-interpret/src/env.rs @@ -99,6 +99,11 @@ impl Environment { function.call(self, args) } + /// Binds a value to the given name in the current scope. + pub fn bind(&mut self, name: &str, value: impl Into) { + self.insert(name.into(), Some(value.into())); + } + /// Gets all registered globals, bound or unbound. pub fn globals(&self) -> &HashMap> { &self.global