Refactoring

This commit is contained in:
Justin Ethier 2016-04-20 03:57:30 -04:00
parent 56c9a3340f
commit b734d1aef2
2 changed files with 25 additions and 14 deletions

View file

@ -201,9 +201,8 @@ typedef enum { STAGE_CLEAR_OR_MARKING
#define stack_overflow(x,y) ((x) > (y))
#endif
#define eq(x,y) (x == y)
#define type_of(x) (((list) x)->tag)
#define forward(x) (((list) x)->cons_car)
#define type_of(obj) (((pair_type *) obj)->tag)
#define forward(obj) (((pair_type *) obj)->cons_car)
/** Define value types.
* Depending on the underlying architecture, compiler, etc these types
@ -326,11 +325,13 @@ typedef bytevector_type *bytevector;
/* Pair (cons) type */
typedef struct {gc_header_type hdr; tag_type tag; object cons_car,cons_cdr;} cons_type;
typedef struct {gc_header_type hdr; tag_type tag; object cons_car; object cons_cdr;} cons_type;
typedef cons_type *list;
typedef cons_type pair_type;
typedef pair_type *pair;
#define car(x) (((list) x)->cons_car)
#define cdr(x) (((list) x)->cons_cdr)
#define car(x) (((pair_type *) x)->cons_car)
#define cdr(x) (((pair_type *) x)->cons_cdr)
#define caar(x) (car(car(x)))
#define cadr(x) (car(cdr(x)))
#define cdar(x) (cdr(car(x)))

View file

@ -733,14 +733,24 @@ object Cyc_write_char(void *data, object c, object port)
// TODO: should not be a predicate, may end up moving these to Scheme code
object memberp(void *data, object x, list l)
{Cyc_check_cons_or_null(data, l);
for (; l != NULL; l = cdr(l)) if (boolean_f != equalp(x,car(l))) return boolean_t;
return boolean_f;}
{
Cyc_check_cons_or_null(data, l);
for (; l != NULL; l = cdr(l)) {
if (boolean_f != equalp(x,car(l)))
return boolean_t;
}
return boolean_f;
}
object memqp(void *data, object x, list l)
{Cyc_check_cons_or_null(data, l);
for (; l != NULL; l = cdr(l)) if ((x == car(l))) return boolean_t;
return boolean_f;}
{
Cyc_check_cons_or_null(data, l);
for (; l != NULL; l = cdr(l)){
if ((x == car(l)))
return boolean_t;
}
return boolean_f;
}
object equalp(object x, object y)
{