add boolean functions
This commit is contained in:
parent
404ccb7fb1
commit
808fe32ac0
24
src/bool.c
24
src/bool.c
|
@ -28,8 +28,32 @@ pic_bool_eq_p(pic_state *pic)
|
||||||
return pic_bool_value(pic_eq_p(pic, x, y));
|
return pic_bool_value(pic_eq_p(pic, x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: replace it with native opcode */
|
||||||
|
static pic_value
|
||||||
|
pic_bool_not(pic_state *pic)
|
||||||
|
{
|
||||||
|
pic_value v;
|
||||||
|
|
||||||
|
pic_get_args(pic, "o", &v);
|
||||||
|
|
||||||
|
return pic_false_p(v) ? pic_true_value() : pic_false_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
static pic_value
|
||||||
|
pic_bool_boolean_p(pic_state *pic)
|
||||||
|
{
|
||||||
|
pic_value v;
|
||||||
|
|
||||||
|
pic_get_args(pic, "o", &v);
|
||||||
|
|
||||||
|
return (pic_true_p(v) || pic_false_p(v)) ? pic_true_value() : pic_false_value();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_init_bool(pic_state *pic)
|
pic_init_bool(pic_state *pic)
|
||||||
{
|
{
|
||||||
pic_defun(pic, "eq?", pic_bool_eq_p);
|
pic_defun(pic, "eq?", pic_bool_eq_p);
|
||||||
|
|
||||||
|
pic_defun(pic, "not", pic_bool_not);
|
||||||
|
pic_defun(pic, "boolean?", pic_bool_boolean_p);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue