From 9517c65347ca38f77f4d1366ae97ad400e0bee67 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 25 Feb 2022 21:03:55 -0600 Subject: [PATCH] added get_struct_by_name --- core/type_info/helper.onyx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/type_info/helper.onyx b/core/type_info/helper.onyx index 43ea2993..70328dde 100644 --- a/core/type_info/helper.onyx +++ b/core/type_info/helper.onyx @@ -211,4 +211,16 @@ enum_values :: (E: type_expr) -> [] Type_Info_Enum.Member { if info.kind != .Enum do return .[]; return info.members; +} + +get_struct_by_name :: (name: str) -> type_expr { + index := 0; + for type_table { + defer index += 1; + if it.kind != .Struct do continue; + + if (cast(^Type_Info_Struct) it).name == name do return cast(type_expr) index; + } + + return void; } \ No newline at end of file -- 2.25.1