about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2023-03-13T12·53-0700
committertazjin <tazjin@tvl.su>2023-03-13T21·33+0000
commite7a534e0c66758530b02ffce608e9f5bef9db3c5 (patch)
treebec17fc35062d2ea1726566d9b96f0b780dd4119 /tvix
parent47895c4c30932ebdcfc326ca5ab800f2012ae843 (diff)
refactor(tvix/eval): reduce fetch{forced|captured}_with visibility r/5990
This commit moves fetch_forced_with and fetch_captured_with into the
scope of their only caller (resolve_with).

Change-Id: I9a8bc27228888729d591e8cb021c431b2b6468f5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8289
Autosubmit: Adam Joseph <adam@westernsemico.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/vm/mod.rs44
1 files changed, 22 insertions, 22 deletions
diff --git a/tvix/eval/src/vm/mod.rs b/tvix/eval/src/vm/mod.rs
index 6ecd264d36a7..febd4ebd9777 100644
--- a/tvix/eval/src/vm/mod.rs
+++ b/tvix/eval/src/vm/mod.rs
@@ -998,28 +998,6 @@ impl<'o> VM<'o> {
     }
 }
 
-/// Fetch and force a value on the with-stack from the VM.
-async fn fetch_forced_with(co: &GenCo, idx: usize) -> Value {
-    match co.yield_(GeneratorRequest::WithValue(idx)).await {
-        GeneratorResponse::Value(value) => value,
-        msg => panic!(
-            "Tvix bug: VM responded with incorrect generator message: {}",
-            msg
-        ),
-    }
-}
-
-/// Fetch and force a value on the *captured* with-stack from the VM.
-async fn fetch_captured_with(co: &GenCo, idx: usize) -> Value {
-    match co.yield_(GeneratorRequest::CapturedWithValue(idx)).await {
-        GeneratorResponse::Value(value) => value,
-        msg => panic!(
-            "Tvix bug: VM responded with incorrect generator message: {}",
-            msg
-        ),
-    }
-}
-
 /// Resolve a dynamically bound identifier (through `with`) by looking
 /// for matching values in the with-stacks carried at runtime.
 async fn resolve_with(
@@ -1028,6 +1006,28 @@ async fn resolve_with(
     vm_with_len: usize,
     upvalue_with_len: usize,
 ) -> Result<Value, ErrorKind> {
+    /// Fetch and force a value on the with-stack from the VM.
+    async fn fetch_forced_with(co: &GenCo, idx: usize) -> Value {
+        match co.yield_(GeneratorRequest::WithValue(idx)).await {
+            GeneratorResponse::Value(value) => value,
+            msg => panic!(
+                "Tvix bug: VM responded with incorrect generator message: {}",
+                msg
+            ),
+        }
+    }
+
+    /// Fetch and force a value on the *captured* with-stack from the VM.
+    async fn fetch_captured_with(co: &GenCo, idx: usize) -> Value {
+        match co.yield_(GeneratorRequest::CapturedWithValue(idx)).await {
+            GeneratorResponse::Value(value) => value,
+            msg => panic!(
+                "Tvix bug: VM responded with incorrect generator message: {}",
+                msg
+            ),
+        }
+    }
+
     for with_stack_idx in (0..vm_with_len).rev() {
         // TODO(tazjin): is this branch still live with the current with-thunking?
         let with = fetch_forced_with(&co, with_stack_idx).await;