Change union layout to store type info rather than an integer; ternary expression for types with constant condition

This commit is contained in:
Ginger Bill
2017-07-19 12:15:21 +01:00
parent 4db462a703
commit 6113164211
9 changed files with 222 additions and 85 deletions
+9 -1
View File
@@ -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)");