1 (cl:defpackage :sb-aclrepl
4 (cl:in-package :sb-aclrepl)
6 (defvar *noprint* nil "boolean: T if don't print prompt and output")
7 (defvar *break-level* 0 "current break level")
8 (defvar *inspect-break* nil "boolean: T if break caused by inspect")
9 (defvar *continuable-break* nil "boolean: T if break caused by continuable error")
11 (shadowing-import '(sb-impl::scrub-control-stack
12 sb-int:*repl-prompt-fun* sb-int:*repl-read-form-fun*)
17 (break-level (1+ *break-level*))
21 (let ((*noprint* noprint)
22 (*break-level* break-level)
23 (*inspect-break* inspect)
24 (*continuable-break* continuable)
28 (*package* *package*))
29 (sb-int:/show0 "entering REPL")
31 (multiple-value-bind (reason reason-param)
36 ((and (eq reason :inspect)
37 (plusp *break-level*))
39 ((and (eq reason :pop)
40 (plusp *break-level*))
41 (return-from repl)))))))
44 "Read-Eval-Print one form"
45 ;; (See comment preceding the definition of SCRUB-CONTROL-STACK.)
48 (funcall *repl-prompt-fun* *standard-output*)
49 ;; (Should *REPL-PROMPT-FUN* be responsible for doing its own
50 ;; FORCE-OUTPUT? I can't imagine a valid reason for it not to
51 ;; be done here, so leaving it up to *REPL-PROMPT-FUN* seems
52 ;; odd. But maybe there *is* a valid reason in some
53 ;; circumstances? perhaps some deadlock issue when being driven
54 ;; by another process or something...)
55 (force-output *standard-output*))
56 (let* ((form (funcall *repl-read-form-fun*
59 (results (multiple-value-list (sb-impl::interactive-eval form))))
61 (dolist (result results)
62 ;; FIXME: Calling fresh-line before a result ensures the result starts
63 ;; on a newline, but it usually generates an empty line.
64 ;; One solution would be to have the newline's entered on the
65 ;; input stream inform the output stream that the column should be
66 ;; reset to the beginning of the line.
67 (fresh-line *standard-output*)
68 (prin1 result *standard-output*)))))
70 (defun repl-fun (noprint)
71 (repl :noprint noprint :break-level 0))
73 (when (boundp 'sb-impl::*repl-fun*)
74 (setq sb-impl::*repl-fun* #'repl-fun))