aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-18 20:58:36 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-18 20:58:36 -0400
commit6f3b2c073a968e57d787849dce42ff1253ed0102 (patch)
treee5fb20ae4322fdbbded412c2cb771b7e4ed68ecf /types.c
parent967b649da20f1cb2011025456853cb55f25e9a88 (diff)
Add `enum.tag` as a way to do a boolean test for whether a value has a
particular tag or not
Diffstat (limited to 'types.c')
-rw-r--r--types.c8
1 files changed, 8 insertions, 0 deletions
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;