diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-28 21:47:56 +0100 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-28 21:47:56 +0100 |
| commit | 8be18d9a401f898320b57379488bad1367632628 (patch) | |
| tree | fef9a5b31bf48a673206e769778c96deffcd45b2 /src/types.cpp | |
| parent | 35a32d41e03ad10134d7705e4e502c1a23f39d47 (diff) | |
Allow for constant `[]typeid`
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/types.cpp b/src/types.cpp index 46e41bb4b..814f99eff 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1377,14 +1377,20 @@ gb_internal bool is_type_ordered_numeric(Type *t) { gb_internal bool is_type_constant_type(Type *t) { t = core_type(t); if (t == nullptr) { return false; } - if (t->kind == Type_Basic) { + switch (t->kind) { + case Type_Basic: + if (t->Basic.kind == Basic_typeid) { + return true; + } return (t->Basic.flags & BasicFlag_ConstantType) != 0; - } - if (t->kind == Type_BitSet) { + case Type_BitSet: return true; - } - if (t->kind == Type_Proc) { + case Type_Proc: return true; + case Type_Array: + return is_type_constant_type(t->Array.elem); + case Type_EnumeratedArray: + return is_type_constant_type(t->EnumeratedArray.elem); } return false; } @@ -2539,6 +2545,20 @@ gb_internal bool elem_type_can_be_constant(Type *t) { return true; } +gb_internal bool elem_cannot_be_constant(Type *t) { + if (is_type_any(t)) { + return true; + } + if (is_type_union(t)) { + return !is_type_union_constantable(t); + } + if (is_type_raw_union(t)) { + return true; + } + return false; +} + + gb_internal bool is_type_lock_free(Type *t) { t = core_type(t); if (t == t_invalid) { |