2013-10-11 04:36:51 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "picrin.h"
|
|
|
|
|
|
|
|
bool
|
|
|
|
pic_eq_p(pic_state *pic, pic_value x, pic_value y)
|
|
|
|
{
|
|
|
|
if (pic_type(x) != pic_type(y))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (pic_type(x)) {
|
|
|
|
case PIC_TT_NIL:
|
|
|
|
return true;
|
|
|
|
case PIC_TT_SYMBOL:
|
2013-10-28 13:11:31 -04:00
|
|
|
return pic_sym(x) == pic_sym(y);
|
2013-10-11 04:36:51 -04:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2013-10-30 11:29:55 -04:00
|
|
|
|
|
|
|
static pic_value
|
|
|
|
pic_bool_eq_p(pic_state *pic)
|
|
|
|
{
|
|
|
|
pic_value x, y;
|
|
|
|
|
|
|
|
pic_get_args(pic, "oo", &x, &y);
|
|
|
|
|
|
|
|
return pic_bool_value(pic_eq_p(pic, x, y));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pic_init_bool(pic_state *pic)
|
|
|
|
{
|
|
|
|
pic_defun(pic, "eq?", pic_bool_eq_p);
|
|
|
|
}
|