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.
15 #include "ao_scheme.h"
19 ao_scheme_vfprintf(FILE *out, const char *format, va_list args)
23 while ((c = *format++) != '\0') {
25 switch (c = *format++) {
27 ao_scheme_poly_write(out, (ao_poly) va_arg(args, unsigned int), true);
30 ao_scheme_poly_write(out, (ao_poly) va_arg(args, unsigned int), false);
33 fprintf(out, "%p", va_arg(args, void *));
36 fprintf(out, "%d", va_arg(args, int));
39 fprintf(out, "%x", va_arg(args, int));
42 fprintf(out, "%s", va_arg(args, char *));
54 ao_scheme_fprintf(FILE *out, const char *format, ...)
57 va_start(args, format);
58 ao_scheme_vfprintf(out, format, args);
63 ao_scheme_error(int error, const char *format, ...)
67 ao_scheme_exception |= error;
68 va_start(args, format);
69 ao_scheme_vfprintf(stdout, format, args);
72 ao_scheme_fprintf(stdout, "Value: %v\n", ao_scheme_v);
73 ao_scheme_fprintf(stdout, "Frame: %v\n", ao_scheme_frame_poly(ao_scheme_frame_current));
75 ao_scheme_stack_write(stdout, ao_scheme_stack_poly(ao_scheme_stack), true);
76 ao_scheme_fprintf(stdout, "Globals: %v\n", ao_scheme_frame_poly(ao_scheme_frame_global));