From ce2f7d20599e57247a82e70a8d5cfdcf0e0527e9 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Mon, 11 Nov 2024 23:02:02 +0100 Subject: [PATCH] fixing negation truncation --- lang/src/son/hbvm.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lang/src/son/hbvm.rs b/lang/src/son/hbvm.rs index e263ada0..470da46a 100644 --- a/lang/src/son/hbvm.rs +++ b/lang/src/son/hbvm.rs @@ -566,7 +566,12 @@ impl TokenKind { fn unop(&self, dst: ty::Id, src: ty::Id) -> Option EncodedInstr> { let src_idx = src.simple_size().unwrap().ilog2() as usize - 2; Some(match self { - Self::Sub => instrs::neg, + Self::Sub => [ + |a, b| sub8(a, 0, b), + |a, b| sub16(a, 0, b), + |a, b| sub32(a, 0, b), + |a, b| sub64(a, 0, b), + ][src.simple_size().unwrap().ilog2() as usize], Self::Not => instrs::not, Self::Float if dst.is_float() && src.is_integer() => { debug_assert_matches!(