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_read.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_read.c')
| -rw-r--r-- | src/lisp/ao_lisp_read.c | 31 | 
1 files changed, 22 insertions, 9 deletions
| diff --git a/src/lisp/ao_lisp_read.c b/src/lisp/ao_lisp_read.c index ccb4ba3a..ea98b976 100644 --- a/src/lisp/ao_lisp_read.c +++ b/src/lisp/ao_lisp_read.c @@ -155,8 +155,21 @@ lex_get()  	if (lex_unget_c) {  		c = lex_unget_c;  		lex_unget_c = 0; -	} else +	} else { +#if AO_LISP_ALTOS +		static uint8_t	at_eol; + +		if (at_eol) { +			ao_cmd_readline(); +			at_eol = 0; +		} +		c = ao_cmd_lex(); +		if (c == '\n') +			at_eol = 1; +#else  		c = getchar(); +#endif +	}  	return c;  } @@ -362,13 +375,13 @@ static struct ao_lisp_cons	*read_cons;  static struct ao_lisp_cons	*read_cons_tail;  static struct ao_lisp_cons	*read_stack; -static ao_lisp_poly +static ao_poly  read_item(void)  {  	struct ao_lisp_atom	*atom;  	char			*string;  	int			cons; -	ao_lisp_poly		v; +	ao_poly			v;  	if (!been_here) {  		ao_lisp_root_add(&ao_lisp_cons_type, &read_cons); @@ -381,7 +394,7 @@ read_item(void)  	for (;;) {  		while (parse_token == OPEN) {  			if (cons++) -				read_stack = ao_lisp_cons(ao_lisp_cons_poly(read_cons), read_stack); +				read_stack = ao_lisp_cons_cons(ao_lisp_cons_poly(read_cons), read_stack);  			read_cons = NULL;  			read_cons_tail = NULL;  			parse_token = lex(); @@ -416,10 +429,10 @@ read_item(void)  				v = AO_LISP_NIL;  			if (--cons) {  				read_cons = ao_lisp_poly_cons(read_stack->car); -				read_stack = read_stack->cdr; +				read_stack = ao_lisp_poly_cons(read_stack->cdr);  				for (read_cons_tail = read_cons;  				     read_cons_tail && read_cons_tail->cdr; -				     read_cons_tail = read_cons_tail->cdr) +				     read_cons_tail = ao_lisp_poly_cons(read_cons_tail->cdr))  					;  			}  			break; @@ -428,9 +441,9 @@ read_item(void)  		if (!cons)  			break; -		struct ao_lisp_cons	*read = ao_lisp_cons(v, NULL); +		struct ao_lisp_cons	*read = ao_lisp_cons_cons(v, NULL);  		if (read_cons_tail) -			read_cons_tail->cdr = read; +			read_cons_tail->cdr = ao_lisp_cons_poly(read);  		else  			read_cons = read;  		read_cons_tail = read; @@ -440,7 +453,7 @@ read_item(void)  	return v;  } -ao_lisp_poly +ao_poly  ao_lisp_read(void)  {  	parse_token = lex(); | 
