1 /* Nitfol - z-machine interpreter using Glk for output.
2 Copyright (C) 1999 Evin Robertson
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,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
18 The author can be reached at nitfol@deja.com
23 typedef enum { E_INSTR, E_OBJECT, E_STACK, E_MEMORY, E_MATH, E_STRING,
24 E_OUTPUT, E_SOUND, E_SYSTEM, E_VERSION, E_CORRUPT, E_SAVE,
28 static const char *errortypenames[] = {
45 /* These all feature loop detection, so if error reporting spawns another
46 error, we won't infinite loop. Hopefully.
49 void n_show_warn(errortypes type, const char *message, offset number)
51 if(!ignore_errors && allow_output) {
52 showstuff("WARN", errortypenames[type], message, number);
56 void n_show_port(errortypes type, const char *message, offset number)
58 if(!ignore_errors && allow_output) {
59 showstuff("PORT", errortypenames[type], message, number);
63 void n_show_error(errortypes type, const char *message, offset number)
65 if(!ignore_errors && allow_output) {
66 showstuff("ERROR", errortypenames[type], message, number);
70 /* showstuff calls n_show_fatal if it's looping uncontrollably, but it
71 disables its loopiness detector so it can show this fatal error. So
72 n_show_fatal needs its own loop detection. */
73 void n_show_fatal(errortypes type, const char *message, offset number)
75 static BOOL loopy = FALSE;
81 showstuff("FATAL", errortypenames[type], message, number);
87 void n_show_debug(errortypes type, const char *message, offset number)
90 static BOOL loopy = FALSE;
92 n_show_fatal(E_SYSTEM, "loopy debug error", 0);
94 showstuff("E_DEBUG", errortypenames[type], message, number);
99 zword z_range_error(offset p)
102 static BOOL loopy = FALSE;
104 n_show_fatal(E_SYSTEM, "loopy range error", 0);
106 showstuff("RANGE", errortypenames[E_MEMORY], "invalid memory access", p);