This commit is contained in:
agra
2026-02-14 21:27:51 +02:00
parent 0e777e9d2e
commit e7d2abdf0c
5 changed files with 338 additions and 78 deletions

View File

@@ -15,6 +15,7 @@ field_name :: ($T: Type, idx: s64) -> string #builtin;
field_value :: (s: $T, idx: s64) -> Any #builtin;
is_flags :: ($T: Type) -> bool #builtin;
field_value_int :: ($T: Type, idx: s64) -> s64 #builtin;
field_index :: ($T: Type, val: T) -> s64 #builtin;
string :: []u8 #builtin;
int_to_string :: (n: s64) -> string {
@@ -221,9 +222,9 @@ flags_to_string :: (val: $T) -> string {
enum_to_string :: (u: $T) -> string {
if is_flags(T) { return flags_to_string(u); }
tag := cast(s64) u;
result := concat(".", field_name(T, tag));
payload := field_value(u, tag);
idx := field_index(T, u);
result := concat(".", field_name(T, idx));
payload := field_value(u, idx);
pstr := any_to_string(payload);
if pstr.len > 0 {
result = concat(result, concat("(", concat(pstr, ")")));