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))
25 (sb-int:/show0 "entering REPL")
27 (multiple-value-bind (reason reason-param)
32 ((and (eq reason :inspect)
33 (plusp *break-level*))
35 ((and (eq reason :pop)
36 (plusp *break-level*))
37 (return-from repl)))))))
40 "Read-Eval-Print one form"
41 ;; (See comment preceding the definition of SCRUB-CONTROL-STACK.)
44 (funcall *repl-prompt-fun* *standard-output*)
45 ;; (Should *REPL-PROMPT-FUN* be responsible for doing its own
46 ;; FORCE-OUTPUT? I can't imagine a valid reason for it not to
47 ;; be done here, so leaving it up to *REPL-PROMPT-FUN* seems
48 ;; odd. But maybe there *is* a valid reason in some
49 ;; circumstances? perhaps some deadlock issue when being driven
50 ;; by another process or something...)
51 (force-output *standard-output*))
52 (let* ((form (funcall *repl-read-form-fun*
55 (results (multiple-value-list (sb-impl::interactive-eval form))))
57 (dolist (result results)
58 ;; Don't fresh-line before a result, since newline was entered by user
59 ;; in *repl-read-form-fun*
60 (fresh-line *standard-output*)
61 (prin1 result *standard-output*)))))
63 (defun repl-fun (noprint)
64 (repl :noprint noprint :break-level 0))
66 (when (boundp 'sb-impl::*repl-fun*)
67 (setq sb-impl::*repl-fun* #'repl-fun))