aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/generator/procedure/host.jvm.lux
blob: d99694554ff80c4953bf995ca382f167913c64c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
(;module:
  lux
  (lux (control [monad #+ do])
       (data [text "text/" Eq<Text>]
             text/format
             (coll [list "list/" Functor<List>]
                   [dict #+ Dict]))
       [macro #+ with-gensyms]
       (macro [code]
              ["s" syntax #+ syntax:])
       [host])
  (luxc ["&" base]
        (lang ["la" analysis]
              ["ls" synthesis])
        ["&;" analyser]
        (analyser (procedure ["&;" host]))
        ["&;" synthesizer]
        (synthesizer [function])
        (generator ["&;" common]
                   ["&;" runtime]
                   (host ["$" jvm]
                         (jvm ["$t" type]
                              ["$d" def]
                              ["$i" inst]))))
  ["@" ../common])

(do-template [<name> <inst>]
  [(def: <name>
     $;Inst
     <inst>)]

  [L2S (|>. $i;L2I $i;I2S)]
  [L2B (|>. $i;L2I $i;I2B)]
  )

(do-template [<name> <unwrap> <conversion> <wrap>]
  [(def: (<name> inputI)
     @;Unary
     (if (is $i;NOP <conversion>)
       (|>. inputI
            ($i;unwrap <unwrap>)
            ($i;wrap <wrap>))
       (|>. inputI
            ($i;unwrap <unwrap>)
            <conversion>
            ($i;wrap <wrap>))))]
  
  [convert//double-to-float #$;Double $i;D2F #$;Float]
  [convert//double-to-int #$;Double $i;D2I #$;Int]
  [convert//double-to-long #$;Double $i;D2L #$;Long]
  [convert//float-to-double #$;Float $i;F2D #$;Double]
  [convert//float-to-int #$;Float $i;F2I #$;Int]
  [convert//float-to-long #$;Float $i;F2L #$;Long]
  [convert//int-to-byte #$;Int $i;I2B #$;Byte]
  [convert//int-to-char #$;Int $i;I2C #$;Char]
  [convert//int-to-double #$;Int $i;I2D #$;Double]
  [convert//int-to-float #$;Int $i;I2F #$;Float]
  [convert//int-to-long #$;Int $i;I2L #$;Long]
  [convert//int-to-short #$;Int $i;I2S #$;Short]
  [convert//long-to-double #$;Long $i;L2D #$;Double]
  [convert//long-to-float #$;Long $i;L2F #$;Float]
  [convert//long-to-int #$;Long $i;L2I #$;Int]
  [convert//long-to-short #$;Long L2S #$;Short]
  [convert//long-to-byte #$;Long L2B #$;Byte]
  [convert//char-to-byte #$;Char $i;I2B #$;Byte]
  [convert//char-to-short #$;Char $i;I2S #$;Short]
  [convert//char-to-int #$;Char $i;NOP #$;Int]
  [convert//char-to-long #$;Char $i;I2L #$;Long]
  [convert//byte-to-long #$;Byte $i;I2L #$;Long]
  [convert//short-to-long #$;Short $i;I2L #$;Long]
  )

(def: conversion-procs
  @;Bundle
  (<| (@;prefix "convert")
      (|> (dict;new text;Hash<Text>)
          (@;install "double-to-float" (@;unary convert//double-to-float))
          (@;install "double-to-int" (@;unary convert//double-to-int))
          (@;install "double-to-long" (@;unary convert//double-to-long))
          (@;install "float-to-double" (@;unary convert//float-to-double))
          (@;install "float-to-int" (@;unary convert//float-to-int))
          (@;install "float-to-long" (@;unary convert//float-to-long))
          (@;install "int-to-byte" (@;unary convert//int-to-byte))
          (@;install "int-to-char" (@;unary convert//int-to-char))
          (@;install "int-to-double" (@;unary convert//int-to-double))
          (@;install "int-to-float" (@;unary convert//int-to-float))
          (@;install "int-to-long" (@;unary convert//int-to-long))
          (@;install "int-to-short" (@;unary convert//int-to-short))
          (@;install "long-to-double" (@;unary convert//long-to-double))
          (@;install "long-to-float" (@;unary convert//long-to-float))
          (@;install "long-to-int" (@;unary convert//long-to-int))
          (@;install "long-to-short" (@;unary convert//long-to-short))
          (@;install "long-to-byte" (@;unary convert//long-to-byte))
          (@;install "char-to-byte" (@;unary convert//char-to-byte))
          (@;install "char-to-short" (@;unary convert//char-to-short))
          (@;install "char-to-int" (@;unary convert//char-to-int))
          (@;install "char-to-long" (@;unary convert//char-to-long))
          (@;install "byte-to-long" (@;unary convert//byte-to-long))
          (@;install "short-to-long" (@;unary convert//short-to-long))
          )))

(do-template [<name> <op> <unwrapX> <unwrapY> <wrap>]
  [(def: (<name> [xI yI])
     @;Binary
     (|>. xI ($i;unwrap <unwrapX>)
          yI ($i;unwrap <unwrapY>)
          <op> ($i;wrap <wrap>)))]

  [int//+ $i;IADD #$;Int #$;Int #$;Int]
  [int//- $i;ISUB #$;Int #$;Int #$;Int]
  [int//* $i;IMUL #$;Int #$;Int #$;Int]
  [int/// $i;IDIV #$;Int #$;Int #$;Int]
  [int//% $i;IREM #$;Int #$;Int #$;Int]
  [int//and $i;IAND #$;Int #$;Int #$;Int]
  [int//or $i;IOR #$;Int #$;Int #$;Int]
  [int//xor $i;IXOR #$;Int #$;Int #$;Int]
  [int//shl $i;ISHL #$;Int #$;Int #$;Int]
  [int//shr $i;ISHR #$;Int #$;Int #$;Int]
  [int//ushr $i;IUSHR #$;Int #$;Int #$;Int]
  
  [long//+ $i;LADD #$;Long #$;Long #$;Long]
  [long//- $i;LSUB #$;Long #$;Long #$;Long]
  [long//* $i;LMUL #$;Long #$;Long #$;Long]
  [long/// $i;LDIV #$;Long #$;Long #$;Long]
  [long//% $i;LREM #$;Long #$;Long #$;Long]
  [long//and $i;LAND #$;Long #$;Long #$;Long]
  [long//or $i;LOR #$;Long #$;Long #$;Long]
  [long//xor $i;LXOR #$;Long #$;Long #$;Long]
  [long//shl $i;LSHL #$;Long #$;Int #$;Long]
  [long//shr $i;LSHR #$;Long #$;Int #$;Long]
  [long//ushr $i;LUSHR #$;Long #$;Int #$;Long]

  [float//+ $i;FADD #$;Float #$;Float #$;Float]
  [float//- $i;FSUB #$;Float #$;Float #$;Float]
  [float//* $i;FMUL #$;Float #$;Float #$;Float]
  [float/// $i;FDIV #$;Float #$;Float #$;Float]
  [float//% $i;FREM #$;Float #$;Float #$;Float]
  
  [double//+ $i;DADD #$;Double #$;Double #$;Double]
  [double//- $i;DSUB #$;Double #$;Double #$;Double]
  [double//* $i;DMUL #$;Double #$;Double #$;Double]
  [double/// $i;DDIV #$;Double #$;Double #$;Double]
  [double//% $i;DREM #$;Double #$;Double #$;Double]
  )

(do-template [<name> <op> <unwrapX> <unwrapY> <wrap>]
  [(def: (<name> [xI yI])
     @;Binary
     (<| $i;with-label (function [@then])
         $i;with-label (function [@end])
         (|>. xI ($i;unwrap <unwrapX>)
              yI ($i;unwrap <unwrapY>)
              (<op> @then)
              ($i;GETSTATIC "java.lang.Boolean" "FALSE" ($t;class "java.lang.Boolean" (list)))
              ($i;GOTO @end)
              ($i;label @then)
              ($i;GETSTATIC "java.lang.Boolean" "TRUE" ($t;class "java.lang.Boolean" (list)))
              ($i;label @end))))]

  [int//= $i;IF_ICMPEQ #$;Int #$;Int #$;Boolean]
  [int//< $i;IF_ICMPLT #$;Int #$;Int #$;Boolean]

  [char//= $i;IF_ICMPEQ #$;Char #$;Char #$;Boolean]
  [char//< $i;IF_ICMPLT #$;Char #$;Char #$;Boolean]
  )

(do-template [<name> <op> <reference> <unwrapX> <unwrapY> <wrap>]
  [(def: (<name> [xI yI])
     @;Binary
     (<| $i;with-label (function [@then])
         $i;with-label (function [@end])
         (|>. xI ($i;unwrap <unwrapX>)
              yI ($i;unwrap <unwrapY>)
              <op>
              ($i;int <reference>)
              ($i;IF_ICMPEQ @then)
              ($i;GETSTATIC "java.lang.Boolean" "FALSE" ($t;class "java.lang.Boolean" (list)))
              ($i;GOTO @end)
              ($i;label @then)
              ($i;GETSTATIC "java.lang.Boolean" "TRUE" ($t;class "java.lang.Boolean" (list)))
              ($i;label @end))))]

  [long//= $i;LCMP  0 #$;Long #$;Long #$;Boolean]
  [long//< $i;LCMP -1 #$;Long #$;Long #$;Boolean]
  
  [float//= $i;FCMPG  0 #$;Float #$;Float #$;Boolean]
  [float//< $i;FCMPG -1 #$;Float #$;Float #$;Boolean]

  [double//= $i;DCMPG  0 #$;Double #$;Double #$;Boolean]
  [double//< $i;DCMPG -1 #$;Double #$;Double #$;Boolean]
  )

(def: int-procs
  @;Bundle
  (<| (@;prefix "int")
      (|> (dict;new text;Hash<Text>)
          (@;install "+" (@;binary int//+))
          (@;install "-" (@;binary int//-))
          (@;install "*" (@;binary int//*))
          (@;install "/" (@;binary int///))
          (@;install "%" (@;binary int//%))
          (@;install "=" (@;binary int//=))
          (@;install "<" (@;binary int//<))
          (@;install "and" (@;binary int//and))
          (@;install "or" (@;binary int//or))
          (@;install "xor" (@;binary int//xor))
          (@;install "shl" (@;binary int//shl))
          (@;install "shr" (@;binary int//shr))
          (@;install "ushr" (@;binary int//ushr))
          )))

(def: long-procs
  @;Bundle
  (<| (@;prefix "long")
      (|> (dict;new text;Hash<Text>)
          (@;install "+" (@;binary long//+))
          (@;install "-" (@;binary long//-))
          (@;install "*" (@;binary long//*))
          (@;install "/" (@;binary long///))
          (@;install "%" (@;binary long//%))
          (@;install "=" (@;binary long//=))
          (@;install "<" (@;binary long//<))
          (@;install "and" (@;binary long//and))
          (@;install "or" (@;binary long//or))
          (@;install "xor" (@;binary long//xor))
          (@;install "shl" (@;binary long//shl))
          (@;install "shr" (@;binary long//shr))
          (@;install "ushr" (@;binary long//ushr))
          )))

(def: float-procs
  @;Bundle
  (<| (@;prefix "float")
      (|> (dict;new text;Hash<Text>)
          (@;install "+" (@;binary float//+))
          (@;install "-" (@;binary float//-))
          (@;install "*" (@;binary float//*))
          (@;install "/" (@;binary float///))
          (@;install "%" (@;binary float//%))
          (@;install "=" (@;binary float//=))
          (@;install "<" (@;binary float//<))
          )))

(def: double-procs
  @;Bundle
  (<| (@;prefix "double")
      (|> (dict;new text;Hash<Text>)
          (@;install "+" (@;binary double//+))
          (@;install "-" (@;binary double//-))
          (@;install "*" (@;binary double//*))
          (@;install "/" (@;binary double///))
          (@;install "%" (@;binary double//%))
          (@;install "=" (@;binary double//=))
          (@;install "<" (@;binary double//<))
          )))

(def: char-procs
  @;Bundle
  (<| (@;prefix "char")
      (|> (dict;new text;Hash<Text>)
          (@;install "=" (@;binary char//=))
          (@;install "<" (@;binary char//<))
          )))

(def: (array//length arrayI)
  @;Unary
  (|>. arrayI
       $i;ARRAYLENGTH
       $i;I2L
       ($i;wrap #$;Long)))

(def: (array//new proc generate inputs)
  (-> Text @;Proc)
  (case inputs
    (^ (list (#ls;Nat level) (#ls;Text class) lengthS))
    (do macro;Monad<Lux>
      [lengthI (generate lengthS)
       #let [arrayJT ($t;array level (case class
                                       "boolean" $t;boolean
                                       "byte" $t;byte
                                       "short" $t;short
                                       "int" $t;int
                                       "long" $t;long
                                       "float" $t;float
                                       "double" $t;double
                                       "char" $t;char
                                       _ ($t;class class (list))))]]
      (wrap (|>. lengthI
                 ($i;unwrap #$;Long)
                 $i;L2I
                 ($i;array arrayJT))))

    _
    (&;fail (format "Wrong syntax for '" proc "'."))))

(def: (array//read proc generate inputs)
  (-> Text @;Proc)
  (case inputs
    (^ (list (#ls;Text class) idxS arrayS))
    (do macro;Monad<Lux>
      [arrayI (generate arrayS)
       idxI (generate idxS)
       #let [loadI (case class
                     "boolean" (|>. $i;BALOAD ($i;wrap #$;Boolean))
                     "byte" (|>. $i;BALOAD ($i;wrap #$;Byte))
                     "short" (|>. $i;SALOAD ($i;wrap #$;Short))
                     "int" (|>. $i;IALOAD ($i;wrap #$;Int))
                     "long" (|>. $i;LALOAD ($i;wrap #$;Long))
                     "float" (|>. $i;FALOAD ($i;wrap #$;Float))
                     "double" (|>. $i;DALOAD ($i;wrap #$;Double))
                     "char" (|>. $i;CALOAD ($i;wrap #$;Char))
                     _ $i;AALOAD)]]
      (wrap (|>. arrayI
                 idxI
                 ($i;unwrap #$;Long)
                 $i;L2I
                 loadI)))

    _
    (&;fail (format "Wrong syntax for '" proc "'."))))

(def: (array//write proc generate inputs)
  (-> Text @;Proc)
  (case inputs
    (^ (list (#ls;Text class) idxS valueS arrayS))
    (do macro;Monad<Lux>
      [arrayI (generate arrayS)
       idxI (generate idxS)
       valueI (generate valueS)
       #let [storeI (case class
                      "boolean" (|>. ($i;unwrap #$;Boolean) $i;BASTORE)
                      "byte" (|>. ($i;unwrap #$;Byte) $i;BASTORE)
                      "short" (|>. ($i;unwrap #$;Short) $i;SASTORE)
                      "int" (|>. ($i;unwrap #$;Int) $i;IASTORE)
                      "long" (|>. ($i;unwrap #$;Long) $i;LASTORE)
                      "float" (|>. ($i;unwrap #$;Float) $i;FASTORE)
                      "double" (|>. ($i;unwrap #$;Double) $i;DASTORE)
                      "char" (|>. ($i;unwrap #$;Char) $i;CASTORE)
                      _ $i;AASTORE)]]
      (wrap (|>. arrayI
                 $i;DUP
                 idxI
                 ($i;unwrap #$;Long)
                 $i;L2I
                 valueI
                 storeI)))

    _
    (&;fail (format "Wrong syntax for '" proc "'."))))

(def: array-procs
  @;Bundle
  (<| (@;prefix "array")
      (|> (dict;new text;Hash<Text>)
          (@;install "length" (@;unary array//length))
          (@;install "new" array//new)
          (@;install "read" array//read)
          (@;install "write" array//write)
          )))

(def: (object//null _)
  @;Nullary
  $i;NULL)

(def: (object//null? objectI)
  @;Unary
  (<| $i;with-label (function [@then])
      $i;with-label (function [@end])
      (|>. objectI
           ($i;IFNULL @then)
           ($i;GETSTATIC "java.lang.Boolean" "FALSE" ($t;class "java.lang.Boolean" (list)))
           ($i;GOTO @end)
           ($i;label @then)
           ($i;GETSTATIC "java.lang.Boolean" "TRUE" ($t;class "java.lang.Boolean" (list)))
           ($i;label @end))))

(def: (object//synchronized [monitorI exprI])
  @;Binary
  (|>. monitorI
       $i;DUP
       $i;MONITORENTER
       exprI
       $i;SWAP
       $i;MONITOREXIT))

(def: (object//throw exceptionI)
  @;Unary
  (|>. exceptionI
       $i;ATHROW))

(def: (object//class proc generate inputs)
  (-> Text @;Proc)
  (case inputs
    (^ (list (#ls;Text class)))
    (do macro;Monad<Lux>
      []
      (wrap (|>. ($i;string class)
                 ($i;INVOKESTATIC "java.lang.Class" "forName"
                                  ($t;method (list ($t;class "java.lang.String" (list)))
                                             (#;Some ($t;class "java.lang.Class" (list)))
                                             (list))
                                  false))))

    _
    (&;fail (format "Wrong syntax for '" proc "'."))))

(def: (object//instance? proc generate inputs)
  (-> Text @;Proc)
  (case inputs
    (^ (list (#ls;Text class) objectS))
    (do macro;Monad<Lux>
      [objectI (generate objectS)]
      (wrap (|>. objectI
                 ($i;INSTANCEOF class)
                 ($i;wrap #$;Boolean))))

    _
    (&;fail (format "Wrong syntax for '" proc "'."))))

(def: object-procs
  @;Bundle
  (<| (@;prefix "object")
      (|> (dict;new text;Hash<Text>)
          (@;install "null" (@;nullary object//null))
          (@;install "null?" (@;unary object//null?))
          (@;install "synchronized" (@;binary object//synchronized))
          (@;install "throw" (@;unary object//throw))
          (@;install "class" object//class)
          (@;install "instance?" object//instance?)
          )))

(def: primitives
  (Dict Text $;Primitive)
  (|> (list ["boolean" #$;Boolean]
            ["byte" #$;Byte]
            ["short" #$;Short]
            ["int" #$;Int]
            ["long" #$;Long]
            ["float" #$;Float]
            ["double" #$;Double]
            ["char" #$;Char])
      (dict;from-list text;Hash<Text>)))

(def: (static//get proc generate inputs)
  (-> Text @;Proc)
  (case inputs
    (^ (list (#ls;Text class) (#ls;Text field) (#ls;Text unboxed)))
    (do macro;Monad<Lux>
      []
      (case (dict;get unboxed primitives)
        (#;Some primitive)
        (let [primitive (case unboxed
                          "boolean" #$;Boolean
                          "byte" #$;Byte
                          "short" #$;Short
                          "int" #$;Int
                          "long" #$;Long
                          "float" #$;Float
                          "double" #$;Double
                          "char" #$;Char
                          _ (undefined))]
          (wrap (|>. ($i;GETSTATIC class field (#$;Primitive primitive))
                     ($i;wrap primitive))))
        
        #;None
        (wrap ($i;GETSTATIC class field ($t;class unboxed (list))))))

    _
    (&;fail (format "Wrong syntax for '" proc "'."))))

(def: (static//put proc generate inputs)
  (-> Text @;Proc)
  (case inputs
    (^ (list (#ls;Text class) (#ls;Text field) (#ls;Text unboxed) valueS))
    (do macro;Monad<Lux>
      [valueI (generate valueS)]
      (case (dict;get unboxed primitives)
        (#;Some primitive)
        (let [primitive (case unboxed
                          "boolean" #$;Boolean
                          "byte" #$;Byte
                          "short" #$;Short
                          "int" #$;Int
                          "long" #$;Long
                          "float" #$;Float
                          "double" #$;Double
                          "char" #$;Char
                          _ (undefined))]
          (wrap (|>. valueI
                     ($i;unwrap primitive)
                     ($i;PUTSTATIC class field (#$;Primitive primitive))
                     ($i;string &runtime;unit))))
        
        #;None
        (wrap (|>. valueI
                   ($i;CHECKCAST class)
                   ($i;PUTSTATIC class field ($t;class class (list)))
                   ($i;string &runtime;unit)))))

    _
    (&;fail (format "Wrong syntax for '" proc "'."))))

(def: (virtual//get proc generate inputs)
  (-> Text @;Proc)
  (case inputs
    (^ (list (#ls;Text class) (#ls;Text field) (#ls;Text unboxed) objectS))
    (do macro;Monad<Lux>
      [objectI (generate objectS)]
      (case (dict;get unboxed primitives)
        (#;Some primitive)
        (let [primitive (case unboxed
                          "boolean" #$;Boolean
                          "byte" #$;Byte
                          "short" #$;Short
                          "int" #$;Int
                          "long" #$;Long
                          "float" #$;Float
                          "double" #$;Double
                          "char" #$;Char
                          _ (undefined))]
          (wrap (|>. objectI
                     ($i;CHECKCAST class)
                     ($i;GETFIELD class field (#$;Primitive primitive))
                     ($i;wrap primitive))))
        
        #;None
        (wrap (|>. objectI
                   ($i;CHECKCAST class)
                   ($i;GETFIELD class field ($t;class class (list)))))))

    _
    (&;fail (format "Wrong syntax for '" proc "'."))))

(def: (virtual//put proc generate inputs)
  (-> Text @;Proc)
  (case inputs
    (^ (list (#ls;Text class) (#ls;Text field) (#ls;Text unboxed) valueS objectS))
    (do macro;Monad<Lux>
      [valueI (generate valueS)
       objectI (generate objectS)]
      (case (dict;get unboxed primitives)
        (#;Some primitive)
        (let [primitive (case unboxed
                          "boolean" #$;Boolean
                          "byte" #$;Byte
                          "short" #$;Short
                          "int" #$;Int
                          "long" #$;Long
                          "float" #$;Float
                          "double" #$;Double
                          "char" #$;Char
                          _ (undefined))]
          (wrap (|>. objectI
                     ($i;CHECKCAST class)
                     valueI
                     ($i;unwrap primitive)
                     ($i;PUTFIELD class field (#$;Primitive primitive))
                     ($i;string &runtime;unit))))
        
        #;None
        (wrap (|>. objectI
                   ($i;CHECKCAST class)
                   valueI
                   ($i;CHECKCAST class)
                   ($i;PUTFIELD class field ($t;class class (list)))
                   ($i;string &runtime;unit)))))

    _
    (&;fail (format "Wrong syntax for '" proc "'."))))

(def: member-procs
  @;Bundle
  (<| (@;prefix "member")
      (|> (dict;new text;Hash<Text>)
          (dict;merge (<| (@;prefix "static")
                          (|> (dict;new text;Hash<Text>)
                              (@;install "get" static//get)
                              (@;install "put" static//put))))
          (dict;merge (<| (@;prefix "virtual")
                          (|> (dict;new text;Hash<Text>)
                              (@;install "get" virtual//get)
                              (@;install "put" virtual//put))))
          )))

(def: #export procedures
  @;Bundle
  (<| (@;prefix "jvm")
      (|> (dict;new text;Hash<Text>)
          (dict;merge conversion-procs)
          (dict;merge int-procs)
          (dict;merge long-procs)
          (dict;merge float-procs)
          (dict;merge double-procs)
          (dict;merge char-procs)
          (dict;merge array-procs)
          (dict;merge object-procs)
          (dict;merge member-procs)
          )))