diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-05-06 23:02:47 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-05-06 23:02:47 +0100 |
| commit | 03fbdc3f75e60178f9bc70e3fd4b232d588cb3a4 (patch) | |
| tree | 47f0319d7cd304b72f470d8edb9d74098f4190a5 /src | |
| parent | ea6a4859eda5bbebf02838061babf1ba1821324b (diff) | |
Fix IR printing bug with global unicode identifiers
Diffstat (limited to 'src')
| -rw-r--r-- | src/ir_print.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/ir_print.c b/src/ir_print.c index 92833eaf4..e6b77aec3 100644 --- a/src/ir_print.c +++ b/src/ir_print.c @@ -71,7 +71,7 @@ bool ir_valid_char(u8 c) { return false; } -void ir_print_escape_string(irFileBuffer *f, String name, bool print_quotes) { +void ir_print_escape_string(irFileBuffer *f, String name, bool print_quotes, bool prefix_with_dot) { isize extra = 0; for (isize i = 0; i < name.len; i++) { u8 c = name.text[i]; @@ -87,7 +87,7 @@ void ir_print_escape_string(irFileBuffer *f, String name, bool print_quotes) { char hex_table[] = "0123456789ABCDEF"; - isize buf_len = name.len + extra + 2; + isize buf_len = name.len + extra + 2 + 1; gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&string_buffer_arena); @@ -99,6 +99,10 @@ void ir_print_escape_string(irFileBuffer *f, String name, bool print_quotes) { buf[j++] = '"'; } + if (prefix_with_dot) { + buf[j++] = '.'; + } + for (isize i = 0; i < name.len; i++) { u8 c = name.text[i]; if (ir_valid_char(c)) { @@ -124,15 +128,12 @@ void ir_print_escape_string(irFileBuffer *f, String name, bool print_quotes) { void ir_print_encoded_local(irFileBuffer *f, String name) { ir_fprintf(f, "%%"); - ir_print_escape_string(f, name, true); + ir_print_escape_string(f, name, true, false); } void ir_print_encoded_global(irFileBuffer *f, String name, bool remove_prefix) { ir_fprintf(f, "@"); - if (!remove_prefix) { - ir_fprintf(f, "."); - } - ir_print_escape_string(f, name, true); + ir_print_escape_string(f, name, true, !remove_prefix); } void ir_print_type(irFileBuffer *f, irModule *m, Type *t); @@ -361,7 +362,7 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type * if (!is_type_string(type)) { GB_ASSERT(is_type_array(type)); ir_fprintf(f, "c\""); - ir_print_escape_string(f, str, false); + ir_print_escape_string(f, str, false, false); ir_fprintf(f, "\""); } else { // HACK NOTE(bill): This is a hack but it works because strings are created at the very end @@ -622,7 +623,7 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type * void ir_print_block_name(irFileBuffer *f, irBlock *b) { if (b != NULL) { - ir_print_escape_string(f, b->label, false); + ir_print_escape_string(f, b->label, false, false); ir_fprintf(f, "-%td", b->index); } else { ir_fprintf(f, "<INVALID-BLOCK>"); |