1 /* -*-C-*-
2 
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
4     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts
6     Institute of Technology
7 
8 This file is part of MIT/GNU Scheme.
9 
10 MIT/GNU Scheme is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or (at
13 your option) any later version.
14 
15 MIT/GNU Scheme is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with MIT/GNU Scheme; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
23 USA.
24 
25 */
26 
27 /* Error and termination code declarations. */
28 
29 #ifndef SCM_ERRORS_H
30 #define SCM_ERRORS_H
31 
32 /* All error and termination codes must be positive to allow
33    primitives to return either an error code or a primitive flow
34    control value (see const.h).  */
35 
36 #define ERR_BAD_ERROR_CODE			0x00
37 #define ERR_UNBOUND_VARIABLE			0x01
38 #define ERR_UNASSIGNED_VARIABLE			0x02
39 #define ERR_INAPPLICABLE_OBJECT			0x03
40 #define ERR_IN_SYSTEM_CALL			0x04
41 #define ERR_WITH_ARGUMENT			0x05
42 #define ERR_BAD_FRAME				0x06
43 /* #define ERR_BROKEN_COMPILED_VARIABLE		0x07 */
44 /* #define ERR_UNDEFINED_USER_TYPE		0x08 */
45 #define ERR_UNDEFINED_PRIMITIVE			0x09
46 #define ERR_EXTERNAL_RETURN			0x0A
47 #define ERR_EXECUTE_MANIFEST_VECTOR		0x0B
48 #define ERR_WRONG_NUMBER_OF_ARGUMENTS		0x0C
49 #define ERR_ARG_1_WRONG_TYPE			0x0D
50 #define ERR_ARG_2_WRONG_TYPE			0x0E
51 #define ERR_ARG_3_WRONG_TYPE			0x0F
52 #define ERR_ARG_1_BAD_RANGE			0x10
53 #define ERR_ARG_2_BAD_RANGE			0x11
54 #define ERR_ARG_3_BAD_RANGE			0x12
55 #define ERR_MACRO_BINDING			0x13
56 #define ERR_FASDUMP_OBJECT_TOO_LARGE		0x14
57 #define ERR_SYNTAX_ERROR			0x15
58 /* #define ERR_NO_ERRORS			0x16 */
59 #define ERR_FASL_FILE_TOO_BIG			0x17
60 #define ERR_FASL_FILE_BAD_DATA			0x18
61 /* #define ERR_IMPURIFY_OUT_OF_SPACE		0x19 */
62 /* #define ERR_WRITE_INTO_PURE_SPACE		0x1A */
63 /* #define ERR_LOSING_SPARE_HEAP		0x1B */
64 /* #define ERR_NO_HASH_TABLE			0x1C */
65 /* #define ERR_BAD_SET				0x1D */
66 /* #define ERR_ARG_1_FAILED_COERCION		0x1E */
67 /* #define ERR_ARG_2_FAILED_COERCION		0x1F */
68 #define ERR_OUT_OF_FILE_HANDLES			0x20
69 /* #define ERR_SHELL_DIED			0x21 */
70 #define ERR_ARG_4_BAD_RANGE			0x22
71 #define ERR_ARG_5_BAD_RANGE			0x23
72 #define ERR_ARG_6_BAD_RANGE			0x24
73 #define ERR_ARG_7_BAD_RANGE			0x25
74 #define ERR_ARG_8_BAD_RANGE			0x26
75 #define ERR_ARG_9_BAD_RANGE			0x27
76 #define ERR_ARG_10_BAD_RANGE			0x28
77 #define ERR_ARG_4_WRONG_TYPE			0x29
78 #define ERR_ARG_5_WRONG_TYPE			0x2A
79 #define ERR_ARG_6_WRONG_TYPE			0x2B
80 #define ERR_ARG_7_WRONG_TYPE			0x2C
81 #define ERR_ARG_8_WRONG_TYPE			0x2D
82 #define ERR_ARG_9_WRONG_TYPE			0x2E
83 #define ERR_ARG_10_WRONG_TYPE			0x2F
84 #define ERR_INAPPLICABLE_CONTINUATION		0x30
85 #define ERR_COMPILED_CODE_ERROR			0x31
86 #define ERR_FLOATING_OVERFLOW			0x32
87 #define ERR_UNIMPLEMENTED_PRIMITIVE		0x33
88 #define ERR_ILLEGAL_REFERENCE_TRAP		0x34
89 /* #define ERR_BROKEN_VARIABLE_CACHE		0x35 */
90 #define ERR_WRONG_ARITY_PRIMITIVES		0x36
91 /* #define ERR_IO_ERROR				0x37 */
92 #define ERR_FASDUMP_ENVIRONMENT			0x38
93 #define ERR_FASLOAD_BAND			0x39
94 #define ERR_FASLOAD_COMPILED_MISMATCH		0x3A
95 /* #define ERR_UNKNOWN_PRIMITIVE_CONTINUATION	0x3B */
96 /* #define ERR_ILLEGAL_CONTINUATION		0x3C */
97 #define ERR_STACK_HAS_SLIPPED			0x3D
98 #define ERR_CANNOT_RECURSE			0x3E
99 #define ERR_PROCESS_TERMINATED			0x3F
100 
101 /* If you add any error codes here, add them to the table below.  */
102 
103 #define MAX_ERROR				0x3F
104 
105 #define ERROR_NAME_TABLE						\
106 {									\
107 /* 0x00 */		"bad-error-code",				\
108 /* 0x01 */		"unbound-variable",				\
109 /* 0x02 */		"unassigned-variable",				\
110 /* 0x03 */		"undefined-procedure",				\
111 /* 0x04 */		"system-call",					\
112 /* 0x05 */		"error-with-argument",				\
113 /* 0x06 */		"bad-frame",					\
114 /* 0x07 */		0,						\
115 /* 0x08 */		0,						\
116 /* 0x09 */		"undefined-primitive-operation",		\
117 /* 0x0a */		"external-return",				\
118 /* 0x0b */		"execute-manifest-vector",			\
119 /* 0x0c */		"wrong-number-of-arguments",			\
120 /* 0x0d */		"wrong-type-argument-0",			\
121 /* 0x0e */		"wrong-type-argument-1",			\
122 /* 0x0f */		"wrong-type-argument-2",			\
123 /* 0x10 */		"bad-range-argument-0",				\
124 /* 0x11 */		"bad-range-argument-1",				\
125 /* 0x12 */		"bad-range-argument-2",				\
126 /* 0x13 */		"macro-binding",				\
127 /* 0x14 */		"fasdump-object-too-large",			\
128 /* 0x15 */		"syntax-error",					\
129 /* 0x16 */		0,						\
130 /* 0x17 */		"fasl-file-too-big",				\
131 /* 0x18 */		"fasl-file-bad-data",				\
132 /* 0x19 */		0,						\
133 /* 0x1a */		0,						\
134 /* 0x1b */		0,						\
135 /* 0x1c */		0,						\
136 /* 0x1d */		0,						\
137 /* 0x1e */		0,						\
138 /* 0x1f */		0,						\
139 /* 0x20 */		"out-of-file-handles",				\
140 /* 0x21 */		0,						\
141 /* 0x22 */		"bad-range-argument-3",				\
142 /* 0x23 */		"bad-range-argument-4",				\
143 /* 0x24 */		"bad-range-argument-5",				\
144 /* 0x25 */		"bad-range-argument-6",				\
145 /* 0x26 */		"bad-range-argument-7",				\
146 /* 0x27 */		"bad-range-argument-8",				\
147 /* 0x28 */		"bad-range-argument-9",				\
148 /* 0x29 */		"wrong-type-argument-3",			\
149 /* 0x2a */		"wrong-type-argument-4",			\
150 /* 0x2b */		"wrong-type-argument-5",			\
151 /* 0x2c */		"wrong-type-argument-6",			\
152 /* 0x2d */		"wrong-type-argument-7",			\
153 /* 0x2e */		"wrong-type-argument-8",			\
154 /* 0x2f */		"wrong-type-argument-9",			\
155 /* 0x30 */		"inapplicable-continuation",			\
156 /* 0x31 */		"compiled-code-error",				\
157 /* 0x32 */		"floating-overflow",				\
158 /* 0x33 */		"unimplemented-primitive",			\
159 /* 0x34 */		"illegal-reference-trap",			\
160 /* 0x35 */		0,						\
161 /* 0x36 */		"wrong-arity-primitives",			\
162 /* 0x37 */		0,						\
163 /* 0x38 */		"fasdump-environment",				\
164 /* 0x39 */		"fasload-band",					\
165 /* 0x3a */		"fasload-compiled-mismatch",			\
166 /* 0x3b */		0,						\
167 /* 0x3c */		0,						\
168 /* 0x3d */		"stack-has-slipped",				\
169 /* 0x3e */		"cannot-recurse",				\
170 /* 0x3f */		"process-terminated",				\
171 }
172 
173 /* Termination codes: the interpreter halts on these */
174 
175 #define TERM_HALT				0x00
176 #define TERM_DISK_RESTORE			0x01
177 #define TERM_BROKEN_HEART			0x02
178 #define TERM_NON_POINTER_RELOCATION		0x03
179 #define TERM_BAD_ROOT				0x04
180 #define TERM_NON_EXISTENT_CONTINUATION		0x05
181 #define TERM_BAD_STACK				0x06
182 #define TERM_STACK_OVERFLOW			0x07
183 #define TERM_STACK_ALLOCATION_FAILED		0x08
184 #define TERM_NO_ERROR_HANDLER			0x09
185 #define TERM_NO_INTERRUPT_HANDLER		0x0A
186 #define TERM_UNIMPLEMENTED_CONTINUATION		0x0B
187 #define TERM_EXIT				0x0C
188 #define TERM_BAD_PRIMITIVE_DURING_ERROR		0x0D
189 #define TERM_EOF				0x0E
190 #define TERM_BAD_PRIMITIVE			0x0F
191 #define TERM_TERM_HANDLER			0x10
192 #define TERM_END_OF_COMPUTATION			0x11
193 #define TERM_INVALID_TYPE_CODE                  0x12
194 #define TERM_COMPILER_DEATH			0x13
195 #define TERM_GC_OUT_OF_SPACE			0x14
196 #define TERM_NO_SPACE				0x15
197 #define TERM_SIGNAL				0x16
198 /* #define TERM_				0x17 */
199 #define TERM_SAVE_AND_EXIT			0x18
200 #define TERM_TRAP				0x19
201 #define TERM_BAD_BACK_OUT			0x1a
202 
203 /*
204   If you add any termination codes here, add them to
205   the tables below as well!
206  */
207 
208 #define MAX_TERMINATION				0x1a
209 
210 #define TERM_NAME_TABLE							\
211 {									\
212 /* 0x00 */		"halt",						\
213 /* 0x01 */		"disk-restore",					\
214 /* 0x02 */		"broken-heart",					\
215 /* 0x03 */		"non-pointer-relocation",			\
216 /* 0x04 */		"bad-root",					\
217 /* 0x05 */		"non-existent-continuation",			\
218 /* 0x06 */		"bad-stack",					\
219 /* 0x07 */		"stack-overflow",				\
220 /* 0x08 */		"stack-allocation-failed",			\
221 /* 0x09 */		"no-error-handler",				\
222 /* 0x0a */		"no-interrupt-handler",				\
223 /* 0x0b */		"unimplemented-continuation",			\
224 /* 0x0c */		"exit",						\
225 /* 0x0d */		"bad-primitive-during-error",			\
226 /* 0x0e */		"eof",						\
227 /* 0x0f */		"bad-primitive",				\
228 /* 0x10 */		"termination-handler",				\
229 /* 0x11 */		"end-of-computation",				\
230 /* 0x12 */		"invalid-type-code",				\
231 /* 0x13 */		"compiler-death",				\
232 /* 0x14 */		"gc-out-of-space",				\
233 /* 0x15 */		"no-space",					\
234 /* 0x16 */		"signal",					\
235 /* 0x17 */		0,						\
236 /* 0x18 */		"save-and-exit",				\
237 /* 0x19 */		"trap",						\
238 /* 0x1a */		"bad-back-out"					\
239 }
240 
241 #define TERM_MESSAGE_TABLE						\
242 {									\
243 /* 0x00 */		"Moriturus te saluto",				\
244 /* 0x01 */		"Unrecoverable error while loading a band",	\
245 /* 0x02 */		"Broken heart encountered",			\
246 /* 0x03 */		"Non pointer relocation",			\
247 /* 0x04 */		"Cannot restore control state from band",	\
248 /* 0x05 */		"Nonexistent return code",			\
249 /* 0x06 */		"Control stack messed up",			\
250 /* 0x07 */		"Stack overflow: Maximum recursion depth exceeded", \
251 /* 0x08 */		"Not enough space for stack!",			\
252 /* 0x09 */		"No error handler",				\
253 /* 0x0A */		"No interrupt handler",				\
254 /* 0x0B */		"Unimplemented return code",			\
255 /* 0x0C */		"Inconsistency detected",			\
256 /* 0x0D */		"Error during unknown primitive",		\
257 /* 0x0E */		"End of input stream reached",			\
258 /* 0x0F */		"Bad primitive invoked",			\
259 /* 0x10 */		"Termination handler returned",			\
260 /* 0x11 */		"End of computation",				\
261 /* 0x12 */		"Unknown type encountered",			\
262 /* 0x13 */		"Mismatch between compiled code and compiled code support", \
263 /* 0x14 */		"Out of space after garbage collection",	\
264 /* 0x15 */		"Out of memory: Available memory exceeded",	\
265 /* 0x16 */		"Unhandled signal received",			\
266 /* 0x17 */		0,						\
267 /* 0x18 */		"Halt requested by external source",		\
268 /* 0x19 */		"User requested termination after trap",	\
269 /* 0x1A */		"Backing out of non-primitive"			\
270 }
271 
272 #endif /* SCM_ERRORS_H */
273