From 5a497cdf1cfae31c3a391ca803d8a0bd86bfab1b Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 15 Aug 2022 00:33:48 +0300 Subject: feat(tvix/eval): implement with_stack in VM Change-Id: I805c24c9a751ded15725ba9be651aa0869e013e5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6218 Tested-by: BuildkiteCI Reviewed-by: sterni Reviewed-by: grfn --- tvix/eval/src/vm.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src/vm.rs') diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 881d79ba98..66126881a8 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -17,6 +17,10 @@ pub struct VM { ip: usize, chunk: Chunk, stack: Vec, + + // Stack indices of attribute sets from which variables should be + // dynamically resolved (`with`). + with_stack: Vec, } macro_rules! arithmetic_op { @@ -277,7 +281,7 @@ impl VM { self.push(value) } - OpCode::OpPushWith(_idx) => todo!("with handling not implemented"), + OpCode::OpPushWith(idx) => self.with_stack.push(idx), } #[cfg(feature = "disassembler")] @@ -335,6 +339,7 @@ pub fn run_chunk(chunk: Chunk) -> EvalResult { chunk, ip: 0, stack: vec![], + with_stack: vec![], }; vm.run() -- cgit 1.4.1