From 23f9f9064e99e559f57b35a5f84a9525f8023bd9 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Thu, 15 Jun 2017 12:14:56 +0100 Subject: Add CheckerInfo API functions --- src/types.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/types.cpp') diff --git a/src/types.cpp b/src/types.cpp index 51c77d383..4b1f276c0 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -95,6 +95,8 @@ struct TypeRecord { Entity * union__tag; i64 variant_block_size; // NOTE(bill): Internal use only + Type * variant_parent; + i32 variant_index; i64 * offsets; bool are_offsets_set; @@ -838,6 +840,14 @@ bool is_type_union(Type *t) { t = base_type(t); return (t->kind == Type_Record && t->Record.kind == TypeRecord_Union); } +bool is_type_variant(Type *t) { + t = base_type(t); + if (t->kind == Type_Record) { + return t->Record.kind == TypeRecord_Struct && t->Record.variant_parent != NULL; + } + return false; +} + bool is_type_raw_union(Type *t) { t = base_type(t); return (t->kind == Type_Record && t->Record.kind == TypeRecord_RawUnion); -- cgit v1.2.3