add enum_min, enum_max to [meta]

This commit is contained in:
Judah Caruso 2025-05-25 15:03:01 -06:00
parent c72c27fc81
commit 0632f97757

View file

@ -37,3 +37,37 @@ type_is_struct :: ($$T: Type) -> bool, *Type_Info_Struct {
ok, info := check_type_tag(T, .STRUCT);
return ok, info.(*Type_Info_Struct);
}
enum_max :: (T: Type) -> int #expand {
#assert T.(*Type_Info).type == .ENUM;
return #run -> int {
info := T.(*Type_Info_Enum);
if info.values.count == 0 {
return 0;
}
max := 0;
for info.values if it > max {
max = it;
}
return max;
};
}
enum_min :: (T: Type) -> int #expand {
#assert T.(*Type_Info).type == .ENUM;
return #run -> int {
info := T.(*Type_Info_Enum);
if info.values.count == 0 {
return 0;
}
min := 0xFFFFFF_FFFFFF;
for info.values if it < min {
min = it;
}
return min;
};
}