Add boolean, comparison, and equality functions

This commit is contained in:
2022-11-07 09:18:59 -05:00
parent 4da62ad2da
commit 6af4e67309
7 changed files with 133 additions and 9 deletions

View File

@@ -105,3 +105,25 @@ struct ucl_object *ucl_special_progn(struct ucl_state *state, struct ucl_object
struct ucl_object *ucl_special_quote(struct ucl_state *state, struct ucl_object *args) {
return ucl_car(args);
}
struct ucl_object *ucl_special_and(struct ucl_state *state, struct ucl_object *args) {
struct ucl_object *value = ucl_t_create();
FOREACH_LIST(args, iter, form) {
value = ucl_evaluate(state, form);
if (!ucl_truthy_bool(value)) {
return value;
}
}
return value;
}
struct ucl_object *ucl_special_or(struct ucl_state *state, struct ucl_object *args) {
struct ucl_object *value = ucl_nil_create();
FOREACH_LIST(args, iter, form) {
value = ucl_evaluate(state, form);
if (ucl_truthy_bool(value)) {
return value;
}
}
return value;
}