aboutsummaryrefslogtreecommitdiff
path: root/builtins/bool.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-04 21:13:50 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-04 21:13:50 -0500
commitadde91636f04ae7544dba1ca5c6c1a40c074edb9 (patch)
treedfeb8c0c16fda6a87ef30b048b070ee4cb175a78 /builtins/bool.c
parentb08a0d3e2bf45bae11c982dd24d0292d6436b993 (diff)
Builtins
Diffstat (limited to 'builtins/bool.c')
-rw-r--r--builtins/bool.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/builtins/bool.c b/builtins/bool.c
new file mode 100644
index 00000000..7614113f
--- /dev/null
+++ b/builtins/bool.c
@@ -0,0 +1,39 @@
+
+#include <gc.h>
+#include <gc/cord.h>
+#include <stdalign.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/param.h>
+#include <err.h>
+
+#include "types.h"
+#include "../util.h"
+#include "../SipHash/halfsiphash.h"
+
+extern const void *SSS_HASH_VECTOR;
+
+static CORD Bool_cord(const bool *b, bool colorize, const TypeInfo *type)
+{
+ (void)type;
+ if (colorize)
+ return *b ? "\x1b[35myes\x1b[m" : "\x1b[35mno\x1b[m";
+ else
+ return *b ? "yes" : "no";
+}
+
+public struct {
+ TypeInfo type;
+} Bool_type = {
+ .type={
+ .name="Bool",
+ .size=sizeof(bool),
+ .align=alignof(bool),
+ .tag=CustomInfo,
+ .CustomInfo={.cord=(void*)Bool_cord},
+ },
+};
+
+// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0