mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Add hidden __tag for union variables.
This commit is contained in:
+11
@@ -92,6 +92,8 @@ typedef struct TypeRecord {
|
||||
// Entity_TypeName - union
|
||||
Entity **variants;
|
||||
i32 variant_count;
|
||||
Entity * union__tag;
|
||||
|
||||
|
||||
i64 * offsets;
|
||||
bool are_offsets_set;
|
||||
@@ -1415,6 +1417,15 @@ Selection lookup_field_with_selection(gbAllocator a, Type *type_, String field_n
|
||||
sel.index.count = prev_count;
|
||||
}
|
||||
}
|
||||
if (type->Record.kind == TypeRecord_Union) {
|
||||
if (str_eq(field_name, str_lit("__tag"))) {
|
||||
Entity *e = type->Record.union__tag;
|
||||
GB_ASSERT(e != NULL);
|
||||
selection_add_index(&sel, -1); // HACK(bill): Leaky memory
|
||||
sel.entity = e;
|
||||
return sel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sel;
|
||||
|
||||
Reference in New Issue
Block a user