From: Brendan Hansen Date: Tue, 6 Jun 2023 03:18:28 +0000 (-0500) Subject: added: type info methods X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=2a0fe5152f687af19a03e917ec4316990769a6ab;p=onyx.git added: type info methods --- 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); +} + +