From 408696f380f962354676594eeb0492faf048f2da Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 26 Mar 2017 22:12:24 +0200 Subject: [PATCH] mini-mes: Debugging to stderr. * scaffold/mini-mes.c (error, bload_env, main): Send debug info to stderr. throw/catch dinges: URG --- mes.c | 5 +++-- scaffold/mini-mes.c | 37 +++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/mes.c b/mes.c index 1310c42f..48b828b4 100644 --- a/mes.c +++ b/mes.c @@ -431,8 +431,9 @@ error (SCM key, SCM x) if ((throw = assq_ref_env (cell_symbol_throw, r0)) != cell_undefined) return apply (throw, cons (key, cons (x, cell_nil)), r0); display_error_ (key); - fputs (": ", stderr); + eputs (": "); display_error_ (x); + eputs ("\n"); assert (!"error"); } @@ -521,7 +522,7 @@ SCM set_env_x (SCM x, SCM e, SCM a) { SCM p = assert_defined (x, assq (x, a)); - if (TYPE (p) != TPAIR) error (cell_symbol_not_a_pair, cons (p, x)); + if (TYPE (p) != TPAIR) error (cell_symbol_not_a_pair, cons (p, x)); return set_cdr_x (p, e); } diff --git a/scaffold/mini-mes.c b/scaffold/mini-mes.c index 06bd3a93..4b5a5315 100644 --- a/scaffold/mini-mes.c +++ b/scaffold/mini-mes.c @@ -422,9 +422,10 @@ error (SCM key, SCM x) SCM throw; if ((throw = assq_ref_env (cell_symbol_throw, r0)) != cell_undefined) return apply (throw, cons (key, cons (x, cell_nil)), r0); - display_ (key); - puts (": "); + display_error_ (key); + eputs (": "); display_ (x); + eputs ("\n"); assert (0); } @@ -1633,27 +1634,27 @@ bload_env (SCM a) ///((internal)) if (g_debug) { - puts ("symbols: "); + eputs ("symbols: "); SCM s = g_symbols; while (s && s != cell_nil) { - display_ (CAR (s)); - puts (" "); + display_error_ (CAR (s)); + eputs (" "); s = CDR (s); } - puts ("\n"); - puts ("functions: "); - puts (itoa (g_function)); - puts ("\n"); + eputs ("\n"); + eputs ("functions: "); + eputs (itoa (g_function)); + eputs ("\n"); for (int i = 0; i < g_function; i++) { - puts ("["); - puts (itoa (i)); - puts ("]: "); - puts (g_functions[i].name); - puts ("\n"); + eputs ("["); + eputs (itoa (i)); + eputs ("]: "); + eputs (g_functions[i].name); + eputs ("\n"); } - display_ (r0); - puts ("\n"); + //display_error_ (r0); + //puts ("\n"); } return r2; } @@ -1699,12 +1700,12 @@ main (int argc, char *argv[]) if (g_debug) { eputs ("program: "); - display_ (r1); + display_error_ (r1); eputs ("\n"); } r3 = cell_vm_begin; r1 = eval_apply (); - display_ (r1); + display_error_ (r1); eputs ("\n"); #if !MES_MINI