diff options
| author | gingerBill <bill@gingerbill.org> | 2024-07-15 14:49:20 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-07-15 14:49:20 +0100 |
| commit | 1e37eaf54daf885636ea3ad9606a2b54e01721f9 (patch) | |
| tree | 207c49870eb711412d08394d5ee4b169797f5d73 /src/types.cpp | |
| parent | 5cefab8229514c308c4676bbd86db7a8b3d2c5f5 (diff) | |
Begin work for `bit_set[...; [N]T]` (not working)
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp index fdc174d81..3f86d4c50 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -2011,6 +2011,24 @@ gb_internal bool is_type_valid_bit_set_elem(Type *t) { return false; } + +gb_internal bool is_valid_bit_field_backing_type(Type *type) { + if (type == nullptr) { + return false; + } + type = base_type(type); + if (is_type_untyped(type)) { + return false; + } + if (is_type_integer(type)) { + return true; + } + if (type->kind == Type_Array) { + return is_type_integer(type->Array.elem); + } + return false; +} + gb_internal Type *bit_set_to_int(Type *t) { GB_ASSERT(is_type_bit_set(t)); Type *bt = base_type(t); @@ -2018,6 +2036,9 @@ gb_internal Type *bit_set_to_int(Type *t) { if (underlying != nullptr && is_type_integer(underlying)) { return underlying; } + if (underlying != nullptr && is_valid_bit_field_backing_type(underlying)) { + return underlying; + } i64 sz = type_size_of(t); switch (sz) { |