Move SSD array pixel accessors to typed Kotlin

ober

5293e429b252b92bb8145676c02ee96dc3427fcd

diff --git a/.build.yml b/.build.yml
index 77a0c81..76f119c 100644
--- a/.build.yml
+++ b/.build.yml
@@ -5,7 +5,7 @@ packages:
   - make=4.4.1-r4
 sources:
   # Build dependency: full immutable commit, mirrored in dependencies.lock.json.
-  - "https://git.sr.ht/~lisp/jerboa#47ca11b0fc7b75ae33ecccf4fc22cbe4c9bcf8e0"
+  - "https://git.sr.ht/~lisp/jerboa#b461a2e2042f0f7ec9621a8c8f7d4997b7f875ac"
   # The second source is the build subject selected by the SourceHut submitter.
   - https://git.sr.ht/~lisp/jerboa-android
 tasks:
@@ -14,6 +14,6 @@ tasks:
       test "$(apk info -v chez-scheme)" = chez-scheme-10.3.0-r2
       test "$(apk info -v git)" = git-2.54.0-r0
       test "$(apk info -v make)" = make-4.4.1-r4
-      test "$(git -C ../jerboa rev-parse HEAD)" = 47ca11b0fc7b75ae33ecccf4fc22cbe4c9bcf8e0
-      test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 123466f97f77704fb16ccc1d98e6c522dbf24575
+      test "$(git -C ../jerboa rev-parse HEAD)" = b461a2e2042f0f7ec9621a8c8f7d4997b7f875ac
+      test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 306cb8d6e192e79f5e78b673efa4eedc04b3c244
       JERBOA="chez --libdirs .:../jerboa/lib --script" make test
diff --git a/dependencies.lock.json b/dependencies.lock.json
index 2c45d8c..653043c 100644
--- a/dependencies.lock.json
+++ b/dependencies.lock.json
@@ -11,8 +11,8 @@
   "generator_runtime": {
     "name": "jerboa",
     "repository": "https://git.sr.ht/~lisp/jerboa",
-    "commit": "47ca11b0fc7b75ae33ecccf4fc22cbe4c9bcf8e0",
-    "tree": "123466f97f77704fb16ccc1d98e6c522dbf24575"
+    "commit": "b461a2e2042f0f7ec9621a8c8f7d4997b7f875ac",
+    "tree": "306cb8d6e192e79f5e78b673efa4eedc04b3c244"
   },
   "assurance_tools": {
     "osv_scanner": {
diff --git a/scripts/verify-supply-chain.sh b/scripts/verify-supply-chain.sh
index 48a67cc..59ce214 100755
--- a/scripts/verify-supply-chain.sh
+++ b/scripts/verify-supply-chain.sh
@@ -3,8 +3,8 @@ set -eu
 
 repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P)
 lock="$repo/dependencies.lock.json"
-jerboa_commit=47ca11b0fc7b75ae33ecccf4fc22cbe4c9bcf8e0 # gitsafe:ignore
-jerboa_tree=123466f97f77704fb16ccc1d98e6c522dbf24575 # gitsafe:ignore
+jerboa_commit=b461a2e2042f0f7ec9621a8c8f7d4997b7f875ac # gitsafe:ignore
+jerboa_tree=306cb8d6e192e79f5e78b673efa4eedc04b3c244 # gitsafe:ignore
 gradle_sha=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78
 jdk_macos_sha=8fa1eff40bb637a33613b2ccb8b12c70dc3661cc22cf8e784943715769a05336
 jdk_linux_sha=d8afc263758141a66e0e3aafc321e783f7016696f4eaea067d340a269037d331
diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 3586d65..e245d5a 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -604,6 +604,35 @@
             (and (and (> lum 115.0)
                       (< lum 252.0))
                  (> (- maxC minC) (int32 8)))))))
+
+    (typed-kotlin-file "com/sfb/ssdreview/VisionArrays.kt"
+      (typed-library (com sfb ssdreview)
+        (export grayAt edgeAt)
+        (type Int32)
+        (type IntArray)
+        (type BooleanArray)
+        (def (grayAt (gray : IntArray)
+                     (width : Int32)
+                     (height : Int32)
+                     (x : Int32)
+                     (y : Int32)) : Int32
+          (if (or (< x (int32 0))
+                  (or (< y (int32 0))
+                      (or (>= x width)
+                          (>= y height))))
+            (int32 255)
+            (int-array-ref gray (+ (* y width) x))))
+        (def (edgeAt (edge : BooleanArray)
+                     (width : Int32)
+                     (height : Int32)
+                     (x : Int32)
+                     (y : Int32)) : Bool
+          (if (or (< x (int32 0))
+                  (or (< y (int32 0))
+                      (or (>= x width)
+                          (>= y height))))
+            #f
+            (boolean-array-ref edge (+ (* y width) x))))))
     (typed-kotlin-file "com/sfb/ssdreview/UiTextHelpers.kt"
       (typed-library (com sfb ssdreview)
         (export normalizeFiringArc normalizeLabel isGenericGuessLabel isSsdPdfName
@@ -3184,11 +3213,6 @@
        "        return BooleanArray(width * height) { gradients[it] >= threshold }"
        "    }"
        ""
-       "    private fun grayAt(gray: IntArray, width: Int, height: Int, x: Int, y: Int): Int ="
-       "        if (x !in 0 until width || y !in 0 until height) 255 else gray[y * width + x]"
-       ""
-       "    private fun edgeAt(edge: BooleanArray, width: Int, height: Int, x: Int, y: Int): Boolean ="
-       "        x in 0 until width && y in 0 until height && edge[y * width + x]"
        "}"
        ))
     (kotlin-file-lines "com/sfb/ssdreview/SsdVisionBridge.kt"