X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftoplevel.lisp;h=3afa9ad6ccaf26e316189daeaac6d16952b34bb8;hb=9c1a7443146bba92c2430689981bd46c66551c35;hp=3faf43e65465f94d26145a9c26f542bcc5240646;hpb=f06a378c741965a906b6a042c9420efb9c51198f;p=sbcl.git diff --git a/src/code/toplevel.lisp b/src/code/toplevel.lisp index 3faf43e..3afa9ad 100644 --- a/src/code/toplevel.lisp +++ b/src/code/toplevel.lisp @@ -46,7 +46,7 @@ ;;; by QUIT) is caught and any final processing and return codes are ;;; handled appropriately. (defmacro handling-end-of-the-world (&body body) - (let ((caught (gensym "CAUGHT"))) + (with-unique-names (caught) `(let ((,caught (catch '%end-of-the-world (/show0 "inside CATCH '%END-OF-THE-WORLD") ,@body))) @@ -173,7 +173,7 @@ (let* ((csp (sap-int (sb!c::control-stack-pointer-sap))) (initial-offset (logand csp (1- bytes-per-scrub-unit))) (end-of-stack - (- sb!vm::*control-stack-end* sb!c:*backend-page-size*))) + (- sb!vm:*control-stack-end* sb!c:*backend-page-size*))) (labels ((scrub (ptr offset count) (declare (type system-area-pointer ptr) @@ -205,7 +205,7 @@ #!+stack-grows-downward-not-upward (let* ((csp (sap-int (sb!c::control-stack-pointer-sap))) - (end-of-stack (+ sb!vm::*control-stack-start* sb!c:*backend-page-size*)) + (end-of-stack (+ sb!vm:*control-stack-start* sb!c:*backend-page-size*)) (initial-offset (logand csp (1- bytes-per-scrub-unit)))) (labels ((scrub (ptr offset count) @@ -521,7 +521,7 @@ ;; have unwound enough stack by the time we get here that this ;; is now possible (sb!kernel::protect-control-stack-guard-page 1) - (repl :noprint noprint :break-level 0) + (funcall *repl-fun* noprint) (critically-unreachable "after REPL"))))))) ;;; Our default REPL prompt is the minimal traditional one. @@ -539,7 +539,6 @@ (quit) form))) - ;;; hooks to support customized toplevels like ACL-style toplevel ;;; from KMR on sbcl-devel 2002-12-21 (defvar *repl-read-form-fun* #'repl-read-form-fun @@ -551,42 +550,32 @@ (defvar *repl-prompt-fun* #'repl-prompt-fun "a function of one argument STREAM for the toplevel REPL to call: Prompt the user for input.") - -(defvar *noprint* nil "boolean: T if don't print prompt and output") -(defvar *break-level* 0 "current break level") -(defvar *inspect-break* nil "boolean: T if break caused by inspect") -(defvar *continuable-break* nil "boolean: T if break caused by continuable error") - -(defun repl (&key - (break-level (1+ *break-level*)) - (noprint *noprint*) - (inspect nil) - (continuable nil)) - (let ((*noprint* noprint) - (*break-level* break-level) - (*inspect-break* inspect) - (*continuable-break* continuable)) - (/show0 "entering REPL") - (loop - ;; (See comment preceding the definition of SCRUB-CONTROL-STACK.) - (scrub-control-stack) - (unless *noprint* - (funcall *repl-prompt-fun* *standard-output*) - ;; (Should *REPL-PROMPT-FUN* be responsible for doing its own - ;; FORCE-OUTPUT? I can't imagine a valid reason for it not to - ;; be done here, so leaving it up to *REPL-PROMPT-FUN* seems - ;; odd. But maybe there *is* a valid reason in some - ;; circumstances? perhaps some deadlock issue when being driven - ;; by another process or something...) - (force-output *standard-output*)) - (let* ((form (funcall *repl-read-form-fun* - *standard-input* - *standard-output*)) - (results (multiple-value-list (interactive-eval form)))) - (unless *noprint* - (dolist (result results) - (fresh-line) - (prin1 result))))))) +(defvar *repl-fun* #'repl-fun + "a function of one argument NOPRINT that provides the REPL for the system. + Assumes that *standard-input* and *standard-output* are setup.") + +(defun repl-fun (noprint) + (/show0 "entering REPL") + (loop + ;; (See comment preceding the definition of SCRUB-CONTROL-STACK.) + (scrub-control-stack) + (unless noprint + (funcall *repl-prompt-fun* *standard-output*) + ;; (Should *REPL-PROMPT-FUN* be responsible for doing its own + ;; FORCE-OUTPUT? I can't imagine a valid reason for it not to + ;; be done here, so leaving it up to *REPL-PROMPT-FUN* seems + ;; odd. But maybe there *is* a valid reason in some + ;; circumstances? perhaps some deadlock issue when being driven + ;; by another process or something...) + (force-output *standard-output*)) + (let* ((form (funcall *repl-read-form-fun* + *standard-input* + *standard-output*)) + (results (multiple-value-list (interactive-eval form)))) + (unless noprint + (dolist (result results) + (fresh-line) + (prin1 result)))))) ;;; suitable value for *DEBUGGER-HOOK* for a noninteractive Unix-y program (defun noprogrammer-debugger-hook-fun (condition old-debugger-hook)