Refactoring

This commit is contained in:
Justin Ethier 2016-04-20 23:00:04 -04:00
parent 63a2204efc
commit 40416364f8
5 changed files with 14 additions and 14 deletions

2
gc.c
View file

@ -514,7 +514,7 @@ size_t gc_allocated_bytes(object obj, gc_free_list *q, gc_free_list *r)
}
#endif
t = type_of(obj);
if (t == pair_tag) return gc_heap_align(sizeof(cons_type));
if (t == pair_tag) return gc_heap_align(sizeof(pair_type));
if (t == macro_tag) return gc_heap_align(sizeof(macro_type));
if (t == closure0_tag) return gc_heap_align(sizeof(closure0_type));
if (t == closure1_tag) return gc_heap_align(sizeof(closure1_type));

View file

@ -62,7 +62,7 @@ object Cyc_global_set(void *thd, object *glo, object value);
args and the number of provided ones, and pass the difference as 'count'
*/
#define load_varargs(var, arg_var, count) \
list var = (count > 0) ? alloca(sizeof(cons_type)*count) : NULL; \
list var = (count > 0) ? alloca(sizeof(pair_type)*count) : NULL; \
{ \
int i; \
object tmp; \

View file

@ -423,20 +423,20 @@ typedef struct {
tag_type tag;
object cons_car;
object cons_cdr;
} cons_type;
typedef cons_type *list;
typedef cons_type pair_type;
} pair_type;
typedef pair_type *list;
typedef pair_type cons_type;
typedef pair_type *pair;
#define make_pair(n,a,d) \
cons_type n; \
pair_type n; \
n.hdr.mark = gc_color_red; \
n.hdr.grayed = 0; \
n.tag = pair_tag; \
n.cons_car = a; \
n.cons_cdr = d;
#define make_cons(n,a,d) \
cons_type n; \
pair_type n; \
n.hdr.mark = gc_color_red; \
n.hdr.grayed = 0; \
n.tag = pair_tag; \
@ -536,7 +536,7 @@ static const object primitive_##name = &name##_primitive
/* All constant-size objects */
typedef union {
boolean_type boolean_t;
cons_type cons_t;
pair_type cons_t;
symbol_type symbol_t;
primitive_type primitive_t;
integer_type integer_t;

View file

@ -1416,7 +1416,7 @@ object Cyc_command_line_arguments(void *data, object cont) {
object lis = NULL;
for (i = _cyc_argc; i > 1; i--) { // skip program name
object ps = alloca(sizeof(string_type));
object pl = alloca(sizeof(cons_type));
object pl = alloca(sizeof(pair_type));
make_string(s, _cyc_argv[i - 1]);
memcpy(ps, &s, sizeof(string_type));
((list)pl)->hdr.mark = gc_color_red;
@ -2077,7 +2077,7 @@ object Cyc_io_peek_char(void *data, object cont, object port) {
// Functions internal to the runtime that use malloc
list mcons(object a, object d)
{
cons_type *c = malloc(sizeof(cons_type));
pair_type *c = malloc(sizeof(pair_type));
c->hdr.mark = gc_color_red;
c->hdr.grayed = 0;
c->tag = pair_tag;
@ -2643,7 +2643,7 @@ void Cyc_apply(void *data, int argc, closure cont, object prim, ...){
va_list ap;
object tmp;
int i;
list args = alloca(sizeof(cons_type) * argc);
list args = alloca(sizeof(pair_type) * argc);
va_start(ap, prim);
@ -2678,7 +2678,7 @@ void Cyc_apply_from_buf(void *data, int argc, object prim, object *buf) {
exit(1);
}
args = alloca(sizeof(cons_type) * (argc - 1));
args = alloca(sizeof(pair_type) * (argc - 1));
cont = buf[0];
for (i = 1; i < argc; i++) {
@ -2768,7 +2768,7 @@ char *gc_move(char *obj, gc_thread_data *thd, int *alloci, int *heap_grown) {
if (!is_object_type(obj)) return obj;
switch(type_of(obj)){
case pair_tag: {
list hp = gc_alloc(Cyc_heap, sizeof(cons_type), obj, thd, heap_grown);
list hp = gc_alloc(Cyc_heap, sizeof(pair_type), obj, thd, heap_grown);
return gc_fixup_moved_obj(thd, alloci, obj, hp);
}
case macro_tag: {

View file

@ -23,7 +23,7 @@
object lis = NULL;
for (i = _cyc_argc; i > 0; i--) {
object ps = alloca(sizeof(string_type));
object pl = alloca(sizeof(cons_type));
object pl = alloca(sizeof(pair_type));
make_string(s, _cyc_argv[i - 1]);
memcpy(ps, &s, sizeof(string_type));
((list)pl)->hdr.mark = gc_color_red;