add enum_min, enum_max to [meta]
This commit is contained in:
parent
c72c27fc81
commit
0632f97757
1 changed files with 34 additions and 0 deletions
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue