about summary refs log tree commit diff
path: root/tvix/eval/src/value/function.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/value/function.rs')
-rw-r--r--tvix/eval/src/value/function.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tvix/eval/src/value/function.rs b/tvix/eval/src/value/function.rs
index e5db43d58ace..e8301d82da11 100644
--- a/tvix/eval/src/value/function.rs
+++ b/tvix/eval/src/value/function.rs
@@ -60,4 +60,15 @@ impl Closure {
     pub fn push_upvalue(&self, value: Value) {
         self.0.borrow_mut().upvalues.push(value)
     }
+
+    /// Resolve the deferred upvalues in the closure from a slice of
+    /// the current stack, using the indices stored in the deferred
+    /// values.
+    pub fn resolve_deferred_upvalues(&self, stack: &[Value]) {
+        for upvalue in self.0.borrow_mut().upvalues.iter_mut() {
+            if let Value::DeferredUpvalue(idx) = upvalue {
+                *upvalue = stack[idx.0].clone();
+            }
+        }
+    }
 }