REPL fixes + an nREPL server for editor-connected dev
The line REPL was broken (read-line called nil — the __stdin-read-line host seam the clojure.core *in* reader drives was never implemented on Chez) and didn't load the project, so (require '[some.lib]) failed. Now: - __stdin-read-line reads a line from stdin (get-line); read-line / read / the REPL work. - repl resolves the project first (deps on the roots, native libs loaded), so libraries are available — same context a run gets. - jolt.nrepl: a jolt-native nREPL server (bencode over a loopback jolt.ffi socket) speaking the real protocol — clone / describe / eval / load-file / close, with stdout capture, :ns-scoped eval (in-ns; binding *ns* doesn't drive load-string resolution here), and real error text. 'joltc nrepl [port]' applies the project then serves; writes .nrepl-port. Editors (CIDER/Calva/Cursive) connect and develop live; project libraries load in the session. - ex-message returns nil for raw Chez conditions, so jolt.host/condition-message exposes the condition text; the REPL and nREPL surface it instead of an opaque #<compound condition>. Why native, not real nREPL: nrepl.server is welded to java.util.concurrent executors, two compiled Java helper classes, a DynamicClassLoader, Compiler internals and a JVMTI agent — not faithfully shimmable. The wire protocol, which is what clients depend on, is small and implemented directly. Runtime .ss + jolt-core, no re-mint. Full gate green.
This commit is contained in:
parent
9a60922d61
commit
d33277c0b2
5 changed files with 220 additions and 2 deletions
|
|
@ -202,6 +202,12 @@
|
|||
(set! jolt-str-render-one
|
||||
(lambda (v) (if (jfile? v) (jfile-path v) (%io-str-render v))))
|
||||
|
||||
;; stdin line seam: the clojure.core *in* reader (50-io.clj) drives read-line /
|
||||
;; read / read+string through __stdin-read-line. Return the next line (newline
|
||||
;; stripped) or nil at EOF. Without this, (read-line) and the REPL call nil.
|
||||
(def-var! "clojure.core" "__stdin-read-line"
|
||||
(lambda () (let ((l (get-line (current-input-port)))) (if (eof-object? l) jolt-nil l))))
|
||||
|
||||
;; (type f) -> :jolt/file (the tagged-file :jolt/type). Re-def-var!
|
||||
;; "type": natives-meta.ss already bound the var to the old jolt-type value, so the
|
||||
;; set! alone (which updates the symbol for internal callers) wouldn't reach it.
|
||||
|
|
|
|||
|
|
@ -256,6 +256,11 @@
|
|||
(let loop ((xs irr) (acc m))
|
||||
(if (null? xs) acc (loop (cdr xs) (string-append acc " " (jolt-pr-str (car xs)))))))
|
||||
(with-output-to-string (lambda () (display-condition c)))))
|
||||
;; expose a Chez condition's message to Clojure (ex-message returns nil for raw
|
||||
;; host conditions): the nREPL eval handler surfaces it instead of an opaque
|
||||
;; "#<compound condition>".
|
||||
(def-var! "jolt.host" "condition-message"
|
||||
(lambda (c) (if (condition? c) (condition->message-string c) jolt-nil)))
|
||||
(define (record-method-dispatch obj method-name rest-args)
|
||||
(let ((rest (if (jolt-nil? rest-args) '() (seq->list rest-args))))
|
||||
(cond
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue