mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Add intrinsics.type_canonical_name
This commit is contained in:
@@ -233,6 +233,9 @@ type_integer_to_signed :: proc($T: typeid) -> type where type_is_integer(T), t
|
|||||||
|
|
||||||
type_has_shared_fields :: proc($U, $V: typeid) -> bool where type_is_struct(U), type_is_struct(V) ---
|
type_has_shared_fields :: proc($U, $V: typeid) -> bool where type_is_struct(U), type_is_struct(V) ---
|
||||||
|
|
||||||
|
// Returns the canonicalized name of the type, of which is used to produce the pseudo-unique 'typeid'
|
||||||
|
type_canonical_name :: proc($T: typeid) -> string ---
|
||||||
|
|
||||||
constant_utf16_cstring :: proc($literal: string) -> [^]u16 ---
|
constant_utf16_cstring :: proc($literal: string) -> [^]u16 ---
|
||||||
|
|
||||||
constant_log2 :: proc($v: $T) -> T where type_is_integer(T) ---
|
constant_log2 :: proc($v: $T) -> T where type_is_integer(T) ---
|
||||||
|
|||||||
@@ -7134,6 +7134,22 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case BuiltinProc_type_canonical_name:
|
||||||
|
{
|
||||||
|
Operand op = {};
|
||||||
|
Type *type = check_type(c, ce->args[0]);
|
||||||
|
Type *bt = base_type(type);
|
||||||
|
if (bt == nullptr || bt == t_invalid) {
|
||||||
|
error(ce->args[0], "Expected a type for '%.*s'", LIT(builtin_name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
operand->mode = Addressing_Constant;
|
||||||
|
operand->type = t_untyped_string;
|
||||||
|
operand->value = type_to_canonical_string(permanent_allocator(), type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case BuiltinProc_procedure_of:
|
case BuiltinProc_procedure_of:
|
||||||
{
|
{
|
||||||
Ast *call_expr = unparen_expr(ce->args[0]);
|
Ast *call_expr = unparen_expr(ce->args[0]);
|
||||||
|
|||||||
@@ -339,6 +339,8 @@ BuiltinProc__type_simple_boolean_end,
|
|||||||
|
|
||||||
BuiltinProc_type_has_shared_fields,
|
BuiltinProc_type_has_shared_fields,
|
||||||
|
|
||||||
|
BuiltinProc_type_canonical_name,
|
||||||
|
|
||||||
BuiltinProc__type_end,
|
BuiltinProc__type_end,
|
||||||
|
|
||||||
BuiltinProc_procedure_of,
|
BuiltinProc_procedure_of,
|
||||||
@@ -697,6 +699,7 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_COUNT] = {
|
|||||||
{STR_LIT("type_map_cell_info"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
{STR_LIT("type_map_cell_info"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||||
|
|
||||||
{STR_LIT("type_has_shared_fields"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
{STR_LIT("type_has_shared_fields"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||||
|
{STR_LIT("type_canonical_name"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics},
|
||||||
|
|
||||||
{STR_LIT(""), 0, false, Expr_Stmt, BuiltinProcPkg_intrinsics},
|
{STR_LIT(""), 0, false, Expr_Stmt, BuiltinProcPkg_intrinsics},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user