about summary refs log tree commit diff
path: root/tvix/eval/src/compiler
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-10-03T13·08+0300
committertazjin <tazjin@tvl.su>2022-10-04T21·27+0000
commitb69b50feb1a1323188cf1f6da2141c5e8d21999a (patch)
tree6ff7a8dd8ac3182673e71913c7e8bd90aed9df44 /tvix/eval/src/compiler
parentd6643f66b1cb8db5fc802ad53ef0d2633a51e815 (diff)
refactor(tvix/eval): split observer traits in two r/5033
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 <grfn@gws.fyi>
Diffstat (limited to 'tvix/eval/src/compiler')
-rw-r--r--tvix/eval/src/compiler/mod.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index 6a3d10acf62d..d69566f070d2 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -28,7 +28,7 @@ use std::sync::Arc;
 
 use crate::chunk::Chunk;
 use crate::errors::{Error, ErrorKind, EvalResult};
-use crate::observer::Observer;
+use crate::observer::CompilerObserver;
 use crate::opcode::{CodeIdx, Count, JumpOffset, OpCode, UpvalueIdx};
 use crate::value::{Closure, Lambda, Thunk, Value};
 use crate::warnings::{EvalWarning, WarningKind};
@@ -95,7 +95,7 @@ struct Compiler<'observer> {
 
     /// Carry an observer for the compilation process, which is called
     /// whenever a chunk is emitted.
-    observer: &'observer mut dyn Observer,
+    observer: &'observer mut dyn CompilerObserver,
 }
 
 /// Compiler construction
@@ -104,7 +104,7 @@ impl<'observer> Compiler<'observer> {
         location: Option<PathBuf>,
         file: Arc<codemap::File>,
         globals: HashMap<&'static str, Value>,
-        observer: &'observer mut dyn Observer,
+        observer: &'observer mut dyn CompilerObserver,
     ) -> EvalResult<Self> {
         let mut root_dir = match location {
             Some(dir) => Ok(dir),
@@ -1146,7 +1146,7 @@ pub fn compile(
     location: Option<PathBuf>,
     file: Arc<codemap::File>,
     globals: HashMap<&'static str, Value>,
-    observer: &mut dyn Observer,
+    observer: &mut dyn CompilerObserver,
 ) -> EvalResult<CompilationOutput> {
     let mut c = Compiler::new(location, file, globals, observer)?;