Chez Phase 2 (inc O): host String methods (jolt-nfca)

Port the java.lang.String/CharSequence method surface to the Chez RT so
(.toUpperCase s), (.substring s a b), (.indexOf s x), the regex methods
(.matches/.replaceAll/.replaceFirst/.split), etc. run on a string target.

natives-str.ss holds jolt-string-method, ported from the seed's surface in
eval_resolve.janet: ASCII case mapping (byte-oriented like the seed), -1 on
indexOf miss, flonum numeric returns to match jolt's number model, Scheme
chars for charAt, and the regex methods over the irregex compiled via
jolt-re-pattern. record-method-dispatch gains a string? arm that falls
through to it (unsupported methods still throw).

Corpus prelude floor 2002 -> 2026 (+24), 0 new divergences. _str 27/27 vs
build/jolt; full jpm test + conformance x3 green.

The (. x m) dot-form (the . special form, distinct from .method sugar) and
the clojure.string namespace (needs prelude plumbing + Pattern) stay deferred.
This commit is contained in:
Yogthos 2026-06-18 20:36:39 -04:00
parent b7158e0690
commit 3ab53ba938
6 changed files with 209 additions and 2 deletions

View file

@ -209,6 +209,9 @@
((reified-methods obj)
=> (lambda (rm) (let ((f (hashtable-ref rm method-name #f)))
(if f (apply jolt-invoke f obj rest) (error #f (string-append "No method " method-name))))))
;; java.lang.String interop (jolt-nfca): defined in natives-str.ss, loaded
;; after this file (free reference, resolved at call time).
((string? obj) (jolt-string-method method-name obj rest))
(else (error #f (string-append "No method " method-name " for value"))))))
;; reify: instance-local method table. obj is a jreify carrying a method ht +