diff --git a/dust-cli/src/main.rs b/dust-cli/src/main.rs index e3f9154..872084b 100644 --- a/dust-cli/src/main.rs +++ b/dust-cli/src/main.rs @@ -158,7 +158,11 @@ fn main() { return; } }; - let disassembly = chunk.disassembler().style(style).disassemble(); + let disassembly = chunk + .disassembler() + .style(style) + .source(&source) + .disassemble(); println!("{}", disassembly); diff --git a/dust-lang/src/disassembler.rs b/dust-lang/src/disassembler.rs index aa4afd4..a4651e4 100644 --- a/dust-lang/src/disassembler.rs +++ b/dust-lang/src/disassembler.rs @@ -16,6 +16,9 @@ //! ```text //! ┌──────────────────────────────────────────────────────────────────────────────┐ //! │ dust │ +//! │ │ +//! │ write_line("hello_world") │ +//! │ │ //! │ 3 instructions, 1 constants, 0 locals, returns none │ //! │ │ //! │ Instructions │ @@ -30,7 +33,7 @@ //! │ --------- │ //! │ i TYPE VALUE │ //! │ --- ---------------- ----------------- │ -//! │ 0 str Hello, world! │ +//! │ 0 str hello_world │ //! └──────────────────────────────────────────────────────────────────────────────┘ //! ``` use std::env::current_exe; @@ -91,7 +94,7 @@ impl<'a> Disassembler<'a> { (longest_line.chars().count() + 2).max(80) } - pub fn set_source(&mut self, source: &'a str) -> &mut Self { + pub fn source(mut self, source: &'a str) -> Self { self.source = Some(source); self