mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Change union layout to store type info rather than an integer; ternary expression for types with constant condition
This commit is contained in:
+9
-1
@@ -866,7 +866,15 @@ fmt_value :: proc(fi: ^FmtInfo, v: any, verb: rune) {
|
||||
}
|
||||
|
||||
case Union:
|
||||
write_string(fi.buf, "(union)");
|
||||
data := cast(^u8)v.data;
|
||||
tipp := cast(^^TypeInfo)(data + info.tag_offset);
|
||||
if data == nil || tipp == nil {
|
||||
write_string(fi.buf, "(union)");
|
||||
} else {
|
||||
ti := tipp^;
|
||||
fmt_arg(fi, any{data, ti}, verb);
|
||||
}
|
||||
|
||||
|
||||
case RawUnion:
|
||||
write_string(fi.buf, "(raw_union)");
|
||||
|
||||
Reference in New Issue
Block a user