diff --git a/host/chez/host-static.ss b/host/chez/host-static.ss index 2e6deeb..83a77a4 100644 --- a/host/chez/host-static.ss +++ b/host/chez/host-static.ss @@ -154,6 +154,11 @@ (register-host-methods! "thread" (list (cons "getContextClassLoader" (lambda (self) (make-jhost "classloader" '()))))) +;; clojure.lang.LockingTransaction: jolt has no STM (no refs/dosync), so a +;; transaction is never running. isRunning -> false (jolt-0obq). +(register-class-statics! "LockingTransaction" (list (cons "isRunning" (lambda () #f)))) +(register-class-statics! "clojure.lang.LockingTransaction" (list (cons "isRunning" (lambda () #f)))) + (define (now-millis) (let ((t (current-time 'time-utc))) (+ (* 1000 (time-second t)) (quotient (time-nanosecond t) 1000000)))) diff --git a/host/chez/io.ss b/host/chez/io.ss index 72af1fd..5588737 100644 --- a/host/chez/io.ss +++ b/host/chez/io.ss @@ -128,6 +128,20 @@ (jolt-invoke (var-deref "clojure.core" "read-string") (if (reader-jhost? reader) (drain-reader reader) (jolt-str-render-one reader)))) +;; line-seq (jolt-0obq): the overlay line-seq reads via a Janet map-reader's +;; :read-line-fn, but a Chez io/reader is a jhost StringReader. Drain it (or take a +;; string) and split on newline; a trailing newline does NOT yield a final empty +;; line (like readLine -> nil at EOF). Re-asserted in post-prelude.ss. +(define (chez-lines s) + (let loop ((cs (string->list s)) (cur '()) (acc '())) + (cond ((null? cs) (reverse (if (null? cur) acc (cons (list->string (reverse cur)) acc)))) + ((char=? (car cs) #\newline) (loop (cdr cs) '() (cons (list->string (reverse cur)) acc))) + (else (loop (cdr cs) (cons (car cs) cur) acc))))) +(define (chez-line-seq rdr) + (list->cseq (chez-lines (cond ((string? rdr) rdr) + ((reader-jhost? rdr) (drain-reader rdr)) + (else (jolt-str-render-one rdr)))))) + (define (jolt-slurp src . opts) (cond ((jfile? src) (read-file-string (jfile-path src))) diff --git a/host/chez/post-prelude.ss b/host/chez/post-prelude.ss index 59db040..ad23bc2 100644 --- a/host/chez/post-prelude.ss +++ b/host/chez/post-prelude.ss @@ -71,3 +71,9 @@ (case-lambda ((reader) (chez-edn-read reader)) ((opts reader) (chez-edn-read reader)))) +;; line-seq: a jhost reader (io/reader result) -> drain+split; a map-reader (the +;; overlay's :read-line-fn model, e.g. with-in-str) -> the overlay version. +(let ((overlay-line-seq (var-deref "clojure.core" "line-seq"))) + (def-var! "clojure.core" "line-seq" + (lambda (rdr) + (if (reader-jhost? rdr) (chez-line-seq rdr) (jolt-invoke overlay-line-seq rdr))))) diff --git a/test/chez/run-corpus-prelude.janet b/test/chez/run-corpus-prelude.janet index 2fc3070..9e12926 100644 --- a/test/chez/run-corpus-prelude.janet +++ b/test/chez/run-corpus-prelude.janet @@ -323,7 +323,7 @@ # runtime-require alias registration) -> 2590; arrays + reader-features/ # macroexpand/reader-conditional/re-matcher -> 2629; delay/force/realized? -> 2641. # Strided runs scale down. -(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_PRELUDE_FLOOR") "2641"))) +(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_PRELUDE_FLOOR") "2648"))) (def floor (if (os/getenv "JOLT_CORPUS_LIMIT") 0 base-floor)) (when (or (> (length diverged) 0) (< pass floor)) (printf "REGRESSION: pass %d < floor %d or %d new divergence(s)" pass floor (length diverged))) diff --git a/test/chez/run-corpus-zero-janet.janet b/test/chez/run-corpus-zero-janet.janet index 30b4c3e..4078ce6 100644 --- a/test/chez/run-corpus-zero-janet.janet +++ b/test/chez/run-corpus-zero-janet.janet @@ -219,7 +219,7 @@ # 2685; deftype (P. args) constructor via host-new var fallback -> 2688; # date/time (Date/Timestamp/SimpleDateFormat/TimeZone) + clojure.edn/read over a # reader -> 2692. -(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_ZJ_FLOOR") "2694"))) +(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_ZJ_FLOOR") "2696"))) (def floor (if (os/getenv "JOLT_CORPUS_LIMIT") 0 base-floor)) (when (or (> (length diverged) 0) (< pass floor)) (printf "REGRESSION: pass %d < floor %d or %d new divergence(s)" pass floor (length diverged)))