about summary refs log tree commit diff
path: root/src/common/env.rs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2021-03-08T05·04-0500
committerGriffin Smith <root@gws.fyi>2021-03-08T05·04-0500
commit1ea2d8ba9fef3bee2c757d19d8b42e541e3fe390 (patch)
tree6999d66bb363fce16a078abfc913fa1610c1437c /src/common/env.rs
parent80f8ede0bbc9799d5199707e1e1ad8e80e4ca7ac (diff)
Implement functions, both top-level and anonymous
Implement both top-level and anonymous functions, but not closures in
either case.
Diffstat (limited to 'src/common/env.rs')
-rw-r--r--src/common/env.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/env.rs b/src/common/env.rs
index 8b5cde49e9e4..f499323639e3 100644
--- a/src/common/env.rs
+++ b/src/common/env.rs
@@ -1,4 +1,5 @@
 use std::collections::HashMap;
+use std::mem;
 
 use crate::ast::Ident;
 
@@ -25,6 +26,14 @@ impl<'ast, V> Env<'ast, V> {
         self.0.pop();
     }
 
+    pub fn save(&mut self) -> Self {
+        mem::take(self)
+    }
+
+    pub fn restore(&mut self, saved: Self) {
+        *self = saved;
+    }
+
     pub fn set(&mut self, k: &'ast Ident<'ast>, v: V) {
         self.0.last_mut().unwrap().insert(k, v);
     }