From b69b50feb1a1323188cf1f6da2141c5e8d21999a Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 3 Oct 2022 16:08:59 +0300 Subject: refactor(tvix/eval): split observer traits in two There are actually two different types of observers, the ones that observe the compiler (and emitted chunks from different kinds of expressions), and the ones that trace runtime execution. Use of the NoOpObserver is unchanged, it simply implements both traits. Change-Id: I4277b82674c259ec55238a0de3bb1cdf5e21a258 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6852 Tested-by: BuildkiteCI Reviewed-by: grfn --- tvix/eval/src/vm.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tvix/eval/src/vm.rs') diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 39c9c6e822..41f51a9874 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -6,7 +6,7 @@ use std::{cell::RefMut, rc::Rc}; use crate::{ chunk::Chunk, errors::{Error, ErrorKind, EvalResult}, - observer::Observer, + observer::RuntimeObserver, opcode::{CodeIdx, Count, JumpOffset, OpCode, StackIdx, UpvalueIdx}, upvalues::{UpvalueCarrier, Upvalues}, value::{Builtin, Closure, CoercionKind, Lambda, NixAttrs, NixList, Thunk, Value}, @@ -43,7 +43,7 @@ pub struct VM<'o> { /// dynamically resolved (`with`). with_stack: Vec, - observer: &'o mut dyn Observer, + observer: &'o mut dyn RuntimeObserver, } /// This macro wraps a computation that returns an ErrorKind or a @@ -127,7 +127,7 @@ macro_rules! cmp_op { } impl<'o> VM<'o> { - pub fn new(observer: &'o mut dyn Observer) -> Self { + pub fn new(observer: &'o mut dyn RuntimeObserver) -> Self { Self { observer, frames: vec![], @@ -780,7 +780,7 @@ fn unwrap_or_clone_rc(rc: Rc) -> T { Rc::try_unwrap(rc).unwrap_or_else(|rc| (*rc).clone()) } -pub fn run_lambda(observer: &mut dyn Observer, lambda: Rc) -> EvalResult { +pub fn run_lambda(observer: &mut dyn RuntimeObserver, lambda: Rc) -> EvalResult { let mut vm = VM::new(observer); let value = vm.call(lambda, Upvalues::with_capacity(0), 0)?; vm.force_for_output(&value)?; -- cgit 1.4.1