Change is_utf16 field to encoding and use an enum

This commit is contained in:
gingerBill
2025-08-05 15:12:54 +01:00
parent eae43f1225
commit af3184adc9
10 changed files with 33 additions and 13 deletions

View File

@@ -3101,6 +3101,9 @@ gb_internal void init_core_type_info(Checker *c) {
GB_ASSERT(tis->fields.count == 5);
Entity *type_info_string_encoding_kind = find_core_entity(c, str_lit("Type_Info_String_Encoding_Kind"));
t_type_info_string_encoding_kind = type_info_string_encoding_kind->type;
Entity *type_info_variant = tis->fields[4];
Type *tiv_type = type_info_variant->type;
GB_ASSERT(is_type_union(tiv_type));

View File

@@ -525,7 +525,15 @@ gb_internal void lb_setup_type_info_data_giant_array(lbModule *m, i64 global_typ
break;
case Basic_string:
tag_type = t_type_info_string;
{
tag_type = t_type_info_string;
LLVMValueRef vals[2] = {
lb_const_bool(m, t_bool, false).value,
lb_const_int(m, t_type_info_string_encoding_kind, 0).value,
};
variant_value = llvm_const_named_struct(m, tag_type, vals, gb_count_of(vals));
}
break;
case Basic_cstring:
@@ -533,7 +541,7 @@ gb_internal void lb_setup_type_info_data_giant_array(lbModule *m, i64 global_typ
tag_type = t_type_info_string;
LLVMValueRef vals[2] = {
lb_const_bool(m, t_bool, true).value,
lb_const_bool(m, t_bool, false).value,
lb_const_int(m, t_type_info_string_encoding_kind, 0).value,
};
variant_value = llvm_const_named_struct(m, tag_type, vals, gb_count_of(vals));
@@ -545,7 +553,7 @@ gb_internal void lb_setup_type_info_data_giant_array(lbModule *m, i64 global_typ
tag_type = t_type_info_string;
LLVMValueRef vals[2] = {
lb_const_bool(m, t_bool, false).value,
lb_const_bool(m, t_bool, true).value,
lb_const_int(m, t_type_info_string_encoding_kind, 1).value,
};
variant_value = llvm_const_named_struct(m, tag_type, vals, gb_count_of(vals));
@@ -558,7 +566,7 @@ gb_internal void lb_setup_type_info_data_giant_array(lbModule *m, i64 global_typ
tag_type = t_type_info_string;
LLVMValueRef vals[2] = {
lb_const_bool(m, t_bool, true).value,
lb_const_bool(m, t_bool, true).value,
lb_const_int(m, t_type_info_string_encoding_kind, 1).value,
};
variant_value = llvm_const_named_struct(m, tag_type, vals, gb_count_of(vals));

View File

@@ -661,6 +661,8 @@ gb_global Type *t_type_info_enum_value = nullptr;
gb_global Type *t_type_info_ptr = nullptr;
gb_global Type *t_type_info_enum_value_ptr = nullptr;
gb_global Type *t_type_info_string_encoding_kind = nullptr;
gb_global Type *t_type_info_named = nullptr;
gb_global Type *t_type_info_integer = nullptr;
gb_global Type *t_type_info_rune = nullptr;