From 2a0fe5152f687af19a03e917ec4316990769a6ab Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 5 Jun 2023 22:18:28 -0500 Subject: [PATCH] added: type info methods --- core/runtime/info/types.onyx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/runtime/info/types.onyx b/core/runtime/info/types.onyx index 56ea5a5a..4d2afdcf 100644 --- a/core/runtime/info/types.onyx +++ b/core/runtime/info/types.onyx @@ -231,3 +231,27 @@ get_type_info :: (t: type_expr) -> &Type_Info { } + +#inject type_expr { + info :: get_type_info +} + +#inject Type_Info { + as_basic :: (t: &Type_Info) => cast(&Type_Info_Basic, t); + as_pointer :: (t: &Type_Info) => cast(&Type_Info_Pointer, t); + as_multi_pointer :: (t: &Type_Info) => cast(&Type_Info_Multi_Pointer, t); + as_function :: (t: &Type_Info) => cast(&Type_Info_Function, t); + as_array :: (t: &Type_Info) => cast(&Type_Info_Array, t); + as_slice :: (t: &Type_Info) => cast(&Type_Info_Slice, t); + as_dynamic_array :: (t: &Type_Info) => cast(&Type_Info_Dynamic_Array, t); + as_variadic_argument :: (t: &Type_Info) => cast(&Type_Info_Variadic_Argument, t); + as_enum :: (t: &Type_Info) => cast(&Type_Info_Enum, t); + as_struct :: (t: &Type_Info) => cast(&Type_Info_Struct, t); + as_poly_struct :: (t: &Type_Info) => cast(&Type_Info_Polymorphic_Struct, t); + as_union :: (t: &Type_Info) => cast(&Type_Info_Union, t); + as_poly_union :: (t: &Type_Info) => cast(&Type_Info_Polymorphic_Union, t); + as_distinct :: (t: &Type_Info) => cast(&Type_Info_Distinct, t); + as_compound :: (t: &Type_Info) => cast(&Type_Info_Compound, t); +} + + -- 2.25.1