diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:01:17 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:01:17 -0400 |
| commit | dee3742b48e27ef36637d004163286d3352b0763 (patch) | |
| tree | 881a9a25b4cfeb6ff632a3fa48ccd3abd7f642ae /builtins | |
| parent | bba9f1b141fba5ffc366ef9377fb3089c0c5a1a3 (diff) | |
Optional structs
Diffstat (limited to 'builtins')
| -rw-r--r-- | builtins/optionals.c | 6 |
1 files changed, 6 insertions, 0 deletions
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); |
