PageRenderTime 69ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/src/error.d

https://github.com/ynd/clisp-branch--ynd-devel
D | 1586 lines | 1038 code | 78 blank | 470 comment | 132 complexity | 1efab42528f841737e8e254393398ece MD5 | raw file
Possible License(s): LGPL-2.0, GPL-2.0, BSD-3-Clause
  1. /*
  2. * Error-Handling for CLISP
  3. * Bruno Haible 1990-2005
  4. * Marcus Daniels 8.4.1994
  5. * Sam Steingold 1998-2007
  6. * German comments translated into English: Stefan Kain 2002-09-11
  7. */
  8. #include "lispbibl.c"
  9. /* SYS::*RECURSIVE-ERROR-COUNT* =
  10. depth of recursion of the output of error messages */
  11. local void cancel_interrupts (void) {
  12. #ifdef PENDING_INTERRUPTS
  13. interrupt_pending = false; /* Ctrl-C pending time is soon completed */
  14. #ifndef WIN32_NATIVE
  15. begin_system_call();
  16. #ifdef HAVE_UALARM
  17. ualarm(0,0); /* abort SIGALRM timer */
  18. #else
  19. alarm(0); /* abort SIGALRM timer */
  20. #endif
  21. end_system_call();
  22. #endif
  23. #endif
  24. }
  25. /* UP: Starts the output of an error message.
  26. begin_error()
  27. < STACK_0: Stream (in general *ERROR-OUTPUT*)
  28. < STACK_1: value of *error-handler*
  29. < STACK_2: list of arguments for *error-handler*
  30. < STACK_3: type of condition (in general SIMPLE-ERROR) or NIL
  31. decreases STACK by 7 */
  32. local void begin_error (void)
  33. {
  34. end_system_call(); /* there is no system call running anymore */
  35. cancel_interrupts();
  36. #if defined(HAVE_SIGNALS) && defined(SIGPIPE)
  37. writing_to_subprocess = false;
  38. #endif
  39. if (!posfixnump(Symbol_value(S(recursive_error_count)))) /* should be a fixnum >=0 */
  40. Symbol_value(S(recursive_error_count)) = Fixnum_0; /* otherwise emergency correction */
  41. /* increase error-count, if >3 abort output: */
  42. dynamic_bind(S(recursive_error_count),
  43. fixnum_inc(Symbol_value(S(recursive_error_count)),1));
  44. if (posfixnum_to_V(Symbol_value(S(recursive_error_count))) > 3) {
  45. /* multiple nested error message. */
  46. Symbol_value(S(recursive_error_count)) = Fixnum_0; /* delete error count */
  47. /* bind *PRINT-PRETTY* to NIL (in order to save memory): */
  48. dynamic_bind(S(print_pretty),NIL);
  49. error(serious_condition,
  50. /* Note: All translations of this error message should be in
  51. pure ASCII, to avoid endless recursion if *terminal-encoding*
  52. supports only ASCII characters. */
  53. GETTEXT("Unprintable error message"));
  54. }
  55. var object error_handler = Symbol_value(S(error_handler)); /* *ERROR-HANDLER* */
  56. if (!nullp(error_handler)) { /* *ERROR-HANDER* /= NIL */
  57. pushSTACK(NIL); pushSTACK(NIL); pushSTACK(error_handler);
  58. pushSTACK(make_string_output_stream()); /* String-Output-Stream */
  59. } else if (nullpSv(use_clcs)) { /* SYS::*USE-CLCS* */
  60. /* *ERROR-HANDER* = NIL, SYS::*USE-CLCS* = NIL */
  61. pushSTACK(NIL); pushSTACK(NIL); pushSTACK(NIL);
  62. pushSTACK(var_stream(S(error_output),strmflags_wr_ch_B)); /* Stream *ERROR-OUTPUT* */
  63. fresh_line(&STACK_0); /* new line */
  64. write_sstring(&STACK_0,O(error_string1)); /* print "*** - " */
  65. } else { /* *ERROR-HANDER* = NIL, SYS::*USE-CLCS* /= NIL */
  66. pushSTACK(S(simple_error)); pushSTACK(NIL); pushSTACK(unbound);
  67. pushSTACK(make_string_output_stream()); /* String-Output-Stream */
  68. }
  69. }
  70. /* UP: output an error-object. */
  71. local void write_errorobject (object obj) {
  72. if (nullp(STACK_1)) {
  73. dynamic_bind(S(prin_stream),unbound); /* bind SYS::*PRIN-STREAM* to #<UNBOUND> */
  74. dynamic_bind(S(print_escape),T); /* bind *PRINT-ESCAPE* to T */
  75. dynamic_bind(S(print_readably),NIL); /* bind *PRINT-READABLY* to NIL */
  76. prin1(&STACK_(0+3+3+3),obj); /* output directly */
  77. dynamic_unbind(S(print_readably));
  78. dynamic_unbind(S(print_escape));
  79. dynamic_unbind(S(prin_stream));
  80. } else {
  81. /* push obj onto the argument list: */
  82. pushSTACK(obj);
  83. obj = allocate_cons();
  84. Car(obj) = popSTACK();
  85. Cdr(obj) = STACK_2; STACK_2 = obj;
  86. /* and write "~S" into the format string: */
  87. write_ascii_char(&STACK_0,'~'); write_ascii_char(&STACK_0,'S');
  88. }
  89. }
  90. /* UP: outputs an error-character. */
  91. local void write_errorchar (object obj) {
  92. if (nullp(STACK_1)) {
  93. write_char(&STACK_0,obj); /* write directly */
  94. } else { /* push obj on the argument list: */
  95. pushSTACK(obj);
  96. obj = allocate_cons();
  97. Car(obj) = popSTACK();
  98. Cdr(obj) = STACK_2; STACK_2 = obj;
  99. /* and write "~A" into the format string: */
  100. write_ascii_char(&STACK_0,'~'); write_ascii_char(&STACK_0,'A');
  101. }
  102. }
  103. /* UP: Outputs a piece of an error string without modifications.
  104. write_errorasciz_substring(start,end);
  105. > start, end: delimit an unmovable string in UTF-8 encoding */
  106. local void write_errorasciz_substring (const uintB* start, const uintB* end)
  107. {
  108. #ifdef UNICODE
  109. var object encoding = O(internal_encoding);
  110. var const uintB* bptr = start;
  111. var const uintB* bendptr = end;
  112. var uintL clen = Encoding_mblen(encoding)(encoding,bptr,bendptr);
  113. if (clen > 0) {
  114. var DYNAMIC_ARRAY(charbuf,chart,clen);
  115. {
  116. var chart* cptr = &charbuf[0];
  117. var chart* cendptr = cptr+clen;
  118. Encoding_mbstowcs(encoding)(encoding,nullobj,&bptr,
  119. bendptr,&cptr,cendptr);
  120. ASSERT(cptr == cendptr);
  121. }
  122. {
  123. var const chart* cptr = &charbuf[0];
  124. dotimespL(clen,clen, { write_code_char(&STACK_0,*cptr); cptr++; });
  125. }
  126. FREE_DYNAMIC_ARRAY(charbuf);
  127. }
  128. #else
  129. var const uintB* bptr = start;
  130. while (bptr != end) {
  131. write_code_char(&STACK_0,as_chart(*bptr));
  132. bptr++;
  133. }
  134. #endif
  135. }
  136. /* UP: Outputs an errorstring unchanged.
  137. write_errorasciz(asciz);
  138. > asciz: errorstring (a non-relocatable ASCIZ-string), in UTF-8 Encoding */
  139. local void write_errorasciz (const char* asciz) {
  140. write_errorasciz_substring((const uintB*)asciz,
  141. (const uintB*)(asciz + asciz_length(asciz)));
  142. }
  143. /* UP: Outputs an errorstring. At each tilde-S '~S' an object from the stack
  144. is printed, at each tilde-C '~C' a character from the stack is printed.
  145. write_errorstring(errorstring)
  146. > STACK_0: Stream etc.
  147. > errorstring: Errorstring (an non-relocatable ASCIZ-string),
  148. in UTF-8 Encoding
  149. > STACK_7, STACK_8, ...: arguments (for each '~S' resp. '~C' one argument),
  150. in reversed order as with FUNCALL !
  151. < result: STACK-value above the stream and the arguments */
  152. local gcv_object_t* write_errorstring (const char* errorstring)
  153. {
  154. var gcv_object_t* argptr = args_end_pointer STACKop 7; /* pointer above stream and frame */
  155. while (1) {
  156. var char ch = *errorstring; /* next character */
  157. if (ch==0) /* string finished? */
  158. break;
  159. if (ch=='~') { /* tilde? */
  160. if (errorstring[1]=='S') {
  161. /* print an object from stack: */
  162. write_errorobject(BEFORE(argptr));
  163. errorstring += 2;
  164. continue;
  165. }
  166. if (errorstring[1]=='C') {
  167. /* print a character from stack: */
  168. write_errorchar(BEFORE(argptr));
  169. errorstring += 2;
  170. continue;
  171. }
  172. pushSTACK(asciz_to_string(errorstring,Symbol_value(S(utf_8))));
  173. error(error_condition,
  174. GETTEXT("internal error or error in message catalog: invalid low-level format string ~S"));
  175. }
  176. /* output all characters until the next special character */
  177. var const char* ptr = errorstring;
  178. while (1) {
  179. ptr++;
  180. ch = *ptr;
  181. if (ch==0 || ch=='~')
  182. break;
  183. }
  184. write_errorasciz_substring((const uintB*)errorstring,(const uintB*)ptr);
  185. errorstring = ptr;
  186. }
  187. return argptr;
  188. }
  189. /* SIGNAL the CONDITION and INVOKE the debugger */
  190. nonreturning_function(local, signal_and_debug, (object condition)) {
  191. pushSTACK(condition); /* save condition */
  192. dynamic_bind(S(print_escape),T); /* bind *PRINT-ESCAPE* to NIL */
  193. dynamic_bind(S(print_readably),NIL); /* bind *PRINT-READABLY* to NIL */
  194. pushSTACK(condition); funcall(L(clcs_signal),1); /* (SIGNAL condition) */
  195. dynamic_bind(S(prin_stream),unbound); /* bind SYS::*PRIN-STREAM* to #<UNBOUND> */
  196. pushSTACK(STACK_(0+3+3+3)); /* condition */
  197. funcall(L(invoke_debugger),1); /* (INVOKE-DEBUGGER condition) */
  198. NOTREACHED;
  199. }
  200. /* finishes the output of an error message and starts a new driver,
  201. (when start_driver_p is true)
  202. can trigger GC */
  203. local maygc void end_error (gcv_object_t* stackptr, bool start_driver_p) {
  204. elastic_newline(&STACK_0);
  205. if (nullp(STACK_1)) {
  206. /* *ERROR-HANDER* = NIL, SYS::*USE-CLCS* = NIL */
  207. skipSTACK(4); /* error message has already been printed */
  208. /* unbind binding frame for sys::*recursive-error-count*,
  209. because no error message output is active */
  210. dynamic_unbind(S(recursive_error_count));
  211. set_args_end_pointer(stackptr);
  212. break_driver(false); /* call break-driver (does not return) */
  213. } else {
  214. STACK_0 = get_output_stream_string(&STACK_0);
  215. var object arguments = nreverse(STACK_2);
  216. /* stack layout: type, args, handler, errorstring. */
  217. if (boundp(STACK_1)) {
  218. /* *ERROR-HANDER* /= NIL
  219. stack layout: nil, args, handler, errorstring.
  220. execute (apply *error-handler* nil errorstring args): */
  221. check_SP(); check_STACK();
  222. {
  223. var object error_handler = STACK_1; STACK_1 = NIL;
  224. apply(error_handler,2,arguments);
  225. skipSTACK(2);
  226. }
  227. /* unbind binding frame for sys::*recursive-error-count*,
  228. because no error message output is active */
  229. dynamic_unbind(S(recursive_error_count));
  230. set_args_end_pointer(stackptr);
  231. if (start_driver_p)
  232. break_driver(false); /* call break-driver (does not return) */
  233. } else {
  234. /* *ERROR-HANDER* = NIL, SYS::*USE-CLCS* /= NIL
  235. stack layout: type, args, --, errorstring. */
  236. var object type = STACK_3;
  237. var object errorstring = STACK_0;
  238. skipSTACK(4);
  239. dynamic_unbind(S(recursive_error_count));
  240. /* execute (APPLY #'coerce-to-condition errorstring args
  241. 'error type keyword-arguments) */
  242. pushSTACK(errorstring); pushSTACK(arguments);
  243. pushSTACK(S(error)); pushSTACK(type);
  244. var uintC argcount = 4;
  245. /* arithmetic-error, division-by-zero, floating-point-overflow,
  246. floating-point-underflow
  247. --> complete :operation :operands ??
  248. cell-error, uncound-variable, undefined-function, unbound-slot
  249. --> complete :name */
  250. if (eq(type,S(simple_cell_error))
  251. || eq(type,S(simple_unbound_variable))
  252. || eq(type,S(simple_undefined_function))
  253. || eq(type,S(simple_unbound_slot))) {
  254. pushSTACK(S(Kname)); pushSTACK(BEFORE(stackptr)); /* :name ... */
  255. argcount += 2;
  256. }
  257. /* unbound-slot --> complete :instance */
  258. if (eq(type,S(simple_unbound_slot))) {
  259. pushSTACK(S(Kinstance)); pushSTACK(BEFORE(stackptr)); /* :instance ... */
  260. argcount += 2;
  261. }
  262. /* type-error, keyword-error --> complete :datum, :expected-type */
  263. if (eq(type,S(simple_type_error))
  264. || eq(type,S(simple_keyword_error))
  265. || eq(type,S(simple_charset_type_error))) {
  266. pushSTACK(S(Kexpected_type)); pushSTACK(BEFORE(stackptr)); /* :expected-type ... */
  267. pushSTACK(S(Kdatum)); pushSTACK(BEFORE(stackptr)); /* :datum ... */
  268. argcount += 4;
  269. }
  270. /* argument-list-dotted --> complete :datum */
  271. if (eq(type,S(simple_argument_list_dotted))) {
  272. pushSTACK(S(Kexpected_type)); pushSTACK(S(list)); /* :expected-type 'LIST */
  273. pushSTACK(S(Kdatum)); pushSTACK(BEFORE(stackptr)); /* :datum ... */
  274. argcount += 4;
  275. }
  276. /* package-error --> complete :package */
  277. if (eq(type,S(simple_package_error))) {
  278. pushSTACK(S(Kpackage)); pushSTACK(BEFORE(stackptr)); /* :package ... */
  279. argcount += 2;
  280. }
  281. /* print-not-readable --> complete :object */
  282. if (eq(type,S(simple_print_not_readable))) {
  283. pushSTACK(S(Kobject)); pushSTACK(BEFORE(stackptr)); /* :object */
  284. argcount += 2;
  285. }
  286. /* stream-error, reader-error, end-of-file --> complete :stream */
  287. if (eq(type,S(simple_stream_error))
  288. || eq(type,S(simple_reader_error))
  289. || eq(type,S(simple_end_of_file))) {
  290. pushSTACK(S(Kstream)); pushSTACK(BEFORE(stackptr)); /* :stream ... */
  291. argcount += 2;
  292. }
  293. /* file-error --> complete :pathname */
  294. if (eq(type,S(simple_file_error))) {
  295. pushSTACK(S(Kpathname)); pushSTACK(BEFORE(stackptr)); /* :pathname ... */
  296. argcount += 2;
  297. }
  298. /* source-program-error --> complete :detail */
  299. if (eq(type,S(simple_source_program_error))) {
  300. pushSTACK(S(Kdetail)); pushSTACK(BEFORE(stackptr)); /* :detail ... */
  301. argcount += 2;
  302. }
  303. funcall(S(coerce_to_condition),argcount); /* SYS::COERCE-TO-CONDITION */
  304. set_args_end_pointer(stackptr);
  305. if (start_driver_p)
  306. signal_and_debug(value1);
  307. }
  308. }
  309. }
  310. /* helper -- see doc for error() */
  311. local void prepare_error (condition_t errortype, const char* errorstring,
  312. bool start_driver_p)
  313. { /* the common part of error(), check_value() &c */
  314. begin_error(); /* start error message */
  315. if (!nullp(STACK_3)) { /* *ERROR-HANDLER* = NIL, SYS::*USE-CLCS* /= NIL ? */
  316. /* choose error-type-symbol for errortype: */
  317. var object sym = S(simple_condition); /* first error-type */
  318. sym = objectplus(sym,
  319. (soint)(sizeof(*TheSymbol(sym))
  320. <<(oint_addr_shift-addr_shift))
  321. * (uintL)errortype);
  322. STACK_3 = sym;
  323. }
  324. end_error(write_errorstring(errorstring),start_driver_p); /* finish */
  325. }
  326. /* Error message with Errorstring. Does not return.
  327. error(errortype,errorstring);
  328. > errortype: condition type
  329. > errorstring: Constant ASCIZ-string, in UTF-8 Encoding.
  330. At each tilde-S a LISP-object is taken from STACK and printed instead of
  331. the tilde-S.
  332. > on the STACK: initialization values for the condition,
  333. according to errortype */
  334. nonreturning_function(global, error, (condition_t errortype,
  335. const char* errorstring)) {
  336. prepare_error(errortype,errorstring,true); /* finish error message */
  337. /* there is no point in using the condition system here:
  338. we will get into an infinite loop reporting the error */
  339. fprintf(stderr,"[%s:%d] cannot handle the fatal error due to a fatal error in the fatal error handler!\n",__FILE__,__LINE__);
  340. abort();
  341. /* NOTREACHED; */
  342. }
  343. /* Report an error and try to recover by asking the user to supply a value.
  344. check_value(errortype,errorstring);
  345. > errortype: condition-type
  346. > errorstring: constant ASCIZ-String, in UTF-8 Encoding.
  347. At every tilde-S, a LISP-object is taken from the STACK and printed
  348. instead of the tilde-S.
  349. > on the STACK: PLACE (form to be shown to the user) or NIL, then
  350. the initial values for the Condition, depending on error-type
  351. < value1, value2: return values from CHECK-VALUE:
  352. value1 = value supplied by the user,
  353. value2 = indicates whether PLACE should be filled
  354. < STACK: cleaned up
  355. can trigger GC */
  356. global maygc void check_value (condition_t errortype, const char* errorstring)
  357. {
  358. prepare_error(errortype,errorstring,nullpSv(use_clcs));
  359. /* if SYS::*USE-CLCS* /= NIL, use CHECK-VALUE */
  360. pushSTACK(value1); /* place is already on the stack! */
  361. funcall(S(check_value),2);
  362. }
  363. /* Report an error and try to recover by asking the user to choose among some
  364. alternatives.
  365. correctable_error(errortype,errorstring);
  366. > errortype: condition-type
  367. > errorstring: constant ASCIZ-String, in UTF-8 Encoding.
  368. At every tilde-S, a LISP-object is taken from the STACK and printed
  369. instead of the tilde-S.
  370. > on the STACK: list of alternatives
  371. ((restart-name restart-help-string . value-returned-by-the-restart)*), then
  372. the initial values for the Condition, depending on error-type
  373. < value1: return value from CORRECTABLE-ERROR, one of the CDDRs of the
  374. alternatives
  375. < STACK: cleaned up
  376. can trigger GC */
  377. global maygc void correctable_error (condition_t errortype, const char* errorstring)
  378. {
  379. prepare_error(errortype,errorstring,nullpSv(use_clcs));
  380. /* if SYS::*USE-CLCS* /= NIL, use CORRECTABLE-ERROR */
  381. pushSTACK(value1); /* options are already on the stack! */
  382. funcall(S(correctable_error),2);
  383. }
  384. #undef OS_error
  385. #undef OS_file_error
  386. #undef OS_filestream_error
  387. #ifdef UNIX
  388. /* Define OS_error, OS_file_error. */
  389. #include "errunix.c"
  390. #else
  391. /* Define just ANSIC_error. */
  392. #define OS_error ANSIC_error
  393. #define OS_error_internal ANSIC_error_internal
  394. #include "errunix.c"
  395. #undef OS_error_internal
  396. #undef OS_error
  397. #endif /* UNIX */
  398. #ifdef WIN32_NATIVE
  399. #include "errwin32.c"
  400. #endif
  401. /* Just like OS_error, but takes a channel stream and signals a FILE-ERROR.
  402. OS_filestream_error(stream);
  403. > stream: a channel stream
  404. > end_system_call() already called */
  405. nonreturning_function(global, OS_filestream_error, (object stream)) {
  406. if (streamp(stream) && TheStream(stream)->strmtype == strmtype_file
  407. && !nullp(TheStream(stream)->strm_file_truename)) {
  408. OS_file_error(TheStream(stream)->strm_file_truename);
  409. } else {
  410. OS_error();
  411. }
  412. }
  413. LISPFUN(error,seclass_default,1,0,rest,nokey,0,NIL)
  414. /* (ERROR errorstring {expr})
  415. Does not return.
  416. (defun error (errorstring &rest args)
  417. (if (or *error-handler* (not *use-clcs*))
  418. (progn
  419. (if *error-handler*
  420. (apply *error-handler* nil errorstring args)
  421. (progn
  422. (fresh-line *error-output*)
  423. (write-string "*** - " *error-output*)
  424. (apply #'format *error-output* errorstring args)
  425. (elastic-newline *error-output*)))
  426. (funcall *break-driver* nil))
  427. (let ((condition (coerce-to-condition errorstring args 'error
  428. 'simple-error)))
  429. (signal condition)
  430. (invoke-debugger condition)))) */
  431. {
  432. if (!nullpSv(error_handler) || nullpSv(use_clcs)) {
  433. begin_error(); /* start error message */
  434. rest_args_pointer skipSTACKop 1; /* pointer to the arguments */
  435. if (nullp(STACK_1)) {
  436. /* write error message:
  437. (FORMAT *ERROR-OUTPUT* errorstring {expr})
  438. (ELASTIC-NEWLINE *ERROR-OUTPUT*) */
  439. var object stream = STACK_0;
  440. skipSTACK(4);
  441. pushSTACK(stream);
  442. pushSTACK(stream);
  443. {
  444. var gcv_object_t* ptr = rest_args_pointer;
  445. var uintC count;
  446. dotimespC(count,1+argcount, { pushSTACK(NEXT(ptr)); } );
  447. }
  448. funcall(S(format),2+argcount);
  449. funcall(L(elastic_newline),1);
  450. } else {
  451. /* write error message:
  452. ({handler} nil errorstring {expr}) */
  453. var object fun = STACK_1;
  454. skipSTACK(4);
  455. pushSTACK(NIL);
  456. {
  457. var gcv_object_t* ptr = rest_args_pointer;
  458. var uintC count;
  459. dotimespC(count,1+argcount, { pushSTACK(NEXT(ptr)); } );
  460. }
  461. funcall(fun,2+argcount);
  462. }
  463. /* finish error message, cf. end_error(): */
  464. dynamic_unbind(S(recursive_error_count)); /* no error message output is active */
  465. set_args_end_pointer(rest_args_pointer); /* clean up STACK */
  466. break_driver(false); /* call break-driver (does not return) */
  467. } else {
  468. {
  469. var object arguments = listof(argcount);
  470. pushSTACK(arguments);
  471. }
  472. pushSTACK(S(error));
  473. pushSTACK(S(simple_error));
  474. funcall(S(coerce_to_condition),4); /* (SYS::COERCE-TO-CONDITION ...) */
  475. signal_and_debug(value1);
  476. }
  477. NOTREACHED;
  478. }
  479. /* (SYSTEM::%DEFCLCS error-types)
  480. sets the data needed for ERROR-OF-TYPE. */
  481. LISPFUNN(defclcs,1)
  482. {
  483. O(error_types) = popSTACK();
  484. VALUES0;
  485. }
  486. /* Converts a condition type into the corresponding Simple-Condition. */
  487. local object convert_simple_condition (object type) {
  488. /* traverse vector O(error_types) like an Alist: */
  489. var object v = O(error_types);
  490. var uintL count = Svector_length(v);
  491. if (count > 0) {
  492. var gcv_object_t* ptr = &TheSvector(v)->data[0];
  493. dotimespL(count,count, {
  494. if (eq(type,Car(*ptr)))
  495. return Cdr(*ptr);
  496. ptr++;
  497. });
  498. }
  499. return type; /* not found -> leave type unchanged */
  500. }
  501. LISPFUN(cerror_of_type,seclass_default,3,0,rest,nokey,0,NIL)
  502. /* (SYSTEM::CERROR-OF-TYPE continue-format-string type {keyword value}*
  503. error-format-string {arg}*)
  504. (defun cerror-of-type (continue-format-string type &rest arguments)
  505. (let ((keyword-arguments '()))
  506. (loop
  507. (unless (and (consp arguments) (symbolp (car arguments))) (return))
  508. (push (pop arguments) keyword-arguments)
  509. (push (pop arguments) keyword-arguments))
  510. (setq keyword-arguments (nreverse keyword-arguments))
  511. (let ((error-format-string (first arguments))
  512. (args (rest arguments)))
  513. (apply #'cerror
  514. continue-format-string
  515. (if (or *error-handler* (not *use-clcs*))
  516. error-format-string
  517. (apply #'coerce-to-condition error-format-string args
  518. 'cerror (convert-simple-condition type) keyword-arguments))
  519. args)))) */
  520. {
  521. var gcv_object_t* cfstring_ = &Next(rest_args_pointer STACKop 3);
  522. var uintC keyword_argcount = 0;
  523. rest_args_pointer skipSTACKop 1; /* pointer to the arguments behind type */
  524. while (argcount>=2) {
  525. var object next_arg = Next(rest_args_pointer); /* next argument */
  526. if (!symbolp(next_arg)) /* keyword? */
  527. break;
  528. rest_args_pointer skipSTACKop -2; argcount -= 2; keyword_argcount += 2;
  529. }
  530. /* next argument is hopefully a string. */
  531. if (!nullpSv(error_handler) || nullpSv(use_clcs)) {
  532. /* the type and the keyword-arguments are ignored. */
  533. BEFORE(rest_args_pointer) = *cfstring_;
  534. funcall(S(cerror),argcount+2);
  535. skipSTACK(keyword_argcount+1);
  536. } else {
  537. var object arguments = listof(argcount);
  538. /* stack layout: continue-format-string, type, {keyword, value}*,
  539. errorstring.
  540. rearrange the stack a little bit: */
  541. var object errorstring = STACK_0;
  542. pushSTACK(NIL); pushSTACK(NIL); pushSTACK(NIL);
  543. {
  544. var gcv_object_t* ptr2 = args_end_pointer;
  545. var gcv_object_t* ptr1 = ptr2 STACKop 4;
  546. var uintC count;
  547. dotimesC(count,keyword_argcount, { BEFORE(ptr2) = BEFORE(ptr1); } );
  548. BEFORE(ptr2) = convert_simple_condition(BEFORE(ptr1));
  549. BEFORE(ptr2) = S(cerror);
  550. BEFORE(ptr2) = arguments;
  551. BEFORE(ptr2) = errorstring;
  552. BEFORE(ptr2) = arguments;
  553. }
  554. /* stack layout: continue-format-string, arguments, errorstring, args,
  555. CERROR, type, {keyword, value}*. */
  556. funcall(S(coerce_to_condition),4+keyword_argcount); /* (SYS::COERCE-TO-CONDITION ...) */
  557. /* stack layout: continue-format-string, arguments. */
  558. arguments = STACK_0;
  559. STACK_0 = value1;
  560. apply(S(cerror),2,arguments); /* (CERROR continue-format-string condition ...) */
  561. }
  562. }
  563. LISPFUN(error_of_type,seclass_default,2,0,rest,nokey,0,NIL)
  564. /* (SYSTEM::ERROR-OF-TYPE type {keyword value}* errorstring {expr}*)
  565. does not return.
  566. (defun error-of-type (type &rest arguments)
  567. ;; split off keyword arguments from the &rest arguments:
  568. (let ((keyword-arguments '()))
  569. (loop
  570. (unless (and (consp arguments) (symbolp (car arguments))) (return))
  571. (push (pop arguments) keyword-arguments)
  572. (push (pop arguments) keyword-arguments))
  573. (setq keyword-arguments (nreverse keyword-arguments))
  574. (let ((errorstring (first arguments))
  575. (args (rest arguments)))
  576. (if (or *error-handler* (not *use-clcs*))
  577. (progn
  578. (if *error-handler*
  579. (apply *error-handler* nil errorstring args)
  580. (progn
  581. (fresh-line *error-output*)
  582. (write-string "*** - " *error-output*)
  583. (apply #'format *error-output* errorstring args)
  584. (elastic-newline *error-output*)))
  585. (funcall *break-driver* nil))
  586. (let ((condition
  587. (apply #'coerce-to-condition errorstring args
  588. 'error (convert-simple-condition type)
  589. keyword-arguments)))
  590. (signal condition)
  591. (invoke-debugger condition)))))) */
  592. {
  593. var uintC keyword_argcount = 0;
  594. rest_args_pointer skipSTACKop 1; /* pointer to the arguments behind type */
  595. while (argcount>=2) {
  596. var object next_arg = Next(rest_args_pointer); /* next argument */
  597. if (!symbolp(next_arg)) /* keyword? */
  598. break;
  599. rest_args_pointer skipSTACKop -2; argcount -= 2; keyword_argcount += 2;
  600. }
  601. /* next argument is hopefully a string. */
  602. if (!nullpSv(error_handler) || nullpSv(use_clcs)) {
  603. /* the type and the keyword-arguments are ignored. */
  604. begin_error(); /* start error message */
  605. if (nullp(STACK_1)) {
  606. /* write error message:
  607. (FORMAT *ERROR-OUTPUT* errorstring {expr})
  608. (ELASTIC-NEWLINE *ERROR-OUTPUT*) */
  609. var object stream = STACK_0;
  610. skipSTACK(4);
  611. pushSTACK(stream);
  612. pushSTACK(stream);
  613. {
  614. var gcv_object_t* ptr = rest_args_pointer;
  615. var uintC count;
  616. dotimespC(count,1+argcount, { pushSTACK(NEXT(ptr)); } );
  617. }
  618. funcall(S(format),2+argcount);
  619. funcall(L(elastic_newline),1);
  620. } else {
  621. /* write error message:
  622. ({handler} nil errorstring {expr}) */
  623. var object fun = STACK_1;
  624. skipSTACK(4);
  625. pushSTACK(NIL);
  626. {
  627. var gcv_object_t* ptr = rest_args_pointer;
  628. var uintC count;
  629. dotimespC(count,1+argcount, { pushSTACK(NEXT(ptr)); } );
  630. }
  631. funcall(fun,2+argcount);
  632. }
  633. /* finish error message, cf. end_error(): */
  634. dynamic_unbind(S(recursive_error_count)); /* no error message output is active */
  635. set_args_end_pointer(rest_args_pointer); /* clean up STACK */
  636. break_driver(false); /* call break-driver (does not return) */
  637. } else {
  638. var object arguments = listof(argcount);
  639. /* stack layout: type, {keyword, value}*, errorstring.
  640. rearrange the stack a little bit: */
  641. var object errorstring = STACK_0;
  642. pushSTACK(NIL); pushSTACK(NIL);
  643. {
  644. var gcv_object_t* ptr2 = args_end_pointer;
  645. var gcv_object_t* ptr1 = ptr2 STACKop 3;
  646. var uintC count;
  647. dotimesC(count,keyword_argcount, { BEFORE(ptr2) = BEFORE(ptr1); } );
  648. BEFORE(ptr2) = convert_simple_condition(BEFORE(ptr1));
  649. BEFORE(ptr2) = S(error);
  650. BEFORE(ptr2) = arguments;
  651. BEFORE(ptr2) = errorstring;
  652. }
  653. /* stack layout: errorstring, args, ERROR, type, {keyword, value}*. */
  654. funcall(S(coerce_to_condition),4+keyword_argcount); /* (SYS::COERCE-TO-CONDITION ...) */
  655. signal_and_debug(value1);
  656. }
  657. NOTREACHED;
  658. }
  659. LISPFUNN(invoke_debugger,1)
  660. /* (INVOKE-DEBUGGER condition), CLtL2 p. 915
  661. does not return.
  662. (defun invoke-debugger (condition)
  663. (when *debugger-hook*
  664. (let ((debugger-hook *debugger-hook*)
  665. (*debugger-hook* nil))
  666. (funcall debugger-hook condition debugger-hook)))
  667. (funcall *break-driver* nil condition t)) */
  668. {
  669. var object hook = Symbol_value(S(debugger_hook));
  670. if (!nullp(hook)) {
  671. var object condition = STACK_0;
  672. dynamic_bind(S(debugger_hook),NIL); /* bind *DEBUGGER-HOOK* to NIL */
  673. pushSTACK(condition); pushSTACK(hook); funcall(hook,2); /* call Debugger-Hook */
  674. dynamic_unbind(S(debugger_hook));
  675. }
  676. /* *BREAK-DRIVER* can be assumed here as /= NIL. */
  677. pushSTACK(NIL); pushSTACK(STACK_(0+1)); pushSTACK(T);
  678. funcall(Symbol_value(S(break_driver)),3); /* call break-driver */
  679. reset(1); /* returns unexpectedly -> back to the next loop */
  680. NOTREACHED;
  681. }
  682. /* UP: Executes a break-loop because of keyboard interrupt.
  683. > STACK_0 : calling function
  684. changes STACK, can trigger GC */
  685. global maygc void tast_break (void)
  686. {
  687. cancel_interrupts();
  688. #if defined(HAVE_SIGNALS) && defined(SIGPIPE)
  689. writing_to_subprocess = false;
  690. #endif
  691. if (!nullpSv(error_handler) || nullpSv(use_clcs)) {
  692. /* simulate begin_error(), 7 elements on the STACK: */
  693. pushSTACK(NIL); pushSTACK(NIL); pushSTACK(NIL);
  694. pushSTACK(NIL); pushSTACK(NIL); pushSTACK(NIL);
  695. pushSTACK(var_stream(S(debug_io),strmflags_wr_ch_B)); /* Stream *DEBUG-IO* */
  696. fresh_line(&STACK_0); /* new line */
  697. write_sstring(&STACK_0,O(error_string1)); /* print "*** - " */
  698. /* print string, consume caller names, clean up STACK: */
  699. set_args_end_pointer(write_errorstring(GETTEXT("~S: User break")));
  700. break_driver(true); /* call break-driver */
  701. } else {
  702. pushSTACK(CLSTEXT("Continue execution"));
  703. pushSTACK(S(simple_interrupt_condition)); /* SYSTEM::[SIMPLE-]INTERRUPT-CONDITION */
  704. pushSTACK(CLSTEXT("~S: User break"));
  705. pushSTACK(STACK_(0+3)); /* caller */
  706. funcall(L(cerror_of_type),4); /* (SYS::CERROR-OF-TYPE "..." 'SYSTEM::[SIMPLE-]INTERRUPT-CONDITION "..." caller) */
  707. skipSTACK(1);
  708. }
  709. }
  710. LISPFUN(clcs_signal,seclass_default,1,0,rest,nokey,0,NIL)
  711. /* (SIGNAL datum {arg}*), CLtL2 p. 888
  712. (defun signal (datum &rest arguments)
  713. (let ((condition ; CLtL2 p. 918 specifies this
  714. (coerce-to-condition datum arguments 'signal
  715. 'simple-condition)))
  716. (when (typep condition *break-on-signals*)
  717. ; Enter the debugger prior to signalling the condition
  718. (restart-case (invoke-debugger condition)
  719. (CONTINUE ())))
  720. (invoke-handlers condition)
  721. nil)) */
  722. {
  723. {
  724. var object arguments = listof(argcount);
  725. pushSTACK(arguments);
  726. }
  727. pushSTACK(S(clcs_signal));
  728. pushSTACK(S(simple_condition));
  729. funcall(S(coerce_to_condition),4); /* (SYS::COERCE-TO-CONDITION ...) */
  730. pushSTACK(value1); /* save condition */
  731. pushSTACK(value1); pushSTACK(Symbol_value(S(break_on_signals)));
  732. funcall(S(safe_typep),2); /* (SYS::SAFE-TYPEP condition *BREAK-ON-SIGNALS*) */
  733. if (!nullp(value1)) {
  734. /* call break-driver: (funcall *break-driver* t condition t)
  735. *BREAK-DRIVER* can be assumed here as /= NIL . */
  736. pushSTACK(T); pushSTACK(STACK_(0+1)); pushSTACK(T);
  737. funcall(Symbol_value(S(break_driver)),3);
  738. }
  739. var object condition = popSTACK(); /* condition back */
  740. /* (CATCH 'SYS::DONE-SIGNALING ...). This can be used by handlers to override
  741. all other applicable handlers.
  742. Build CATCH frame: */
  743. pushSTACK(S(done_signaling));
  744. var gcv_object_t* top_of_frame = STACK STACKop 1; /* pointer above frame */
  745. var sp_jmp_buf returner; /* memorize return point */
  746. finish_entry_frame(CATCH,returner,, goto catch_return; );
  747. /* Call handlers: */
  748. invoke_handlers(condition);
  749. catch_return: /* we jump to this label, if the catch-frame built
  750. above has caught a throw. */
  751. skipSTACK(3); /* unwind CATCH-frame */
  752. VALUES1(NIL);
  753. }
  754. /* check_classname(obj,type)
  755. > obj: an object
  756. > classname: a symbol expected to name a class with "proper name" classname
  757. < result: an object of the given type, either the same as obj or a replacement
  758. can trigger GC */
  759. global maygc object check_classname (object obj, object type) {
  760. while (!typep_classname(obj,type)) {
  761. pushSTACK(type); /* save type */
  762. pushSTACK(NIL); /* no PLACE */
  763. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  764. pushSTACK(type); /* TYPE-ERROR slot EXPECTED-TYPE */
  765. pushSTACK(type); pushSTACK(obj);
  766. pushSTACK(TheSubr(subr_self)->name);
  767. check_value(type_error,GETTEXT("~S: ~S is not of type ~S"));
  768. obj = value1; type = popSTACK();
  769. }
  770. return obj;
  771. }
  772. #ifdef FOREIGN
  773. /* check_fpointer_replacement(obj,restart_p)
  774. > obj: an object
  775. > restart_p: flag whether to allow entering a replacement
  776. < result: a valid foreign pointer, either the same as obj or a replacement
  777. can trigger GC */
  778. global maygc object check_fpointer_replacement (object obj, bool restart_p) {
  779. for (;;) {
  780. if (!fpointerp(obj)) {
  781. pushSTACK(NIL); /* no PLACE */
  782. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  783. pushSTACK(S(foreign_pointer)); /* TYPE-ERROR slot EXPECTED-TYPE */
  784. pushSTACK(S(foreign_pointer)); pushSTACK(obj);
  785. pushSTACK(TheSubr(subr_self)->name);
  786. if (restart_p)
  787. check_value(type_error,GETTEXT("~S: ~S is not a ~S"));
  788. else
  789. error(type_error,GETTEXT("~S: ~S is not a ~S"));
  790. obj = value1;
  791. continue;
  792. }
  793. if (!fp_validp(TheFpointer(obj))) {
  794. pushSTACK(NIL); /* no PLACE */
  795. pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
  796. if (restart_p)
  797. check_value(error_condition,GETTEXT("~S: ~S comes from a previous Lisp session and is invalid"));
  798. else
  799. error(error_condition,GETTEXT("~S: ~S comes from a previous Lisp session and is invalid"));
  800. obj = value1;
  801. continue;
  802. }
  803. break;
  804. }
  805. return obj;
  806. }
  807. #endif
  808. /* error-message, if an object is not a list.
  809. error_list(obj);
  810. > obj: non-list */
  811. nonreturning_function(global, error_list, (object obj)) {
  812. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  813. pushSTACK(S(list)); /* TYPE-ERROR slot EXPECTED-TYPE */
  814. pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
  815. error(type_error,GETTEXT("~S: ~S is not a list"));
  816. }
  817. /* define a global check_TYPE_replacement function
  818. > name: type name
  819. > expected_type: object O(...)
  820. > test: test for the acceptability of the replacement value
  821. > error_message: C string GETTEXT(...) */
  822. #define MAKE_CHECK_REPLACEMENT(typename,expected_type,test,error_message) \
  823. global maygc object check_##typename##_replacement (object obj) { \
  824. do { \
  825. pushSTACK(NIL); /* no PLACE */ \
  826. pushSTACK(obj); /* TYPE-ERROR slot DATUM */ \
  827. pushSTACK(expected_type); /* TYPE-ERROR slot EXPECTED-TYPE */ \
  828. pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name); \
  829. check_value(type_error,error_message); \
  830. obj = value1; \
  831. } while (!test(obj)); \
  832. return obj; \
  833. }
  834. /* check_list_replacement(obj)
  835. > obj: not a list
  836. < result: a list, a replacement
  837. can trigger GC */
  838. MAKE_CHECK_REPLACEMENT(list,S(list),listp,GETTEXT("~S: ~S is not a list"))
  839. /* Error message, if an object isn't a proper list because it is dotted.
  840. error_proper_list_dotted(caller,obj);
  841. > caller: the caller (a symbol)
  842. > obj: end of the list, non-list */
  843. nonreturning_function(global, error_proper_list_dotted, (object caller, object obj))
  844. {
  845. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  846. pushSTACK(O(type_proper_list)); /* TYPE-ERROR slot EXPECTED-TYPE */
  847. pushSTACK(obj); pushSTACK(caller);
  848. error(type_error,GETTEXT("~S: A proper list must not end with ~S"));
  849. }
  850. /* Error message, if an object isn't a proper list because it is circular.
  851. error_proper_list_circular(caller,obj);
  852. > caller: the caller (a symbol)
  853. > obj: circular list */
  854. nonreturning_function(global, error_proper_list_circular, (object caller, object obj))
  855. {
  856. dynamic_bind(S(print_circle),T); /* bind *PRINT-CIRCLE* to T */
  857. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  858. pushSTACK(O(type_proper_list)); /* TYPE-ERROR slot EXPECTED-TYPE */
  859. pushSTACK(obj); pushSTACK(caller);
  860. error(type_error,GETTEXT("~S: A proper list must not be circular: ~S"));
  861. }
  862. /* check_symbol_replacement(obj)
  863. > obj: not a symbol
  864. < result: a symbol, a replacement
  865. can trigger GC */
  866. global maygc object check_symbol_replacement (object obj) {
  867. do {
  868. var object caller = subr_self;
  869. caller = (subrp(caller) ? TheSubr(caller)->name : TheFsubr(caller)->name);
  870. pushSTACK(NIL); /* no PLACE */
  871. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  872. pushSTACK(S(symbol)); /* TYPE-ERROR slot EXPECTED-TYPE */
  873. pushSTACK(obj); pushSTACK(caller);
  874. check_value(type_error,GETTEXT("~S: ~S is not a symbol"));
  875. obj = value1;
  876. } while (!symbolp(obj));
  877. return obj;
  878. }
  879. /* check_symbol_non_constant_replacement(obj)
  880. > obj: not a non-constant symbol
  881. > caller: a symbol
  882. < result: a non-constant symbol, a replacement
  883. can trigger GC */
  884. global maygc object check_symbol_non_constant_replacement (object obj, object caller)
  885. {
  886. for (;;) {
  887. obj = check_symbol(obj);
  888. if (constant_var_p(TheSymbol(obj))) {
  889. pushSTACK(NIL); /* no PLACE */
  890. pushSTACK(obj); /* SOURCE-PROGRAM-ERROR slot DETAIL */
  891. pushSTACK(obj); pushSTACK(caller);
  892. check_value(source_program_error,
  893. GETTEXT("~S: ~S is a constant, may not be used as a variable"));
  894. obj = value1;
  895. }
  896. break;
  897. }
  898. return obj;
  899. }
  900. /* UP: signal an error if a non-symbol was declared special
  901. returns the symbol
  902. can trigger GC */
  903. global maygc object check_symbol_special (object obj, object caller)
  904. {
  905. while (!symbolp(obj)) {
  906. pushSTACK(caller);
  907. pushSTACK(NIL); /* no PLACE */
  908. pushSTACK(obj); /* SOURCE-PROGRAM-ERROR slot DETAIL */
  909. pushSTACK(S(special)); pushSTACK(obj); pushSTACK(caller);
  910. check_value(source_program_error,
  911. GETTEXT("~S: ~S is not a symbol, cannot be declared ~S"));
  912. caller = popSTACK();
  913. obj = value1;
  914. }
  915. return obj;
  916. }
  917. /* UP: make sure that the symbol does not name a global symbol-macro
  918. return the symbol
  919. can trigger GC */
  920. global maygc object check_symbol_not_symbol_macro (object symbol) {
  921. symbol = check_symbol(symbol);
  922. if (symmacro_var_p(TheSymbol(symbol))) {
  923. pushSTACK(symbol); /* save */
  924. pushSTACK(NIL); /* 4 continue-format-string */
  925. pushSTACK(S(simple_program_error)); /* 3 error-type */
  926. pushSTACK(NIL); /* 2 error-format-string */
  927. pushSTACK(TheSubr(subr_self)->name); /* 1 */
  928. pushSTACK(symbol); /* 0 */
  929. /* CLSTEXT "can trigger GC", so it cannot be called until
  930. all the arguments have been already pushed on the STACK */
  931. STACK_4 = CLSTEXT("Remove the global SYMBOL-MACRO definition");
  932. if (eq(subr_self,L(proclaim)))
  933. STACK_2 = CLSTEXT("~S: attempting to turn ~S into a SPECIAL variable, but it is already a global SYMBOL-MACRO.");
  934. else if (eq(subr_self,L(proclaim_constant)))
  935. STACK_2 = CLSTEXT("~S: attempting to turn ~S into a constant, but it is already a global SYMBOL-MACRO.");
  936. else STACK_2 = CLSTEXT("~S: Interning ~S into the KEYWORD package would turn it into a constant, but it is already a global SYMBOL-MACRO.");
  937. funcall(L(cerror_of_type),5);
  938. /* continue restart ==> remove SYMBOL-MACRO definition */
  939. pushSTACK(STACK_0); /* save symbol */
  940. clear_symmacro_flag(TheSymbol(STACK_0/*symbol*/));
  941. pushSTACK(S(symbolmacro)); funcall(L(remprop),2);
  942. symbol = popSTACK();
  943. }
  944. return symbol;
  945. }
  946. /* UP: make sure that the symbol does not name a global special variable
  947. return the symbol
  948. can trigger GC */
  949. global maygc object check_symbol_not_global_special (object symbol) {
  950. symbol = check_symbol(symbol);
  951. if (keywordp(symbol)) {
  952. pushSTACK(symbol); pushSTACK(TheSubr(subr_self)->name);
  953. error(program_error,
  954. GETTEXT("~S: the symbol ~S names a global special variable"));
  955. }
  956. if (special_var_p(TheSymbol(symbol))) {
  957. pushSTACK(symbol); /* save */
  958. pushSTACK(NIL); /* 4 continue-format-string */
  959. pushSTACK(S(simple_program_error)); /* 3 error-type */
  960. pushSTACK(NIL); /* 2 error-format-string */
  961. pushSTACK(TheSubr(subr_self)->name); /* 1 */
  962. pushSTACK(symbol); /* 0 */
  963. /* CLSTEXT "can trigger GC", so it cannot be called until
  964. all the arguments have been already pushed on the STACK */
  965. STACK_4 = CLSTEXT("Remove the global SPECIAL variable binding");
  966. STACK_2 = CLSTEXT("~S: the symbol ~S names a global SPECIAL variable");
  967. funcall(L(cerror_of_type),5);
  968. /* continue restart ==> remove the global SPECIAL binding */
  969. symbol = popSTACK();
  970. Symbol_value(symbol) = unbound;
  971. clear_special_flag(TheSymbol(symbol));
  972. clear_const_flag(TheSymbol(symbol));
  973. }
  974. return symbol;
  975. }
  976. /* error-message, if an object is not a simple-vector.
  977. error_no_svector(caller,obj);
  978. > caller: caller (a symbol)
  979. > obj: non-Svector */
  980. nonreturning_function(global, error_no_svector, (object caller, object obj))
  981. {
  982. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  983. pushSTACK(S(simple_vector)); /* TYPE-ERROR slot EXPECTED-TYPE */
  984. pushSTACK(S(simple_vector)); pushSTACK(obj); pushSTACK(caller);
  985. error(type_error,GETTEXT("~S: ~S is not a ~S"));
  986. }
  987. /* error-message, if an object is not a vector.
  988. error_vector(obj);
  989. > obj: non-vector */
  990. nonreturning_function(global, error_vector, (object obj)) {
  991. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  992. pushSTACK(S(vector)); /* TYPE-ERROR slot EXPECTED-TYPE */
  993. pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
  994. error(type_error,GETTEXT("~S: ~S is not a vector"));
  995. }
  996. /* check_array_replacement(obj)
  997. > obj: not an array
  998. < result: an array, a replacement
  999. can trigger GC */
  1000. MAKE_CHECK_REPLACEMENT(array,S(array),arrayp,
  1001. GETTEXT("~S: argument ~S is not an array"))
  1002. /* check_vector_replacement(obj)
  1003. > obj: not an vector
  1004. < result: an vector, a replacement
  1005. can trigger GC */
  1006. MAKE_CHECK_REPLACEMENT(vector,S(vector),vectorp,
  1007. GETTEXT("~S: argument ~S is not a vector"))
  1008. /* check_byte_vector_replacement(obj)
  1009. > obj: not an (ARRAY (UNSIGNED-BYTE 8) (*))
  1010. < result: an (ARRAY (UNSIGNED-BYTE 8) (*)), a replacement
  1011. can trigger GC */
  1012. global maygc object check_byte_vector_replacement (object obj) {
  1013. do {
  1014. pushSTACK(NIL); /* no PLACE */
  1015. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1016. pushSTACK(O(type_uint8_vector)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1017. pushSTACK(O(type_uint8_vector)); pushSTACK(obj);
  1018. pushSTACK(TheSubr(subr_self)->name);
  1019. check_value(type_error,GETTEXT("~S: argument ~S is not a vector of type ~S"));
  1020. obj = value1;
  1021. } while (!bit_vector_p(Atype_8Bit,obj));
  1022. return obj;
  1023. }
  1024. /* error-message, if an object is not an environment.
  1025. error_environment(obj);
  1026. > obj: non-vector */
  1027. nonreturning_function(global, error_environment, (object obj)) {
  1028. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1029. pushSTACK(O(type_svector5)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1030. pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
  1031. error(type_error,GETTEXT("~S: ~S may not be used as an environment"));
  1032. }
  1033. /* error-message, if an argument is not a Fixnum >=0 :
  1034. error_posfixnum(obj);
  1035. > obj: the erroneous argument */
  1036. nonreturning_function(global, error_posfixnum, (object obj)) {
  1037. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1038. pushSTACK(O(type_posfixnum)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1039. pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
  1040. error(type_error,GETTEXT("~S: argument ~S is not a nonnegative fixnum"));
  1041. }
  1042. /* check_posfixnum_replacement(obj)
  1043. > obj: not a fixnum >= 0
  1044. < result: a fixnum >= 0, a replacement
  1045. can trigger GC */
  1046. MAKE_CHECK_REPLACEMENT(posfixnum,O(type_posfixnum),posfixnump,
  1047. GETTEXT("~S: argument ~S is not a nonnegative fixnum"))
  1048. /* check_integer_replacement(obj)
  1049. > obj: not an integer
  1050. < result: an integer, a replacement
  1051. can trigger GC */
  1052. MAKE_CHECK_REPLACEMENT(integer,S(integer),integerp,
  1053. GETTEXT("~S: ~S is not an integer"))
  1054. /* check_pos_integer_replacement(obj)
  1055. > obj: not an integer >= 0
  1056. < result: an integer >= 0, a replacement
  1057. can trigger GC */
  1058. global maygc object check_pos_integer_replacement (object obj) {
  1059. do {
  1060. pushSTACK(NIL); /* no PLACE */
  1061. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1062. pushSTACK(O(type_posinteger)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1063. pushSTACK(obj);
  1064. pushSTACK(TheSubr(subr_self)->name);
  1065. check_value(type_error,GETTEXT("~S: ~S is not a non-negative integer"));
  1066. obj = value1;
  1067. } while (!(integerp(obj) && !R_minusp(obj)));
  1068. return obj;
  1069. }
  1070. /* error-message, if an argument is not a Character:
  1071. error_char(obj);
  1072. > obj: the erroneous argument */
  1073. nonreturning_function(global, error_char, (object obj)) {
  1074. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1075. pushSTACK(S(character)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1076. pushSTACK(obj);
  1077. pushSTACK(TheSubr(subr_self)->name);
  1078. error(type_error,GETTEXT("~S: argument ~S is not a character"));
  1079. }
  1080. /* check_char_replacement(obj)
  1081. > obj: not a character
  1082. < result: a character, a replacement
  1083. can trigger GC */
  1084. MAKE_CHECK_REPLACEMENT(char,S(character),charp,
  1085. GETTEXT("~S: argument ~S is not a character"))
  1086. /* check_string_replacement(obj)
  1087. > obj: not a string
  1088. < result: a string, a replacement
  1089. can trigger GC */
  1090. MAKE_CHECK_REPLACEMENT(string,S(string),stringp,
  1091. GETTEXT("~S: argument ~S is not a string"))
  1092. /* error-message, if an argument is not a Simple-String:
  1093. > obj: the erroneous argument */
  1094. nonreturning_function(global, error_sstring, (object obj)) {
  1095. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1096. pushSTACK(S(simple_string)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1097. pushSTACK(S(simple_string)); pushSTACK(obj);
  1098. pushSTACK(TheSubr(subr_self)->name);
  1099. error(type_error,GETTEXT("~S: argument ~S is not a ~S"));
  1100. }
  1101. /* error-message, if a Simple-String is immutable:
  1102. error_sstring_immutable(obj);
  1103. > obj: the String */
  1104. nonreturning_function(global, error_sstring_immutable, (object obj)) {
  1105. pushSTACK(obj);
  1106. error(error_condition,GETTEXT("Attempt to modify a read-only string: ~S"));
  1107. }
  1108. /* Error message, if an argument is not of type (OR STRING INTEGER).
  1109. error_string_integer(obj) */
  1110. nonreturning_function(global, error_string_integer, (object obj)) {
  1111. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1112. pushSTACK(O(type_string_integer)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1113. pushSTACK(obj); pushSTACK(TheSubr(subr_self)->name);
  1114. error(type_error,
  1115. GETTEXT("~S: argument ~S is neither a string nor an integer"));
  1116. }
  1117. /* Error message, if a string size is too big.
  1118. error_stringsize(size);
  1119. > size: the desired string length */
  1120. nonreturning_function(global, error_stringsize, (uintV size)) {
  1121. var object obj = UV_to_I(size);
  1122. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1123. pushSTACK(O(type_stringsize)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1124. pushSTACK(obj);
  1125. error(type_error,GETTEXT("string too long: desired length ~S exceeds the supported maximum length"));
  1126. }
  1127. /* error message if an argument is not a class.
  1128. error_class(caller,obj);
  1129. > obj: the erroneous argument */
  1130. nonreturning_function(global, error_class, (object obj)) {
  1131. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1132. pushSTACK(S(class)); /* CLOS:CLASS, TYPE-ERROR slot EXPECTED-TYPE */
  1133. pushSTACK(obj);
  1134. pushSTACK(TheSubr(subr_self)->name); /* function name */
  1135. error(type_error,GETTEXT("~S: ~S is not a class"));
  1136. }
  1137. /* error-message, if an argument is not a Stream:
  1138. check_stream_replacement(obj);
  1139. > obj: not a stream
  1140. < obj: a stream
  1141. can trigger GC */
  1142. MAKE_CHECK_REPLACEMENT(stream,S(stream),streamp,
  1143. GETTEXT("~S: argument ~S is not a stream"))
  1144. /* Report an error when the argument is not an encoding:
  1145. > obj: the (possibly) bad argument
  1146. > default: what to return for :DEFAULT
  1147. > keyword_p: true if the object comes from the :EXTERNAL-FORMAT argument
  1148. < result: an encoding
  1149. can trigger GC */
  1150. global maygc object check_encoding (object arg, const gcv_object_t *e_default,
  1151. bool keyword_p) {
  1152. restart:
  1153. if (!boundp(arg) || eq(arg,S(Kdefault)))
  1154. return *e_default;
  1155. if (encodingp(arg))
  1156. return arg;
  1157. #ifdef UNICODE
  1158. if (symbolp(arg) && constant_var_p(TheSymbol(arg))
  1159. && encodingp(Symbol_value(arg)))
  1160. return Symbol_value(arg);
  1161. #ifdef HAVE_GOOD_ICONV
  1162. if (stringp(arg)) { /* (make-encoding :charset arg) */
  1163. pushSTACK(arg); /* :charset */
  1164. pushSTACK(unbound); /* :line-terminator */
  1165. pushSTACK(unbound); /* :input-error-action */
  1166. pushSTACK(unbound); /* :output-error-action */
  1167. pushSTACK(unbound); /* :if-does-not-exist */
  1168. C_make_encoding();
  1169. return value1;
  1170. }
  1171. #endif
  1172. #else
  1173. /* This is a hack to get away without an error. */
  1174. if (symbolp(arg) && eq(Symbol_package(arg),O(charset_package)))
  1175. return O(default_file_encoding);
  1176. #endif
  1177. if (eq(arg,S(Kunix)) || eq(arg,S(Kmac)) || eq(arg,S(Kdos))) {
  1178. /* (make-encoding :charset default-file-encoding :line-terminator arg) */
  1179. pushSTACK(*e_default); /* :charset */
  1180. pushSTACK(arg); /* :line-terminator */
  1181. pushSTACK(unbound); /* :input-error-action */
  1182. pushSTACK(unbound); /* :output-error-action */
  1183. pushSTACK(unbound); /* :if-does-not-exist */
  1184. C_make_encoding();
  1185. return value1;
  1186. }
  1187. pushSTACK(NIL); /* no PLACE */
  1188. pushSTACK(arg); /* TYPE-ERROR slot DATUM */
  1189. pushSTACK(O(type_external_format)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1190. pushSTACK(arg);
  1191. if (keyword_p) pushSTACK(S(Kexternal_format));
  1192. pushSTACK(TheSubr(subr_self)->name);
  1193. check_value(type_error,
  1194. keyword_p ? GETTEXT("~S: illegal ~S argument ~S")
  1195. : GETTEXT("~S: argument ~S is not a character set"));
  1196. arg = value1;
  1197. goto restart;
  1198. }
  1199. /* Error when the property list has odd length
  1200. error_plist_odd(caller,plist);
  1201. > plist: bad plist */
  1202. nonreturning_function(global, error_plist_odd, (object plist)) {
  1203. pushSTACK(plist); /* TYPE-ERROR slot DATUM */
  1204. pushSTACK(S(plist)); /* TYPE-ERROR slot EXPECTED-TYPE*/
  1205. pushSTACK(plist); pushSTACK(TheSubr(subr_self)->name);
  1206. error(type_error,GETTEXT("~S: the property list ~S has an odd length"));
  1207. }
  1208. /* error-message for non-paired keyword-arguments
  1209. error_key_odd(argcount,caller);
  1210. > argcount: the number of arguments on the STACK
  1211. > caller: function */
  1212. nonreturning_function(global, error_key_odd, (uintC argcount, object caller))
  1213. {
  1214. var uintC count;
  1215. pushSTACK(NIL); pushSTACK(NIL);
  1216. for (count=0; count<argcount; count++) STACK_(count) = STACK_(count+2);
  1217. STACK_(argcount) = caller;
  1218. var object arglist = listof(argcount);
  1219. STACK_1 = arglist;
  1220. /* ANSI CL 3.5.1.6. wants a PROGRAM-ERROR here. */
  1221. error(program_error,
  1222. GETTEXT("~S: keyword arguments in ~S should occur pairwise"));
  1223. }
  1224. /* error-message for flawed keyword
  1225. error_key_notkw(kw);
  1226. > kw: Non-Symbol
  1227. > caller: function */
  1228. nonreturning_function(global, error_key_notkw, (object kw, object caller)) {
  1229. pushSTACK(kw); /* KEYWORD-ERROR slot DATUM */
  1230. pushSTACK(S(symbol)); /* KEYWORD-ERROR slot EXPECTED-TYPE */
  1231. pushSTACK(kw); pushSTACK(S(LLkey)); pushSTACK(caller);
  1232. error(keyword_error,GETTEXT("~S: ~S marker ~S is not a symbol"));
  1233. }
  1234. /* error-message for flawed keyword
  1235. error_key_badkw(fun,kw,kwlist);
  1236. > fun: function
  1237. > key: illegal keyword
  1238. > val: its value
  1239. > kwlist: list of legal keywords */
  1240. nonreturning_function(global, error_key_badkw,
  1241. (object fun, object key, object val, object kwlist)) {
  1242. pushSTACK(key); /* KEYWORD-ERROR slot DATUM */
  1243. pushSTACK(kwlist);
  1244. pushSTACK(kwlist);
  1245. pushSTACK(val);
  1246. pushSTACK(key);
  1247. pushSTACK(fun);
  1248. { /* `(MEMBER ,@kwlist) = KEYWORD-ERROR slot EXPECTED-TYPE */
  1249. var object type = allocate_cons();
  1250. Car(type) = S(member); Cdr(type) = STACK_4;
  1251. STACK_4 = type;
  1252. }
  1253. error(keyword_error,
  1254. GETTEXT("~S: illegal keyword/value pair ~S, ~S in argument list.\n"
  1255. "The allowed keywords are ~S"));
  1256. }
  1257. /* check_function_replacement(obj)
  1258. > obj: not a function
  1259. < result: a function, a replacement
  1260. can trigger GC */
  1261. global maygc object check_function_replacement (object obj) {
  1262. do {
  1263. pushSTACK(NIL); /* no PLACE */
  1264. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1265. pushSTACK(S(function)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1266. pushSTACK(obj);
  1267. pushSTACK(TheSubr(subr_self)->name);
  1268. check_value(type_error,GETTEXT("~S: ~S is not a function"));
  1269. if (symbolp(value1))
  1270. obj = Symbol_function(value1);
  1271. else if (funnamep(value1)) {
  1272. var object name = get(Car(Cdr(value1)),S(setf_function));
  1273. if (symbolp(name)) obj = Symbol_function(name);
  1274. else obj = value1;
  1275. } else if (consp(value1) && eq(Car(value1),S(lambda))) {
  1276. pushSTACK(value1); pushSTACK(S(function));
  1277. funcall(L(coerce),2);
  1278. obj = value1;
  1279. } else obj = value1;
  1280. } while (!functionp(obj));
  1281. return obj;
  1282. }
  1283. /* error if funname does not have a function definition
  1284. check_fdefinition(funname,caller)
  1285. > funname: symbol or (setf symbol)
  1286. > caller: symbol
  1287. < a function object, possibly also installed as (FDEFINITION funname)
  1288. can trigger GC */
  1289. global maygc object check_fdefinition (object funname, object caller)
  1290. {
  1291. var object name = (symbolp(funname) ? funname
  1292. : get(Car(Cdr(funname)),S(setf_function)));
  1293. var object def = (symbolp(name) ? (object)Symbol_function(name) : unbound);
  1294. var bool store_p = false;
  1295. while (!functionp(def)) {
  1296. pushSTACK(caller); pushSTACK(funname); /* save */
  1297. pushSTACK(S(quote)); pushSTACK(funname); def = listof(2);
  1298. pushSTACK(S(fdefinition)); pushSTACK(def); def = listof(2);
  1299. pushSTACK(def); /* PLACE */
  1300. pushSTACK(STACK_1/*funname*/); /* CELL-ERROR Slot NAME */
  1301. pushSTACK(STACK_0); /* funname */
  1302. pushSTACK(STACK_4); /* caller */
  1303. check_value(undefined_function,GETTEXT("~S: undefined function ~S"));
  1304. /* value2 selects the restart: 0: CONTINUE, T: STORE-VALUE, else: USE-VALUE
  1305. see also condition.lisp:check-value */
  1306. store_p = eq(value2,T);
  1307. /* this is the only place where check_value()'s second value is checked
  1308. for something other than non-NIL */
  1309. if (eq(value2,Fixnum_0)) { /* RETRY restart */
  1310. funname = STACK_0;
  1311. name = (symbolp(funname) ? funname
  1312. : get(Car(Cdr(funname)),S(setf_function)));
  1313. value1 = (symbolp(name) ? (object)Symbol_function(name) : unbound);
  1314. }
  1315. funname = popSTACK(); caller = popSTACK(); /* restore */
  1316. def = value1;
  1317. }
  1318. if (store_p) { /* STORE-VALUE restart */
  1319. name = (symbolp(funname) ? funname
  1320. : get(Car(Cdr(funname)),S(setf_function)));
  1321. if (!symbolp(name)) {
  1322. pushSTACK(Car(Cdr(funname))); /* the symbol in (setf symbol) */
  1323. pushSTACK(def); /* save new function */
  1324. pushSTACK(funname); funcall(S(get_funname_symbol),1);
  1325. pushSTACK(value1); /* save new name */
  1326. pushSTACK(value1); pushSTACK(S(setf_function)); pushSTACK(STACK_4);
  1327. funcall(L(put),3); /* (put symbol 'setf-function name) */
  1328. name = popSTACK(); def = popSTACK(); /* restore */
  1329. skipSTACK(1); /* drop symbol in (setf symbol) */
  1330. }
  1331. Symbol_function(name) = def;
  1332. }
  1333. return def;
  1334. }
  1335. /* check_funname_replacement(obj)
  1336. > errtype: type of condition to signal if obj is not a function name,
  1337. either type_error or source_program_error
  1338. > caller: a symbol
  1339. > obj: not a function name
  1340. < result: a function name, either the same as obj or a replacement
  1341. can trigger GC */
  1342. global maygc object check_funname_replacement (condition_t errtype, object caller, object obj) {
  1343. pushSTACK(caller); /* save */
  1344. do {
  1345. caller = STACK_0;
  1346. pushSTACK(NIL); /* no PLACE */
  1347. switch (errtype) {
  1348. case type_error:
  1349. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1350. pushSTACK(O(type_function_name)); /* slot EXPECTED-TYPE */
  1351. break;
  1352. case source_program_error:
  1353. pushSTACK(obj); /* SOURCE-PROGRAM-ERROR slot DETAIL */
  1354. break;
  1355. default: NOTREACHED;
  1356. }
  1357. pushSTACK(obj); pushSTACK(caller);
  1358. check_value(errtype,GETTEXT("~S: ~S is not a function name; try using a symbol instead"));
  1359. obj = value1;
  1360. } while (!funnamep(obj));
  1361. skipSTACK(1); /* drop caller */
  1362. return obj;
  1363. }
  1364. /* error-message, if an argument is a lambda-expression instead of a function:
  1365. caller: caller (a symbol)
  1366. obj: the erroneous argument */
  1367. nonreturning_function(global, error_lambda_expression,
  1368. (object caller, object obj)) {
  1369. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1370. pushSTACK(S(function)); /* TYPE-ERROR slot EXPECTED-TYPE */
  1371. pushSTACK(obj); pushSTACK(caller);
  1372. error(type_error,
  1373. GETTEXT("~S: argument ~S is not a function.\n"
  1374. "To get a function in the current environment, write (FUNCTION ...).\n"
  1375. "To get a function in the global environment, write (COERCE '... 'FUNCTION)."));
  1376. }
  1377. /* too many arguments in a function call
  1378. > caller : the function that is reporting the error
  1379. > func : the function being incorrectly called
  1380. > ngiven : the number of arguments given
  1381. < nmax : the maximum number of arguments accepted */
  1382. nonreturning_function(global, error_too_many_args,
  1383. (object caller, object func, uintL ngiven, uintL nmax)) {
  1384. pushSTACK(func);
  1385. pushSTACK(fixnum(nmax));
  1386. pushSTACK(fixnum(ngiven));
  1387. /* ANSI CL 3.5.1.3. wants a PROGRAM-ERROR here. */
  1388. if (!boundp(caller))
  1389. error(program_error,GETTEXT("EVAL/APPLY: Too many arguments (~S instead of at most ~S) given to ~S"));
  1390. else {
  1391. pushSTACK(caller);
  1392. error(program_error,GETTEXT("~S: Too many arguments (~S instead of at most ~S) given to ~S"));
  1393. }
  1394. }
  1395. /* too few arguments in a function call
  1396. > caller : the function that is reporting the error (unbound == EVAL/APPLY)
  1397. > func : the function being incorrectly called
  1398. > ngiven : the number of arguments given
  1399. < nmin : the minimum number of arguments required */
  1400. nonreturning_function(global, error_too_few_args,
  1401. (object caller, object func, uintL ngiven, uintL nmin)) {
  1402. pushSTACK(func);
  1403. pushSTACK(fixnum(nmin));
  1404. pushSTACK(fixnum(ngiven));
  1405. /* ANSI CL 3.5.1.2. wants a PROGRAM-ERROR here. */
  1406. if (!boundp(caller))
  1407. error(program_error,GETTEXT("EVAL/APPLY: Too few arguments (~S instead of at least ~S) given to ~S"));
  1408. else {
  1409. pushSTACK(caller);
  1410. error(program_error,GETTEXT("~S: Too few arguments (~S instead of at least ~S) given to ~S"));
  1411. }
  1412. }
  1413. /* error if an argument is not of a given elementary integer C type.
  1414. error_c_integer(obj);
  1415. > obj: the faulty argument
  1416. > tcode: type code: 0 for int8, 1 for int16, 2 for int32, 3 for int64
  1417. > signedp: sint or uint */
  1418. local const char* prepare_c_integer_signal (object obj, int tcode, bool signedp)
  1419. {
  1420. pushSTACK(obj); /* TYPE-ERROR slot DATUM */
  1421. pushSTACK((signedp?&O(type_sint8):&O(type_uint8))[tcode]); /*EXPECTED-TYPE*/
  1422. pushSTACK(fixnum(8<<tcode)); pushSTACK(obj);
  1423. pushSTACK(TheSubr(subr_self)->name);
  1424. return signedp
  1425. ? GETTEXT("~S: argument ~S is not an integer with at most ~S bits (including the sign bit)")
  1426. : GETTEXT("~S: argument ~S is not a nonnegative integer with at most ~S bits");
  1427. }
  1428. nonreturning_function(global, error_c_integer,
  1429. (object obj, int tcode, bool signedp)) {
  1430. error(type_error,prepare_c_integer_signal(obj,tcode,signedp));
  1431. }
  1432. /* get a replacement of a given elementary integer C type.
  1433. check_c_integer_replacement(obj)
  1434. > obj: not an integer in the range specified by tcode and signedp (see above)
  1435. < obj: an integer in the range specified by tcode and signedp
  1436. can trigger GC */
  1437. global maygc object check_c_integer_replacement (object obj, int tcode,
  1438. bool signedp) {
  1439. do {
  1440. pushSTACK(NIL); /* no PLACE */
  1441. check_value(type_error,prepare_c_integer_signal(obj,tcode,signedp));
  1442. obj = value1;
  1443. } while (!uint8_p(obj));
  1444. return obj;
  1445. }
  1446. /* error, if argument is not an integer in the range of the C type 'uint'.
  1447. check_uint_replacement(obj)
  1448. > obj: not an integer in the range of uint
  1449. < obj: an integer in the range of uint
  1450. can trigger GC */
  1451. MAKE_CHECK_REPLACEMENT(uint,
  1452. #if (int_bitsize==16)
  1453. O(type_uint16),
  1454. #else /* (int_bitsize==32) */
  1455. O(type_uint32),
  1456. #endif
  1457. uint_p,GETTEXT("~S: ~S is not an `unsigned int' number"))
  1458. /* error, if argument is not an integer in the range of the C type 'sint'.
  1459. check_sint_replacement(obj)
  1460. > obj: not an integer in the range of sint
  1461. < obj: an integer in the range of sint
  1462. can trigger GC */
  1463. MAKE_CHECK_REPLACEMENT(sint,
  1464. #if (int_bitsize==16)
  1465. O(type_sint16),
  1466. #else /* (int_bitsize==32) */
  1467. O(type_sint32),
  1468. #endif
  1469. sint_p,GETTEXT("~S: ~S is not an `int' number"))
  1470. /* error, if argument is not an integer in the range of the C type 'ulong'.
  1471. check_ulong_replacement(obj)
  1472. > obj: not an integer in the range of ulong
  1473. < obj: an integer in the range of ulong
  1474. can trigger GC */
  1475. MAKE_CHECK_REPLACEMENT(ulong,
  1476. #if (long_bitsize==32)
  1477. O(type_uint32),
  1478. #else /* (long_bitsize==64) */
  1479. O(type_uint64),
  1480. #endif
  1481. ulong_p,
  1482. GETTEXT("~S: ~S is not a `unsigned long' number"))
  1483. /* error, if argument is not an integer in the range of the C type 'slong'.
  1484. check_slong_replacement(obj)
  1485. > obj: not an integer in the range of slong
  1486. < obj: an integer in the range of slong
  1487. can trigger GC */
  1488. MAKE_CHECK_REPLACEMENT(slong,
  1489. #if (long_bitsize==32)
  1490. O(type_sint32),
  1491. #else /* (long_bitsize==64) */
  1492. O(type_sint64),
  1493. #endif
  1494. slong_p,GETTEXT("~S: ~S is not a `long' number"))
  1495. /* error, if argument is not a Single-Float.
  1496. check_ffloat_replacement(obj)
  1497. > obj: not a single-float
  1498. < obj: a single-float
  1499. can trigger GC */
  1500. MAKE_CHECK_REPLACEMENT(ffloat,S(single_float),single_float_p,
  1501. GETTEXT("~S: ~S is not a single-float"))
  1502. /* error, if argument is not a Double-Float.
  1503. check_dfloat_replacement(obj)
  1504. > obj: not a double-float
  1505. < obj: a double-float
  1506. can trigger GC */
  1507. MAKE_CHECK_REPLACEMENT(dfloat,S(double_float),double_float_p,
  1508. GETTEXT("~S: ~S is not a double-float"))