From 4920989c00e2eb23bae3467cba3637b148f886c9 Mon Sep 17 00:00:00 2001 From: David Mak Date: Mon, 12 Aug 2024 16:56:43 +0800 Subject: [PATCH] WIP - Fix bool format --- nac3artiq/src/codegen.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index 082a68cd..06928086 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -849,18 +849,18 @@ fn polymorphic_print<'ctx>( fmt.push_str("%.*s"); let true_str = ctx.gen_string(generator, "True"); + let true_data = unsafe { true_str.get_field_at_index_unchecked(0) }.into_pointer_value(); + let true_len = unsafe { true_str.get_field_at_index_unchecked(1) }.into_pointer_value(); let false_str = ctx.gen_string(generator, "False"); + let false_data = unsafe { false_str.get_field_at_index_unchecked(0) }.into_pointer_value(); + let false_len = unsafe { false_str.get_field_at_index_unchecked(1) }.into_pointer_value(); - args.push( - ctx.builder - .build_select( - generator.bool_to_i1(ctx, value.into_int_value()), - true_str, - false_str, - "", - ) - .unwrap(), - ); + let bool_val = generator.bool_to_i1(ctx, value.into_int_value()); + + args.extend([ + ctx.builder.build_select(bool_val, true_len, false_len, "").unwrap(), + ctx.builder.build_select(bool_val, true_data, false_data, "").unwrap(), + ]); } TypeEnum::TObj { obj_id, .. }