From 802e8b5d5563a6871cf64b8e867212e6a2f2d465 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Mon, 30 Sep 2024 21:55:34 +0200 Subject: [PATCH] fixing a leaked reg bug when constant happens --- hblang/src/codegen.rs | 1 + hblang/src/fs.rs | 4 ++-- hblang/src/main.rs | 2 ++ hblang/src/parser.rs | 1 - 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hblang/src/codegen.rs b/hblang/src/codegen.rs index f022f6d..4931320 100644 --- a/hblang/src/codegen.rs +++ b/hblang/src/codegen.rs @@ -1242,6 +1242,7 @@ impl Codegen { self.ci.emit(neg(dst.get(), oper.get())); self.ci.free_loc(drop_loc); + self.ci.regs.free(oper); Some(Value::new(value.ty, dst)) } diff --git a/hblang/src/fs.rs b/hblang/src/fs.rs index 3e18852..82047e4 100644 --- a/hblang/src/fs.rs +++ b/hblang/src/fs.rs @@ -20,8 +20,8 @@ use { pub struct Logger; impl log::Log for Logger { - fn enabled(&self, metadata: &log::Metadata) -> bool { - log::max_level() >= metadata.level() + fn enabled(&self, _: &log::Metadata) -> bool { + true } fn log(&self, record: &log::Record) { diff --git a/hblang/src/main.rs b/hblang/src/main.rs index 8f86d03..753cb15 100644 --- a/hblang/src/main.rs +++ b/hblang/src/main.rs @@ -3,9 +3,11 @@ fn main() -> std::io::Result<()> { use std::io::Write; log::set_logger(&hblang::Logger).unwrap(); + log::set_max_level(log::LevelFilter::Error); let args = std::env::args().collect::>(); let args = args.iter().map(String::as_str).collect::>(); + let opts = hblang::Options::from_args(&args)?; let file = args.iter().filter(|a| !a.starts_with('-')).nth(1).copied().unwrap_or("main.hb"); diff --git a/hblang/src/parser.rs b/hblang/src/parser.rs index faf35ed..cfd57a9 100644 --- a/hblang/src/parser.rs +++ b/hblang/src/parser.rs @@ -1314,7 +1314,6 @@ pub fn report_to( _ = writeln!(out, "{}", line.replace("\t", " ")); _ = writeln!(out, "{}^", " ".repeat(col - 1)); - todo!() } #[derive(PartialEq, Eq, Hash)]