From dee3742b48e27ef36637d004163286d3352b0763 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 11 Sep 2024 12:01:17 -0400 Subject: Optional structs --- builtins/optionals.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'builtins') diff --git a/builtins/optionals.c b/builtins/optionals.c index 27ab8ec6..f58c8134 100644 --- a/builtins/optionals.c +++ b/builtins/optionals.c @@ -36,6 +36,12 @@ static inline bool is_null(const void *obj, const TypeInfo *non_optional_type) case ArrayInfo: return ((Array_t*)obj)->length < 0; case TableInfo: return ((Table_t*)obj)->entries.length < 0; case FunctionInfo: return *(void**)obj == NULL; + case CustomInfo: { + int64_t offset = non_optional_type->size; + if (offset % non_optional_type->align) + offset += non_optional_type->align - (offset % non_optional_type->align); + return *(bool*)(obj + offset); + } default: { Text_t t = generic_as_text(NULL, false, non_optional_type); errx(1, "is_null() not implemented for: %k", &t); -- cgit v1.2.3