aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/primitive.jvm.lux
blob: f1d639b721a327092588fa3c0f9c0407371f3687 (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
(.module:
  [lux (#- i64)
   [control
    monad]
   [data
    [text
     format]]
   [language
    [compiler ("operation/" Monad<Operation>)]]]
  [luxc
   [lang
    [host
     [jvm (#+ Inst Operation)
      ["$i" inst]
      ["$t" type]]]]])

(def: #export (bit value)
  (-> Bit (Operation Inst))
  (operation/wrap ($i.GETSTATIC "java.lang.Boolean"
                                (if value "TRUE" "FALSE")
                                ($t.class "java.lang.Boolean" (list)))))

(do-template [<name> <type> <load> <wrap>]
  [(def: #export (<name> value)
     (-> <type> (Operation Inst))
     (operation/wrap (|>> (<load> value) <wrap>)))]

  [i64  Int  $i.long   ($i.wrap #jvm.Long)]
  [f64  Frac $i.double ($i.wrap #jvm.Double)]
  [text Text $i.string (<|)]
  )