From 6f3b2c073a968e57d787849dce42ff1253ed0102 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 18 Aug 2024 20:58:36 -0400 Subject: Add `enum.tag` as a way to do a boolean test for whether a value has a particular tag or not --- types.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'types.c') diff --git a/types.c b/types.c index cd388304..8cb534d7 100644 --- a/types.c +++ b/types.c @@ -594,6 +594,14 @@ type_t *get_field_type(type_t *t, const char *field_name) } return NULL; } + case EnumType: { + auto e = Match(t, EnumType); + for (tag_t *tag = e->tags; tag; tag = tag->next) { + if (streq(field_name, tag->name)) + return Type(BoolType); + } + return NULL; + } case SetType: { if (streq(field_name, "length")) return INT_TYPE; -- cgit v1.2.3