From 40606d9272c960e6e16c7c062585fb84694ffb72 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 3 Nov 2019 00:47:27 +0000 Subject: [PATCH] Fix fmt printing of anonymous SOA structs --- core/fmt/fmt.odin | 76 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 39652e012..ff6657c0b 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -1329,8 +1329,10 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { return; } - strings.write_byte(fi.buf, '{'); - defer strings.write_byte(fi.buf, '}'); + is_soa := info.soa_base_type != nil; + + strings.write_byte(fi.buf, is_soa ? '[' : '{'); + defer strings.write_byte(fi.buf, is_soa ? '[' : '}'); fi.indent += 1; defer fi.indent -= 1; hash := fi.hash; defer fi.hash = hash; @@ -1339,26 +1341,70 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { if hash do strings.write_byte(fi.buf, '\n'); - for _, i in info.names { - if !hash && i > 0 do strings.write_string(fi.buf, ", "); - if hash { - for in 0.. 0 do strings.write_string(fi.buf, ", "); + + field_count := -1; + + if !hash && field_count > 0 do strings.write_string(fi.buf, ", "); + + strings.write_string(fi.buf, base_type_name); + strings.write_byte(fi.buf, '{'); + defer strings.write_byte(fi.buf, '}'); + + for name, i in info.names { + field_count += 1; + + if !hash && field_count > 0 do strings.write_string(fi.buf, ", "); + if hash do for in 0..