about summary refs log tree commit diff
path: root/tvix/eval/src/disassembler.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-04T15·53+0300
committertazjin <tazjin@tvl.su>2022-09-09T21·10+0000
commitcbf2d2d29293af56d60fa7e04ee1969c18b9845f (patch)
tree2958af3ff31f27791632956641c5f6bcec6d72a1 /tvix/eval/src/disassembler.rs
parent3cf5c402091d1e10c26fddf6764f572495f38899 (diff)
refactor(tvix/eval): move `disassemble_op` to the Chunk structure r/4777
Change-Id: Ic6710c609ed647bfa47d673aaf22c4da96c0f319
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6451
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/disassembler.rs')
-rw-r--r--tvix/eval/src/disassembler.rs28
1 files changed, 1 insertions, 27 deletions
diff --git a/tvix/eval/src/disassembler.rs b/tvix/eval/src/disassembler.rs
index d7c9c8895c2e..51d39c3910a1 100644
--- a/tvix/eval/src/disassembler.rs
+++ b/tvix/eval/src/disassembler.rs
@@ -1,12 +1,10 @@
 //! Implements methods for disassembling and printing a representation
 //! of compiled code, as well as tracing the runtime stack during
 //! execution.
-use codemap::CodeMap;
 use std::io::{Stderr, Write};
 use tabwriter::TabWriter;
 
-use crate::chunk::Chunk;
-use crate::opcode::{CodeIdx, OpCode};
+use crate::opcode::OpCode;
 use crate::value::Value;
 
 /// Helper struct to trace runtime values and automatically flush the
@@ -41,27 +39,3 @@ impl Drop for Tracer {
         let _ = self.0.flush();
     }
 }
-
-pub fn disassemble_op<W: Write>(
-    tw: &mut W,
-    codemap: &CodeMap,
-    chunk: &Chunk,
-    width: usize,
-    idx: CodeIdx,
-) {
-    let _ = write!(tw, "{:#width$x}\t ", idx.0, width = width);
-
-    // Print continuation character if the previous operation was at
-    // the same line, otherwise print the line.
-    let line = chunk.get_line(codemap, idx);
-    if idx.0 > 0 && chunk.get_line(codemap, CodeIdx(idx.0 - 1)) == line {
-        write!(tw, "   |\t").unwrap();
-    } else {
-        write!(tw, "{:4}\t", line).unwrap();
-    }
-
-    let _ = match chunk[idx] {
-        OpCode::OpConstant(idx) => writeln!(tw, "OpConstant({}@{})", chunk[idx], idx.0),
-        op => writeln!(tw, "{:?}", op),
-    };
-}