Add intrinsics type_fixed_capacity_dynamic_array_len_offset and type_is_fixed_capacity_dynamic_array

This commit is contained in:
gingerBill
2026-03-12 17:39:44 +00:00
parent c7308d86d4
commit 8e23c58620
4 changed files with 37 additions and 1 deletions

View File

@@ -58,6 +58,7 @@ gb_global BuiltinTypeIsProc *builtin_type_is_procs[BuiltinProc__type_simple_bool
is_type_simd_vector,
is_type_matrix,
is_type_raw_union,
is_type_fixed_capacity_dynamic_array,
is_type_polymorphic_record_specialized,
is_type_polymorphic_record_unspecialized,
@@ -7628,6 +7629,31 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
}
break;
case BuiltinProc_type_fixed_capacity_dynamic_array_len_offset:
{
Operand op = {};
Type *bt = check_type(c, ce->args[0]);
Type *type = base_type(bt);
if (type == nullptr || type == t_invalid) {
error(ce->args[0], "Expected a fixed capacity dynamic array type for '%.*s'", LIT(builtin_name));
return false;
}
if (!is_type_fixed_capacity_dynamic_array(type)) {
error(ce->args[0], "Expected a fixed capacity dynamic array type for '%.*s'", LIT(builtin_name));
return false;
}
i64 sz = type_size_of(type);
gb_unused(sz);
i64 offset = type_offset_of(type, 1);
operand->mode = Addressing_Constant;
operand->value = exact_value_u64(cast(u64)offset);
operand->type = t_uintptr;
break;
}
break;
case BuiltinProc_type_bit_set_backing_type:
{
Operand op = {};