aboutsummaryrefslogtreecommitdiff
path: root/builtins
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-11 14:18:01 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-11 14:18:01 -0400
commit0b5bb32912cfc68c7783548006fca2dc5874eb93 (patch)
treedb5f28d83039ed6f78030f11d347c1c0d7b39664 /builtins
parent273e2f995f1d74e9ef8e9a2e09a3ea2c2b16d839 (diff)
Fix optional bools
Diffstat (limited to 'builtins')
-rw-r--r--builtins/optionals.c4
-rw-r--r--builtins/optionals.h6
2 files changed, 4 insertions, 6 deletions
diff --git a/builtins/optionals.c b/builtins/optionals.c
index 687486db..8a1aaf99 100644
--- a/builtins/optionals.c
+++ b/builtins/optionals.c
@@ -8,7 +8,7 @@
#include "util.h"
public const Array_t NULL_ARRAY = {.length=-1};
-public const Bool_t NULL_BOOL = -1;
+public const OptionalBool_t NULL_BOOL = 2;
public const Int_t NULL_INT = {.small=0};
public const Table_t NULL_TABLE = {.entries.length=-1};
public const Closure_t NULL_CLOSURE = {.fn=NULL};
@@ -19,7 +19,7 @@ static inline bool is_null(const void *obj, const TypeInfo *non_optional_type)
if (non_optional_type == &Int$info)
return ((Int_t*)obj)->small == 0;
else if (non_optional_type == &Bool$info)
- return *((Bool_t*)obj) == NULL_BOOL;
+ return *((OptionalBool_t*)obj) == NULL_BOOL;
else if (non_optional_type == &Num$info)
return isnan(*((Num_t*)obj));
else if (non_optional_type == &Int64$info)
diff --git a/builtins/optionals.h b/builtins/optionals.h
index a6ff5c72..10599473 100644
--- a/builtins/optionals.h
+++ b/builtins/optionals.h
@@ -9,11 +9,9 @@
#include "types.h"
#include "util.h"
-#define Bool_t bool
-#define yes (Bool_t)true
-#define no (Bool_t)false
+#define OptionalBool_t uint8_t
-extern const Bool_t NULL_BOOL;
+extern const OptionalBool_t NULL_BOOL;
extern const Table_t NULL_TABLE;
extern const Array_t NULL_ARRAY;
extern const Int_t NULL_INT;