mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-24 22:54:59 -07:00
Add intrinsics type_bit_set_elem_type & type_bit_set_underlying_type
This commit is contained in:
@@ -5433,6 +5433,58 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
||||
operand->value = exact_value_i64(u->Union.kind == UnionType_no_nil ? 0 : 1);
|
||||
} break;
|
||||
|
||||
case BuiltinProc_type_bit_set_elem_type:
|
||||
{
|
||||
|
||||
if (operand->mode != Addressing_Type) {
|
||||
error(operand->expr, "Expected a type for '%.*s'", LIT(builtin_name));
|
||||
operand->mode = Addressing_Invalid;
|
||||
operand->type = t_invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
Type *bs = operand->type;
|
||||
|
||||
if (!is_type_bit_set(bs)) {
|
||||
error(operand->expr, "Expected a bit_set type for '%.*s'", LIT(builtin_name));
|
||||
operand->mode = Addressing_Invalid;
|
||||
operand->type = t_invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
bs = base_type(bs);
|
||||
GB_ASSERT(bs->kind == Type_BitSet);
|
||||
|
||||
operand->mode = Addressing_Type;
|
||||
operand->type = bs->BitSet.elem;
|
||||
} break;
|
||||
|
||||
case BuiltinProc_type_bit_set_underlying_type:
|
||||
{
|
||||
|
||||
if (operand->mode != Addressing_Type) {
|
||||
error(operand->expr, "Expected a type for '%.*s'", LIT(builtin_name));
|
||||
operand->mode = Addressing_Invalid;
|
||||
operand->type = t_invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
Type *bs = operand->type;
|
||||
|
||||
if (!is_type_bit_set(bs)) {
|
||||
error(operand->expr, "Expected a bit_set type for '%.*s'", LIT(builtin_name));
|
||||
operand->mode = Addressing_Invalid;
|
||||
operand->type = t_invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
bs = base_type(bs);
|
||||
GB_ASSERT(bs->kind == Type_BitSet);
|
||||
|
||||
operand->mode = Addressing_Type;
|
||||
operand->type = bit_set_to_int(bs);
|
||||
} break;
|
||||
|
||||
case BuiltinProc_type_union_variant_count:
|
||||
{
|
||||
if (operand->mode != Addressing_Type) {
|
||||
|
||||
Reference in New Issue
Block a user