mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 22:17:33 +02:00
Refactoring
This commit is contained in:
parent
56c9a3340f
commit
b734d1aef2
2 changed files with 25 additions and 14 deletions
|
@ -201,9 +201,8 @@ typedef enum { STAGE_CLEAR_OR_MARKING
|
||||||
#define stack_overflow(x,y) ((x) > (y))
|
#define stack_overflow(x,y) ((x) > (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define eq(x,y) (x == y)
|
#define type_of(obj) (((pair_type *) obj)->tag)
|
||||||
#define type_of(x) (((list) x)->tag)
|
#define forward(obj) (((pair_type *) obj)->cons_car)
|
||||||
#define forward(x) (((list) x)->cons_car)
|
|
||||||
|
|
||||||
/** Define value types.
|
/** Define value types.
|
||||||
* Depending on the underlying architecture, compiler, etc these types
|
* Depending on the underlying architecture, compiler, etc these types
|
||||||
|
@ -326,11 +325,13 @@ typedef bytevector_type *bytevector;
|
||||||
|
|
||||||
/* Pair (cons) type */
|
/* 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 *list;
|
||||||
|
typedef cons_type pair_type;
|
||||||
|
typedef pair_type *pair;
|
||||||
|
|
||||||
#define car(x) (((list) x)->cons_car)
|
#define car(x) (((pair_type *) x)->cons_car)
|
||||||
#define cdr(x) (((list) x)->cons_cdr)
|
#define cdr(x) (((pair_type *) x)->cons_cdr)
|
||||||
#define caar(x) (car(car(x)))
|
#define caar(x) (car(car(x)))
|
||||||
#define cadr(x) (car(cdr(x)))
|
#define cadr(x) (car(cdr(x)))
|
||||||
#define cdar(x) (cdr(car(x)))
|
#define cdar(x) (cdr(car(x)))
|
||||||
|
|
22
runtime.c
22
runtime.c
|
@ -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
|
// TODO: should not be a predicate, may end up moving these to Scheme code
|
||||||
object memberp(void *data, object x, list l)
|
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;
|
Cyc_check_cons_or_null(data, l);
|
||||||
return boolean_f;}
|
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)
|
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;
|
Cyc_check_cons_or_null(data, l);
|
||||||
return boolean_f;}
|
for (; l != NULL; l = cdr(l)){
|
||||||
|
if ((x == car(l)))
|
||||||
|
return boolean_t;
|
||||||
|
}
|
||||||
|
return boolean_f;
|
||||||
|
}
|
||||||
|
|
||||||
object equalp(object x, object y)
|
object equalp(object x, object y)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue