aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/primitive.jvm.lux
blob: 250b0db52608f1c8de3bcf14b3aa903928efba45 (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
(.module:
  lux
  (lux (control monad)
       (data text/format)
       [macro "macro/" Monad<Meta>])
  (luxc ["&" lang]
        (lang [".L" host]
              (host ["$" jvm]
                    (jvm ["$i" inst]
                         ["$t" type]))
              ["la" analysis]
              ["ls" synthesis]))
  (// [".T" common]))

(def: #export (translate-bit value)
  (-> Bit (Meta $.Inst))
  (macro/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> (Meta $.Inst))
     (macro/wrap (|>> (<load> value) <wrap>)))]

  [translate-i64  Int  $i.long   ($i.wrap #$.Long)]
  [translate-f64  Frac $i.double ($i.wrap #$.Double)]
  [translate-text Text $i.string id]
  )