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

@ -3,10 +3,21 @@ use std::rc::Rc;
use crate::chunk::Chunk;
use super::NixString;
#[derive(Clone, Debug)]
pub struct Lambda {
name: Option<NixString>,
chunk: Rc<Chunk>,
// name: Option<NixString>,
pub(crate) chunk: Rc<Chunk>,
}
impl Lambda {
pub fn new_anonymous() -> Self {
Lambda {
// name: None,
chunk: Default::default(),
}
}
pub fn chunk(&mut self) -> &mut Rc<Chunk> {
&mut self.chunk
}
}