-
Notifications
You must be signed in to change notification settings - Fork 0
/
repl.lisp
42 lines (40 loc) · 1.62 KB
/
repl.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
;;;
;;; repl.lisp - implement new REPL functions for src/code/toplevel.lisp
;;;
(in-package :sb-impl)
(defmacro start-new-repl (&key (eval #'eval) noprint)
`(progn
(setf *repl-prompt-fun*
#'(lambda (stream)
(fresh-line stream)
(write-string (format nil "~A> " (package-name *package*)) stream)))
(setf *repl-read-form-fun*
#'(lambda (in out)
(when *read-suppress* (setf *read-suppress* nil))
(let* ((eof-marker (cons nil nil))
(form (read in nil eof-marker)))
(if (eq form eof-marker)
(quit)
form))))
(setf *repl-fun-generator*
(constantly
#'(lambda (noprint)
(loop
(unwind-protect
(progn
(scrub-control-stack)
(sb-thread::get-foreground)
(unless noprint
(flush-standard-output-streams)
(funcall *repl-prompt-fun* *standard-output*)
(force-output *standard-output*))
(let* ((form (funcall *repl-read-form-fun* *standard-input* *standard-output*))
(results (multiple-value-list (interactive-eval form :eval ,eval)))) ;; <<--
(unless noprint
(dolist (result results)
(fresh-line)
(prin1 result)))))
(disable-stepping))))))
(define-%defun)
;(define-%defmacro)
(toplevel-repl ,noprint)))