From 36e5a4cc07c963e89edd409d9050fe67c10e7e8d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 5 Jan 2023 14:35:49 +0300 Subject: refactor(tvix/eval): take owned ast::Expr in Compiler::compile This adds a very minimal amount of additional Rc-increments (~1 per compilation), but makes it a lot easier to add an AST-optimising compiler pass without incurring a lot of extra cost. Change-Id: I57208bdfc8882e3ae21c5850e14aa380d3ccea36 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7765 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/eval/src/compiler/bindings.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tvix/eval/src/compiler/bindings.rs') diff --git a/tvix/eval/src/compiler/bindings.rs b/tvix/eval/src/compiler/bindings.rs index 12eaae5c19..9d42690023 100644 --- a/tvix/eval/src/compiler/bindings.rs +++ b/tvix/eval/src/compiler/bindings.rs @@ -585,7 +585,7 @@ impl Compiler<'_> { // Create a thunk wrapping value (which may be one as well) // to avoid forcing the from expr too early. self.thunk(binding.value_slot, &namespace, |c, s| { - c.compile(s, &namespace); + c.compile(s, namespace.clone()); c.emit_force(&namespace); c.emit_constant(Value::String(name.into()), &span); @@ -595,7 +595,7 @@ impl Compiler<'_> { // Binding is "just" a plain expression that needs to be // compiled. - Binding::Plain { expr } => self.compile(binding.value_slot, &expr), + Binding::Plain { expr } => self.compile(binding.value_slot, expr), // Binding is a merged or nested attribute set, and needs to be // recursively compiled as another binding. @@ -651,7 +651,7 @@ impl Compiler<'_> { self.compile_bindings(slot, BindingsKind::LetIn, node); // Deal with the body, then clean up the locals afterwards. - self.compile(slot, &node.body().unwrap()); + self.compile(slot, node.body().unwrap()); self.cleanup_scope(node); } -- cgit 1.4.1