diff options
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r-- | tvix/eval/src/vm.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 8ee17258602e..0d0249e3f6c0 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -10,6 +10,9 @@ use crate::{ value::{NixAttrs, NixList, Value}, }; +#[cfg(feature = "disassembler")] +use crate::disassembler::Tracer; + pub struct VM { ip: usize, chunk: Chunk, @@ -88,8 +91,12 @@ impl VM { } fn run(&mut self) -> EvalResult<Value> { + #[cfg(feature = "disassembler")] + let mut tracer = Tracer::new(); + loop { - match self.inc_ip() { + let op = self.inc_ip(); + match op { OpCode::OpConstant(idx) => { let c = self.chunk.constant(idx).clone(); self.push(c); @@ -261,6 +268,11 @@ impl VM { } } + #[cfg(feature = "disassembler")] + { + tracer.trace(&op, self.ip, &self.stack); + } + if self.ip == self.chunk.code.len() { return Ok(self.pop()); } |