diff --git a/host/chez/ns.ss b/host/chez/ns.ss index 40dd2b3..4f02c25 100644 --- a/host/chez/ns.ss +++ b/host/chez/ns.ss @@ -158,8 +158,36 @@ (hashtable-keys ns-refer-table)) m)) -;; ns-imports: Chez has no Java class imports -> always the empty map. -(define (jolt-ns-imports . _) (jolt-hash-map)) +;; ns-imports: clojure.core auto-imports the 96 public java.lang classes into +;; every ns. jolt has no classloader, but returns that map (short symbol -> +;; canonical class-name token) so (count (ns-imports 'user)) = 96 like the JVM. +(define jolt-default-import-names + '("AbstractMethodError" "Appendable" "ArithmeticException" "ArrayIndexOutOfBoundsException" + "ArrayStoreException" "AssertionError" "BigDecimal" "BigInteger" "Boolean" "Byte" + "Callable" "CharSequence" "Character" "Class" "ClassCastException" "ClassCircularityError" + "ClassFormatError" "ClassLoader" "ClassNotFoundException" "CloneNotSupportedException" + "Cloneable" "Comparable" "Compiler" "Deprecated" "Double" "Enum" + "EnumConstantNotPresentException" "Error" "Exception" "ExceptionInInitializerError" "Float" + "IllegalAccessError" "IllegalAccessException" "IllegalArgumentException" + "IllegalMonitorStateException" "IllegalStateException" "IllegalThreadStateException" + "IncompatibleClassChangeError" "IndexOutOfBoundsException" "InheritableThreadLocal" + "InstantiationError" "InstantiationException" "Integer" "InternalError" "InterruptedException" + "Iterable" "LinkageError" "Long" "Math" "NegativeArraySizeException" "NoClassDefFoundError" + "NoSuchFieldError" "NoSuchFieldException" "NoSuchMethodError" "NoSuchMethodException" + "NullPointerException" "Number" "NumberFormatException" "Object" "OutOfMemoryError" "Override" + "Package" "Process" "ProcessBuilder" "Readable" "Runnable" "Runtime" "RuntimeException" + "RuntimePermission" "SecurityException" "SecurityManager" "Short" "StackOverflowError" + "StackTraceElement" "StrictMath" "String" "StringBuffer" "StringBuilder" + "StringIndexOutOfBoundsException" "SuppressWarnings" "System" "Thread" "Thread$State" + "Thread$UncaughtExceptionHandler" "ThreadDeath" "ThreadGroup" "ThreadLocal" "Throwable" + "TypeNotPresentException" "UnknownError" "UnsatisfiedLinkError" "UnsupportedClassVersionError" + "UnsupportedOperationException" "VerifyError" "VirtualMachineError" "Void")) +(define jolt-default-imports + (let loop ((ns jolt-default-import-names) (m (jolt-hash-map))) + (if (null? ns) m + (loop (cdr ns) + (jolt-assoc m (jolt-symbol #f (car ns)) (string-append "java.lang." (car ns))))))) +(define (jolt-ns-imports . _) jolt-default-imports) ;; resolve: an unqualified symbol resolves in the current ns then clojure.core; a ;; qualified one in its own ns. Returns the var iff genuinely defined, else nil — diff --git a/host/chez/run-corpus.ss b/host/chez/run-corpus.ss index 4ba39e1..b584c83 100644 --- a/host/chez/run-corpus.ss +++ b/host/chez/run-corpus.ss @@ -11,7 +11,7 @@ ;; reset between cases so there is no leakage — same isolation a fresh process gives. ;; ;; chez --script host/chez/run-corpus.ss -;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2718) +;; JOLT_CHEZ_ZJ_FLOOR=N override the regression floor (default 2720) ;; JOLT_CORPUS_LIMIT=N every-Nth stride (fast iteration; floor drops to 0) ;; JOLT_DUMP_CRASH_LABELS=1 list crash + allowlisted labels (import (chezscheme)) @@ -86,11 +86,11 @@ ;; transients/atoms/Infinity. These DIVERGE but are tolerated; the gate fails only on ;; a NEW (unlisted) divergence or a drop below the floor. (define known-fail-labels - '("definterface defines" "getMessage on a thrown string" + '("getMessage on a thrown string" "type of record" "chunked-seq? always false" "^Type tag on var" "symbol hint -> :tag" "lists extended type" "seq of tags" - "close on throw" "macroexpand-1" "ns-imports empty user" + "close on throw" "macroexpand-1" "bean is the map" "proxy resolves nil" "*in* is bound" "*in* bound" "bigdec" "bigdec int M" "bigdec suffix M" @@ -196,7 +196,7 @@ ;; Regression floor: fail on any NEW divergence or if pass drops below the floor. (define base-floor (let ((s (getenv "JOLT_CHEZ_ZJ_FLOOR"))) - (if s (string->number s) 2718))) + (if s (string->number s) 2720))) (define floor (if limit 0 base-floor)) (when (or (> (length diverged) 0) (< pass floor)) (printf "REGRESSION: pass ~a < floor ~a or ~a new divergence(s)\n" diff --git a/host/chez/seed/prelude.ss b/host/chez/seed/prelude.ss index fe710b3..b962166 100644 --- a/host/chez/seed/prelude.ss +++ b/host/chez/seed/prelude.ss @@ -908,7 +908,7 @@ (mark-macro! "clojure.core" "proxy")) (guard (e (#t #f)) (def-var! "clojure.core" "definterface" - (lambda (name-sym . body) (let fnrec484 ((name-sym name-sym) (body (list->cseq body))) (jolt-invoke (var-deref "clojure.core" "__sqcat") (jolt-invoke (var-deref "clojure.core" "__sq1") (jolt-symbol #f "def")) (jolt-invoke (var-deref "clojure.core" "__sq1") name-sym) (jolt-invoke (var-deref "clojure.core" "__sq1") (jolt-invoke (var-deref "clojure.core" "__sqmap") )))))) + (lambda (name-sym . body) (let fnrec484 ((name-sym name-sym) (body (list->cseq body))) (jolt-invoke (var-deref "clojure.core" "__sqcat") (jolt-invoke (var-deref "clojure.core" "__sq1") (jolt-symbol #f "do")) (jolt-invoke (var-deref "clojure.core" "__sq1") (jolt-invoke (var-deref "clojure.core" "__sqcat") (jolt-invoke (var-deref "clojure.core" "__sq1") (jolt-symbol #f "def")) (jolt-invoke (var-deref "clojure.core" "__sq1") name-sym) (jolt-invoke (var-deref "clojure.core" "__sq1") (jolt-invoke (var-deref "clojure.core" "__sqmap") )))) (jolt-invoke (var-deref "clojure.core" "__sq1") (jolt-invoke (var-deref "clojure.core" "__sqcat") (jolt-invoke (var-deref "clojure.core" "__sq1") (jolt-symbol #f "quote")) (jolt-invoke (var-deref "clojure.core" "__sq1") name-sym))))))) (mark-macro! "clojure.core" "definterface")) (guard (e (#t #f)) (def-var! "clojure.core" "reify" diff --git a/jolt-core/clojure/core/30-macros.clj b/jolt-core/clojure/core/30-macros.clj index 14036c3..f6bc038 100644 --- a/jolt-core/clojure/core/30-macros.clj +++ b/jolt-core/clojure/core/30-macros.clj @@ -415,8 +415,10 @@ ;; extend is a real FUNCTION now — defined above extend-type. ;; JVM proxies are unsupported. (defmacro proxy [& args] nil) -;; definterface is JVM-only; bind the name to an empty marker. -(defmacro definterface [name-sym & body] `(def ~name-sym {})) +;; definterface is JVM-only; bind the name to a marker and return the name (not a +;; var), matching the JVM where definterface yields the interface Class. +(defmacro definterface [name-sym & body] + `(do (def ~name-sym {}) (quote ~name-sym))) ;; make-reified is a fn (clojure.core); the method map {kw (fn* ...)} is an ;; ordinary map literal that evaluates to {keyword fn}, and the protocol NAME is