From 979209a526e800d78cdbf485c4196da2177b6993 Mon Sep 17 00:00:00 2001 From: occheung Date: Fri, 8 Nov 2024 17:12:01 +0800 Subject: [PATCH] binop: expand `not` operator as loglcal not --- nac3core/src/codegen/expr.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 8a010420..23baadb7 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -1777,7 +1777,12 @@ pub fn gen_unaryop_expr_with_values<'ctx, G: CodeGenerator>( ast::Unaryop::Invert => ctx.builder.build_not(val, "not").map(Into::into).unwrap(), ast::Unaryop::Not => ctx .builder - .build_xor(val, val.get_type().const_all_ones(), "not") + .build_int_compare( + inkwell::IntPredicate::EQ, + val, + val.get_type().const_zero(), + "not", + ) .map(Into::into) .unwrap(), ast::Unaryop::UAdd => val.into(), -- 2.44.2