X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Flisp%2Fao_lisp_cons.c;h=06e9d361e65630bf7b35d66ca2fef0eb4416db4e;hb=ed6967cef5d82baacafe1c23229f44d58c838326;hp=8d607372b7543a817f0998b1c246576f04363ecb;hpb=e1acf5eb12aceda7aa838df031c1da1129d0fa5d;p=fw%2Faltos diff --git a/src/lisp/ao_lisp_cons.c b/src/lisp/ao_lisp_cons.c index 8d607372..06e9d361 100644 --- a/src/lisp/ao_lisp_cons.c +++ b/src/lisp/ao_lisp_cons.c @@ -105,6 +105,19 @@ ao_lisp_cons_cons(ao_poly car, ao_poly cdr) return cons; } +struct ao_lisp_cons * +ao_lisp_cons_cdr(struct ao_lisp_cons *cons) +{ + ao_poly cdr = cons->cdr; + if (cdr == AO_LISP_NIL) + return NULL; + if (ao_lisp_poly_type(cdr) != AO_LISP_CONS) { + (void) ao_lisp_error(AO_LISP_INVALID, "improper list"); + return NULL; + } + return ao_lisp_poly_cons(cdr); +} + ao_poly ao_lisp__cons(ao_poly car, ao_poly cdr) { @@ -114,6 +127,9 @@ ao_lisp__cons(ao_poly car, ao_poly cdr) void ao_lisp_cons_free(struct ao_lisp_cons *cons) { +#if DBG_FREE_CONS + ao_lisp_cons_check(cons); +#endif while (cons) { ao_poly cdr = cons->cdr; cons->cdr = ao_lisp_cons_poly(ao_lisp_cons_free_list); @@ -123,7 +139,7 @@ ao_lisp_cons_free(struct ao_lisp_cons *cons) } void -ao_lisp_cons_print(ao_poly c) +ao_lisp_cons_write(ao_poly c) { struct ao_lisp_cons *cons = ao_lisp_poly_cons(c); int first = 1; @@ -131,14 +147,14 @@ ao_lisp_cons_print(ao_poly c) while (cons) { if (!first) printf(" "); - ao_lisp_poly_print(cons->car); + ao_lisp_poly_write(cons->car); c = cons->cdr; if (ao_lisp_poly_type(c) == AO_LISP_CONS) { cons = ao_lisp_poly_cons(c); first = 0; } else { printf(" . "); - ao_lisp_poly_print(c); + ao_lisp_poly_write(c); cons = NULL; } } @@ -146,12 +162,12 @@ ao_lisp_cons_print(ao_poly c) } void -ao_lisp_cons_patom(ao_poly c) +ao_lisp_cons_display(ao_poly c) { struct ao_lisp_cons *cons = ao_lisp_poly_cons(c); while (cons) { - ao_lisp_poly_patom(cons->car); + ao_lisp_poly_display(cons->car); cons = ao_lisp_poly_cons(cons->cdr); } }