aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-11-20 16:01:59 +0000
committergingerBill <bill@gingerbill.org>2020-11-20 16:01:59 +0000
commit6416a6f39cce4c65c80e29bb4ff4b93a3e463947 (patch)
tree2bf6668068ab0516998fb6bde144a3d4a69bac9e /src/ir_print.cpp
parent87956676f52a56db98e263d1074b490b71141f0b (diff)
Allow string literals for `[N]byte`
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 0605058ee..3ca9954ef 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -745,7 +745,7 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
ir_write_byte(f, ']');
return;
- } else if (is_type_array(type) &&
+ } else if (is_type_array(type) &&
value.kind != ExactValue_Invalid &&
value.kind != ExactValue_String &&
value.kind != ExactValue_Compound) {
@@ -796,7 +796,11 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
GB_ASSERT(is_type_array(type));
ir_write_str_lit(f, "c\"");
ir_print_escape_string(f, str, false, false);
- ir_write_str_lit(f, "\\00\"");
+ if (type->Array.count == str.len) {
+ ir_write_str_lit(f, "\"");
+ } else {
+ ir_write_str_lit(f, "\\00\"");
+ }
} else if (is_type_cstring(t)) {
// HACK NOTE(bill): This is a hack but it works because strings are created at the very end
// of the .ll file
@@ -810,7 +814,7 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
ir_write_str_lit(f, ", ");
ir_print_type(f, m, t_i32);
ir_write_str_lit(f, " 0, i32 0)");
- }else {
+ } else {
// HACK NOTE(bill): This is a hack but it works because strings are created at the very end
// of the .ll file
irValue *str_array = ir_add_global_string_array(m, str);