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 <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
0e421a16c5
commit
36e5a4cc07
2 changed files with 34 additions and 34 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue