refactor(tvix/eval): introduce Closure struct in Value type
This struct will carry the upvalue machinery in addition to the lambda itself. For now, all lambdas are wrapped in closures (though technically analysis of the environment can later remove innermost Closure wrapper, but this optimisation may not be worth it). Change-Id: If2b68549ec1ea4ab838fdc47a2181c694ac937f2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6269 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
parent
af9dca3663
commit
6ce2c666c3
5 changed files with 17 additions and 10 deletions
|
@ -23,7 +23,7 @@ use std::rc::Rc;
|
|||
use crate::chunk::Chunk;
|
||||
use crate::errors::{Error, ErrorKind, EvalResult};
|
||||
use crate::opcode::{CodeIdx, OpCode};
|
||||
use crate::value::{Lambda, Value};
|
||||
use crate::value::{Closure, Lambda, Value};
|
||||
use crate::warnings::{EvalWarning, WarningKind};
|
||||
|
||||
/// Represents the result of compiling a piece of Nix code. If
|
||||
|
@ -822,7 +822,9 @@ impl Compiler {
|
|||
crate::disassembler::disassemble_chunk(&compiled.lambda.chunk);
|
||||
}
|
||||
|
||||
self.emit_constant(Value::Lambda(compiled.lambda));
|
||||
self.emit_constant(Value::Closure(Closure {
|
||||
lambda: compiled.lambda,
|
||||
}));
|
||||
}
|
||||
|
||||
fn compile_apply(&mut self, node: ast::Apply) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue