aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-11-20 16:24:23 +0000
committergingerBill <bill@gingerbill.org>2020-11-20 16:24:23 +0000
commit63e4a2341f1409eec1f2e58036cd01b24b66b8f0 (patch)
tree93801df8d25cb3c09c77d293fa4a53a513bb4383 /src/ir_print.cpp
parent6416a6f39cce4c65c80e29bb4ff4b93a3e463947 (diff)
Support string literals for fixed arrays of runes; Add %q support for arrays/slices of bytes
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 3ca9954ef..a6bfc75d3 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -734,6 +734,28 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
if (is_type_array(type) && value.kind == ExactValue_String && !is_type_u8(core_array_type(type))) {
i64 count = type->Array.count;
Type *elem = type->Array.elem;
+
+ if (is_type_rune_array(type)) {
+ Rune rune;
+ isize offset = 0;
+ isize width = 1;
+ String s = value.value_string;
+ ir_write_byte(f, '[');
+ for (i64 i = 0; i < count && offset < s.len; i++) {
+ width = gb_utf8_decode(s.text+offset, s.len-offset, &rune);
+ if (i > 0) ir_write_str_lit(f, ", ");
+ ir_print_type(f, m, elem);
+ ir_write_byte(f, ' ');
+ ir_print_exact_value(f, m, exact_value_i64(rune), elem);
+ offset += width;
+ }
+ GB_ASSERT(offset == s.len);
+
+ ir_write_byte(f, ']');
+ return;
+ }
+
+
ir_write_byte(f, '[');
for (i64 i = 0; i < count; i++) {