diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-02-23 22:22:56 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-02-23 22:22:56 +0000 |
| commit | a982c51c30141b88fd905c02225c2a7efdb39137 (patch) | |
| tree | 3aa5dd201a9fe386cb3f88ad284d8d736d7b5d1a /core | |
| parent | 047c0e4bcc415a1f0e7b55afd57900319e43dbef (diff) | |
Fix minor bugs in IR for slices
Diffstat (limited to 'core')
| -rw-r--r-- | core/_preload.odin | 6 | ||||
| -rw-r--r-- | core/fmt.odin | 24 |
2 files changed, 19 insertions, 11 deletions
diff --git a/core/_preload.odin b/core/_preload.odin index c1014fa95..de01bb244 100644 --- a/core/_preload.odin +++ b/core/_preload.odin @@ -89,9 +89,9 @@ Type_Info :: union { } -// // NOTE(bill): only the ones that are needed (not all types) -// // This will be set by the compiler -__type_infos: []Type_Info; +// NOTE(bill): only the ones that are needed (not all types) +// This will be set by the compiler +__type_table: []Type_Info; type_info_base :: proc(info: ^Type_Info) -> ^Type_Info { if info == nil { diff --git a/core/fmt.odin b/core/fmt.odin index 54fbfa7f3..e623f533b 100644 --- a/core/fmt.odin +++ b/core/fmt.odin @@ -206,10 +206,12 @@ buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) { } buffer_write_byte(buf, '{'); for name, i in info.names { + if i > 0 { + buffer_write_string(buf, ", "); + } buffer_write_string(buf, name); buffer_write_string(buf, ": "); buffer_write_type(buf, info.types[i]); - buffer_write_byte(buf, ','); } buffer_write_byte(buf, '}'); @@ -227,7 +229,7 @@ buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) { total_count += 1; } for name, i in info.variant_names { - if i > 0 || total_count > 0 { + if total_count > 0 || i > 0 { buffer_write_string(buf, ", "); } buffer_write_string(buf, name); @@ -237,13 +239,15 @@ buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) { variant_type := type_info_base(info.variant_types[i]); variant := union_cast(^Struct)variant_type; - for j in cf.names.count..<variant.names.count { + vc := variant.names.count-cf.names.count; + for j in 0..<vc { if j > 0 { - buffer_write_byte(buf, ','); + buffer_write_string(buf, ", "); } - buffer_write_string(buf, variant.names[j]); + index := j + cf.names.count; + buffer_write_string(buf, variant.names[index]); buffer_write_string(buf, ": "); - buffer_write_type(buf, variant.types[j]); + buffer_write_type(buf, variant.types[index]); } } buffer_write_string(buf, "}"); @@ -251,17 +255,21 @@ buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) { case Raw_Union: buffer_write_string(buf, "raw_union {"); for name, i in info.names { + if i > 0 { + buffer_write_string(buf, ", "); + } buffer_write_string(buf, name); buffer_write_string(buf, ": "); buffer_write_type(buf, info.types[i]); - buffer_write_byte(buf, ','); } buffer_write_string(buf, "}"); case Enum: buffer_write_string(buf, "enum "); buffer_write_type(buf, info.base); - buffer_write_string(buf, " {}"); + buffer_write_string(buf, " {"); + + buffer_write_string(buf, "}"); } } |