diff options
| author | Keith Packard <keithp@keithp.com> | 2016-11-01 21:14:45 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-02-20 11:16:49 -0800 | 
| commit | d2408e72d1e0d3459918601712b09860ab17e200 (patch) | |
| tree | 5405e41249373e4d174e61e157ee30d00f145c8d /src/lisp/ao_lisp_cons.c | |
| parent | e2f4d25cd6f6f3787d4ee99264732d5b2ce23d4c (diff) | |
altos/lisp: Change lisp objects to use ao_poly everywhere. Add const
This makes all lisp objects use 16-bit ints for references so we can
hold more stuff in small amounts of memory. Also adds a separate
constant pool of lisp objects for builtins, initial atoms and constant
lisp code.
Now builds (and runs!) on the nucleo-32 boards.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_cons.c')
| -rw-r--r-- | src/lisp/ao_lisp_cons.c | 19 | 
1 files changed, 10 insertions, 9 deletions
| diff --git a/src/lisp/ao_lisp_cons.c b/src/lisp/ao_lisp_cons.c index 60cbb2f3..65908e30 100644 --- a/src/lisp/ao_lisp_cons.c +++ b/src/lisp/ao_lisp_cons.c @@ -20,7 +20,7 @@ static void cons_mark(void *addr)  	for (;;) {  		ao_lisp_poly_mark(cons->car); -		cons = cons->cdr; +		cons = ao_lisp_poly_cons(cons->cdr);  		if (!cons)  			break;  		if (ao_lisp_mark_memory(cons, sizeof (struct ao_lisp_cons))) @@ -42,42 +42,43 @@ static void cons_move(void *addr)  		struct ao_lisp_cons	*cdr;  		cons->car = ao_lisp_poly_move(cons->car); -		cdr = ao_lisp_move_memory(cons->cdr, sizeof (struct ao_lisp_cons)); +		cdr = ao_lisp_poly_cons(cons->cdr); +		cdr = ao_lisp_move_memory(cdr, sizeof (struct ao_lisp_cons));  		if (!cdr)  			break; -		cons->cdr = cdr; +		cons->cdr = ao_lisp_cons_poly(cdr);  		cons = cdr;  	}  } -const struct ao_lisp_mem_type ao_lisp_cons_type = { +const struct ao_lisp_type ao_lisp_cons_type = {  	.mark = cons_mark,  	.size = cons_size,  	.move = cons_move,  };  struct ao_lisp_cons * -ao_lisp_cons(ao_lisp_poly car, struct ao_lisp_cons *cdr) +ao_lisp_cons_cons(ao_poly car, struct ao_lisp_cons *cdr)  {  	struct ao_lisp_cons	*cons = ao_lisp_alloc(sizeof (struct ao_lisp_cons));  	if (!cons)  		return NULL;  	cons->car = car; -	cons->cdr = cdr; +	cons->cdr = ao_lisp_cons_poly(cdr);  	return cons;  }  void -ao_lisp_cons_print(struct ao_lisp_cons *cons) +ao_lisp_cons_print(ao_poly c)  { +	struct ao_lisp_cons *cons = ao_lisp_poly_cons(c);  	int	first = 1;  	printf("(");  	while (cons) {  		if (!first)  			printf(" "); -		fflush(stdout);  		ao_lisp_poly_print(cons->car); -		cons = cons->cdr; +		cons = ao_lisp_poly_cons(cons->cdr);  		first = 0;  	}  	printf(")"); | 
