diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-05-04 20:34:50 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-05-04 20:34:50 +0100 |
| commit | 789b297f324206a18128f61679bfd36b9c6265b2 (patch) | |
| tree | d4a80640a62b6202c8075d4768502b7c91d8fadb /src/types.c | |
| parent | 3b25f924cbb56882e77daccf229258509022d3be (diff) | |
Add hidden __tag for union variables.
Diffstat (limited to 'src/types.c')
| -rw-r--r-- | src/types.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/types.c b/src/types.c index 82012258e..4001253f8 100644 --- a/src/types.c +++ b/src/types.c @@ -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; |