about summary refs log tree commit diff
path: root/tvix/eval/src/observer.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-10-04T14·05+0300
committertazjin <tazjin@tvl.su>2022-10-05T10·29+0000
commit3530404a4a1cc363d87e559ac24780aa318adb19 (patch)
tree71458cd9fdc83efd71c3c0187e2381a5434fc7f7 /tvix/eval/src/observer.rs
parent2ff764ceb700a1ef18fb532fbbc1ff937ed63f8a (diff)
refactor(tvix/eval): introduce source::SourceCode type r/5035
This type hides away the lower-level handling of most codemap data
structures, especially to library consumers (see corresponding changes
in tvixbolt).

This will help with implement `import` by giving us central control
over how the codemap works.

Change-Id: Ifcea36776879725871b30c518aeb96ab5fda035a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6855
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
Diffstat (limited to 'tvix/eval/src/observer.rs')
-rw-r--r--tvix/eval/src/observer.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/tvix/eval/src/observer.rs b/tvix/eval/src/observer.rs
index ce237529f5b5..8572c2c1eb42 100644
--- a/tvix/eval/src/observer.rs
+++ b/tvix/eval/src/observer.rs
@@ -6,7 +6,6 @@
 //!
 //! All methods are optional, that is, observers can implement only
 /// what they are interested in observing.
-use codemap::CodeMap;
 use std::io::Write;
 use std::rc::Rc;
 use tabwriter::TabWriter;
@@ -14,6 +13,7 @@ use tabwriter::TabWriter;
 use crate::chunk::Chunk;
 use crate::opcode::{CodeIdx, OpCode};
 use crate::value::Lambda;
+use crate::SourceCode;
 use crate::Value;
 
 /// Implemented by types that wish to observe internal happenings of
@@ -69,14 +69,14 @@ impl RuntimeObserver for NoOpObserver {}
 /// internal writer whenwever the compiler emits a toplevel function,
 /// closure or thunk.
 pub struct DisassemblingObserver<W: Write> {
-    codemap: Rc<CodeMap>,
+    source: SourceCode,
     writer: TabWriter<W>,
 }
 
 impl<W: Write> DisassemblingObserver<W> {
-    pub fn new(codemap: Rc<CodeMap>, writer: W) -> Self {
+    pub fn new(source: SourceCode, writer: W) -> Self {
         Self {
-            codemap,
+            source,
             writer: TabWriter::new(writer),
         }
     }
@@ -96,7 +96,7 @@ impl<W: Write> DisassemblingObserver<W> {
         let width = format!("{:#x}", chunk.code.len() - 1).len();
 
         for (idx, _) in chunk.code.iter().enumerate() {
-            let _ = chunk.disassemble_op(&mut self.writer, &self.codemap, width, CodeIdx(idx));
+            let _ = chunk.disassemble_op(&mut self.writer, &self.source, width, CodeIdx(idx));
         }
     }
 }