2 * Copyright © 2016 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
19 ao_lisp_error_poly(char *name, ao_poly poly, ao_poly last)
22 printf("\t\t%s(", name);
23 if (ao_lisp_poly_type(poly) == AO_LISP_CONS) {
26 struct ao_lisp_cons *cons = ao_lisp_poly_cons(poly);
31 ao_lisp_poly_write(cons->car);
41 ao_lisp_poly_write(poly);
46 static void tabs(int indent)
53 ao_lisp_error_frame(int indent, char *name, struct ao_lisp_frame *frame)
60 if (frame->type & AO_LISP_FRAME_PRINT)
63 frame->type |= AO_LISP_FRAME_PRINT;
64 for (f = 0; f < frame->num; f++) {
69 ao_lisp_poly_write(frame->vals[f].atom);
71 ao_lisp_poly_write(frame->vals[f].val);
75 ao_lisp_error_frame(indent + 1, "prev: ", ao_lisp_poly_frame(frame->prev));
76 frame->type &= ~AO_LISP_FRAME_PRINT;
86 ao_lisp_error(int error, char *format, ...)
90 ao_lisp_exception |= error;
91 va_start(args, format);
92 vprintf(format, args);
95 printf("Value: "); ao_lisp_poly_write(ao_lisp_v); printf("\n");
97 ao_lisp_stack_write(ao_lisp_stack_poly(ao_lisp_stack));
98 printf("Globals:\n\t");
99 ao_lisp_frame_write(ao_lisp_frame_poly(ao_lisp_frame_global));