From 6f31c895ffe2dc5dd8281d812252d5db0644ec77 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 23 Aug 2022 22:54:25 +0300 Subject: 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 --- tvix/eval/src/value/lambda.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'tvix/eval/src/value') diff --git a/tvix/eval/src/value/lambda.rs b/tvix/eval/src/value/lambda.rs index 2cecb4f5373b..d8609f50f367 100644 --- a/tvix/eval/src/value/lambda.rs +++ b/tvix/eval/src/value/lambda.rs @@ -3,10 +3,21 @@ use std::rc::Rc; use crate::chunk::Chunk; -use super::NixString; - #[derive(Clone, Debug)] pub struct Lambda { - name: Option, - chunk: Rc, + // name: Option, + pub(crate) chunk: Rc, +} + +impl Lambda { + pub fn new_anonymous() -> Self { + Lambda { + // name: None, + chunk: Default::default(), + } + } + + pub fn chunk(&mut self) -> &mut Rc { + &mut self.chunk + } } -- cgit 1.4.1