about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-28T10·34+0300
committertazjin <tazjin@tvl.su>2022-09-29T11·47+0000
commit09a57e7857d85cf27b88a8aca21a0dc96847c040 (patch)
tree8f1d02a449156cd107a0e7f84296f9af8ea6657c /tvix
parent82df0b432ae85b04d48c4c4352c2173de251e6e5 (diff)
refactor(tvix/eval): emit OpAttrs inside of compile_bindings r/4994
This needs to move here so that we can reuse compile_bindings for the
nested attribute sets we're about to start constructing.

Change-Id: Ie83f52f7e1d128886e96a1da47792211fa826f21
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6796
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/compiler/bindings.rs10
-rw-r--r--tvix/eval/src/compiler/mod.rs2
2 files changed, 6 insertions, 6 deletions
diff --git a/tvix/eval/src/compiler/bindings.rs b/tvix/eval/src/compiler/bindings.rs
index 95ae85569aaa..7d6b30569392 100644
--- a/tvix/eval/src/compiler/bindings.rs
+++ b/tvix/eval/src/compiler/bindings.rs
@@ -319,8 +319,7 @@ impl Compiler<'_> {
             BindingsKind::Attrs
         };
 
-        let count = self.compile_bindings(slot, kind, &node);
-        self.push_op(OpCode::OpAttrs(Count(count)), &node);
+        self.compile_bindings(slot, kind, &node);
 
         // Remove the temporary scope, but do not emit any additional cleanup
         // (OpAttrs consumes all of these locals).
@@ -389,7 +388,7 @@ impl Compiler<'_> {
         }
     }
 
-    fn compile_bindings<N>(&mut self, slot: LocalIdx, kind: BindingsKind, node: &N) -> usize
+    fn compile_bindings<N>(&mut self, slot: LocalIdx, kind: BindingsKind, node: &N)
     where
         N: ToSpan + ast::HasEntry,
     {
@@ -406,7 +405,9 @@ impl Compiler<'_> {
         // Actually bind values and ensure they are on the stack.
         self.bind_values(bindings);
 
-        count
+        if kind.is_attrs() {
+            self.push_op(OpCode::OpAttrs(Count(count)), node);
+        }
     }
 
     /// Compile a standard `let ...; in ...` expression.
@@ -425,7 +426,6 @@ impl Compiler<'_> {
         self.emit_warning(&node, WarningKind::DeprecatedLegacyLet);
         self.scope_mut().begin_scope();
         self.compile_bindings(slot, BindingsKind::RecAttrs, &node);
-        self.push_op(OpCode::OpAttrs(Count(node.entries().count())), &node);
         self.emit_constant(Value::String(SmolStr::new_inline("body").into()), &node);
         self.push_op(OpCode::OpAttrsSelect, &node);
     }
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index bae58434b3a1..6a3d10acf62d 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -19,7 +19,7 @@ mod spans;
 
 use codemap::Span;
 use path_clean::PathClean;
-use rnix::ast::{self, AstToken, HasEntry};
+use rnix::ast::{self, AstToken};
 use smol_str::SmolStr;
 use std::collections::HashMap;
 use std::path::{Path, PathBuf};