Lower typed JVM array helpers to Kotlin

ober

7e3b80fffa00714df9bd37db430a5c3daf6ba89e

diff --git a/lib/jerboa/typed/checker.ss b/lib/jerboa/typed/checker.ss
index 54944ca..8c0b15f 100644
--- a/lib/jerboa/typed/checker.ss
+++ b/lib/jerboa/typed/checker.ss
@@ -400,6 +400,18 @@
       (cons 'float-array-length
             (make-typed-call-sig (list 'FloatArray) 'Int32 '()
               'jvm-float-array-length '()))
+      (cons 'int-array-ref
+            (make-typed-call-sig (list 'IntArray 'Int32) 'Int32 '()
+              'jvm-int-array-ref '()))
+      (cons 'int-array-length
+            (make-typed-call-sig (list 'IntArray) 'Int32 '()
+              'jvm-int-array-length '()))
+      (cons 'boolean-array-ref
+            (make-typed-call-sig (list 'BooleanArray 'Int32) 'Bool '()
+              'jvm-boolean-array-ref '()))
+      (cons 'boolean-array-length
+            (make-typed-call-sig (list 'BooleanArray) 'Int32 '()
+              'jvm-boolean-array-length '()))
       (cons 'int32->string
             (make-typed-call-sig (list 'Int32) 'String '()
               'jvm-to-string '()))
diff --git a/lib/jerboa/typed/kotlin/lower.ss b/lib/jerboa/typed/kotlin/lower.ss
index 12107e5..cb1d152 100644
--- a/lib/jerboa/typed/kotlin/lower.ss
+++ b/lib/jerboa/typed/kotlin/lower.ss
@@ -86,6 +86,9 @@
          [(Nat) (make-kt-type 'ULong #f '())]
          [(Float) (make-kt-type 'Double #f '())]
          [(Float32) (make-kt-type 'Float #f '())]
+         [(FloatArray) (make-kt-type 'FloatArray #f '())]
+         [(IntArray) (make-kt-type 'IntArray #f '())]
+         [(BooleanArray) (make-kt-type 'BooleanArray #f '())]
          [(String) (make-kt-type 'String #f '())]
          [(Bytes) (make-kt-type 'ByteArray #f '())]
          [(Symbol Keyword) (make-kt-type 'String #f '())]
@@ -281,6 +284,14 @@
          (make-kt-index-get (car args) (cadr args))]
         [(jvm-float-array-length)
          (make-kt-member-get (car args) 'size)]
+        [(jvm-int-array-ref)
+         (make-kt-index-get (car args) (cadr args))]
+        [(jvm-int-array-length)
+         (make-kt-member-get (car args) 'size)]
+        [(jvm-boolean-array-ref)
+         (make-kt-index-get (car args) (cadr args))]
+        [(jvm-boolean-array-length)
+         (make-kt-member-get (car args) 'size)]
         [(bytevector-length)
          (make-kt-member-call
            (make-kt-member-get (car args) 'size)
diff --git a/tests/test-typed-kotlin.ss b/tests/test-typed-kotlin.ss
index cdbceff..de26ce2 100644
--- a/tests/test-typed-kotlin.ss
+++ b/tests/test-typed-kotlin.ss
@@ -316,6 +316,44 @@
 (test-contains "Float32 round to Int32 lowers to Java Math.round" float32-math-kotlin
   "java.lang.Math.round((0.25f * a))")
 
+(define array-form
+  '(typed-library (sample typed arrays)
+     (export grayAt edgeAt intSize edgeSize)
+     (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))))
+     (def (intSize (items : IntArray)) : Int32
+       (int-array-length items))
+     (def (edgeSize (items : BooleanArray)) : Int32
+       (boolean-array-length items))))
+
+(define array-kotlin (typed-library-form->kotlin-string array-form))
+
+(test-contains "IntArray type lowers to Kotlin IntArray" array-kotlin
+  "fun grayAt(gray: IntArray, width: Int, height: Int, x: Int, y: Int): Int")
+(test-contains "IntArray indexing lowers to brackets" array-kotlin
+  "gray[((y * width) + x)]")
+(test-contains "BooleanArray type lowers to Kotlin BooleanArray" array-kotlin
+  "fun edgeAt(edge: BooleanArray, width: Int, height: Int, x: Int, y: Int): Boolean")
+(test-contains "BooleanArray indexing lowers to brackets" array-kotlin
+  "edge[((y * width) + x)]")
+(test-contains "IntArray length lowers to Kotlin size" array-kotlin
+  "return items.size")
+
 (define note-form
   '(typed-library (sample typed notes)
      (export appendNote)