mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Add intrinsics type_bit_set_elem_type & type_bit_set_underlying_type
This commit is contained in:
@@ -169,15 +169,18 @@ type_has_nil :: proc($T: typeid) -> bool ---
|
|||||||
|
|
||||||
type_is_specialization_of :: proc($T, $S: typeid) -> bool ---
|
type_is_specialization_of :: proc($T, $S: typeid) -> bool ---
|
||||||
|
|
||||||
type_is_variant_of :: proc($U, $V: typeid) -> bool where type_is_union(U) ---
|
type_is_variant_of :: proc($U, $V: typeid) -> bool where type_is_union(U) ---
|
||||||
type_union_tag_type :: proc($T: typeid) -> typeid where type_is_union(T) ---
|
type_union_tag_type :: proc($T: typeid) -> typeid where type_is_union(T) ---
|
||||||
type_union_tag_offset :: proc($T: typeid) -> uintptr where type_is_union(T) ---
|
type_union_tag_offset :: proc($T: typeid) -> uintptr where type_is_union(T) ---
|
||||||
type_union_base_tag_value :: proc($T: typeid) -> int where type_is_union(U) ---
|
type_union_base_tag_value :: proc($T: typeid) -> int where type_is_union(U) ---
|
||||||
type_union_variant_count :: proc($T: typeid) -> int where type_is_union(T) ---
|
type_union_variant_count :: proc($T: typeid) -> int where type_is_union(T) ---
|
||||||
type_variant_type_of :: proc($T: typeid, $index: int) -> typeid where type_is_union(T) ---
|
type_variant_type_of :: proc($T: typeid, $index: int) -> typeid where type_is_union(T) ---
|
||||||
type_variant_index_of :: proc($U, $V: typeid) -> int where type_is_union(U) ---
|
type_variant_index_of :: proc($U, $V: typeid) -> int where type_is_union(U) ---
|
||||||
|
|
||||||
type_has_field :: proc($T: typeid, $name: string) -> bool ---
|
type_bit_set_elem_type :: proc($T: typeid) -> typeid where type_is_bit_set(T) ---
|
||||||
|
type_bit_set_underlying_type :: proc($T: typeid) -> typeid where type_is_bit_set(T) ---
|
||||||
|
|
||||||
|
type_has_field :: proc($T: typeid, $name: string) -> bool ---
|
||||||
type_field_type :: proc($T: typeid, $name: string) -> typeid ---
|
type_field_type :: proc($T: typeid, $name: string) -> typeid ---
|
||||||
|
|
||||||
type_proc_parameter_count :: proc($T: typeid) -> int where type_is_proc(T) ---
|
type_proc_parameter_count :: proc($T: typeid) -> int where type_is_proc(T) ---
|
||||||
|
|||||||
@@ -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);
|
operand->value = exact_value_i64(u->Union.kind == UnionType_no_nil ? 0 : 1);
|
||||||
} break;
|
} 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:
|
case BuiltinProc_type_union_variant_count:
|
||||||
{
|
{
|
||||||
if (operand->mode != Addressing_Type) {
|
if (operand->mode != Addressing_Type) {
|
||||||
|
|||||||
@@ -269,6 +269,9 @@ BuiltinProc__type_simple_boolean_end,
|
|||||||
BuiltinProc_type_variant_type_of,
|
BuiltinProc_type_variant_type_of,
|
||||||
BuiltinProc_type_variant_index_of,
|
BuiltinProc_type_variant_index_of,
|
||||||
|
|
||||||
|
BuiltinProc_type_bit_set_elem_type,
|
||||||
|
BuiltinProc_type_bit_set_underlying_type,
|
||||||
|
|
||||||
BuiltinProc_type_struct_field_count,
|
BuiltinProc_type_struct_field_count,
|
||||||
|
|
||||||
BuiltinProc_type_proc_parameter_count,
|
BuiltinProc_type_proc_parameter_count,
|
||||||
@@ -577,6 +580,9 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_COUNT] = {
|
|||||||
{STR_LIT("type_variant_type_of"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
{STR_LIT("type_variant_type_of"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||||
{STR_LIT("type_variant_index_of"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
{STR_LIT("type_variant_index_of"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||||
|
|
||||||
|
{STR_LIT("type_bit_set_elem_type"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||||
|
{STR_LIT("type_bit_set_underlying_type"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||||
|
|
||||||
{STR_LIT("type_struct_field_count"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
{STR_LIT("type_struct_field_count"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||||
|
|
||||||
{STR_LIT("type_proc_parameter_count"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
{STR_LIT("type_proc_parameter_count"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||||
|
|||||||
Reference in New Issue
Block a user