diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index e76ef31c..70c774f4 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -748,6 +748,9 @@ fn polymorphic_print<'ctx>( generator: &mut dyn CodeGenerator, fmt: String, args: Vec>| { + assert!(!fmt.is_empty()); + assert_eq!(fmt.as_bytes().last().unwrap(), &0u8); + let fn_name = if as_rtio { "rtio_log" } else { "core_log" }; let print_fn = ctx.module.get_function(fn_name).unwrap_or_else(|| { let llvm_pi8 = ctx.ctx.i8_type().ptr_type(AddressSpace::default()); @@ -763,8 +766,15 @@ fn polymorphic_print<'ctx>( println!("printf({fmt}, [{}])", args.iter().map(|arg| arg.to_string()).join(", ")); + let fmt_val = ctx.gen_string(generator, "hi :)\0"); + let fmt_val = unsafe { fmt_val.get_field_at_index_unchecked(0) }.into_pointer_value(); + println!("fmt_val: {}", fmt_val); + + ctx.builder.build_call(print_fn, &[fmt_val.into()], "").unwrap(); + let fmt = ctx.gen_string(generator, fmt); let fmt = unsafe { fmt.get_field_at_index_unchecked(0) }.into_pointer_value(); + println!("fmt: {}", fmt); ctx.builder .build_call(