From 69f362b53d41500f78873731ac31bf15465ca042 Mon Sep 17 00:00:00 2001 From: mlokr Date: Wed, 4 Sep 2024 18:38:32 +0200 Subject: [PATCH] disasm now displays literal string value --- hblang/src/codegen.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hblang/src/codegen.rs b/hblang/src/codegen.rs index 95502f1..2767978 100644 --- a/hblang/src/codegen.rs +++ b/hblang/src/codegen.rs @@ -8,7 +8,7 @@ use { parser::{self, find_symbol, idfl, CtorField, Expr, ExprRef, FileId, Pos}, HashMap, }, - std::{fmt::Display, ops::Range, rc::Rc}, + std::{fmt::Display, ops::Range, rc::Rc, usize}, }; type Offset = u32; @@ -3275,12 +3275,19 @@ impl Codegen { ) }), ) - .chain( - self.output - .strings - .iter() - .map(|s| (s.range.start, ("string", s.range.len() as _, DisasmItem::Global))), - ) + .chain(self.output.strings.iter().map(|s| { + ( + s.range.start, + ( + std::str::from_utf8( + &self.output.code[s.range.start as usize..s.range.end as usize - 1], + ) + .unwrap_or("!!!!invalid string"), + s.range.len() as _, + DisasmItem::Global, + ), + ) + })) .collect::>(); crate::disasm(&mut sluce, &functions, output, |bin| { if self.ct.active()