refactor(tvix/eval): return a lambda from the compiler

Changes the internal compiler plumbing to not just return a chunk of
code, but the same chunk wrapped inside of a lambda value.

This is one more step towards compiling runtime lambdas.

Change-Id: If0035f8e65a2970c5ae123fc068a2396e1d8fd72
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6240
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-08-23 22:54:25 +03:00 committed by tazjin
parent 4715f9a3a0
commit 6f31c895ff
5 changed files with 28 additions and 16 deletions

View file

@ -31,7 +31,7 @@ pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
let result = crate::compiler::compile(root_expr, location)?;
#[cfg(feature = "disassembler")]
crate::disassembler::disassemble_chunk(&result.chunk);
crate::disassembler::disassemble_chunk(&result.lambda.chunk);
for warning in result.warnings {
eprintln!(
@ -49,5 +49,5 @@ pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
return Err(err.clone());
}
crate::vm::run_chunk(result.chunk)
crate::vm::run_lambda(result.lambda)
}