mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-08 03:24:19 +00:00
Begin work for bit_set[...; [N]T] (not working)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user