aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/generator/primitive.jvm.lux
blob: 2cb01a6aa11afc1bc73206428f1626888737e04a (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
(;module:
  lux
  (lux (control monad)
       (data text/format)
       [macro #+ Monad<Lux> "Lux/" Monad<Lux>])
  (luxc ["&" base]
        (lang ["la" analysis]
              ["ls" synthesis])
        ["&;" analyser]
        ["&;" synthesizer]
        (generator ["&;" common]
                   (host ["$" jvm]
                         (jvm ["$i" inst]
                              ["$t" type]))))
  [../runtime])

(def: #export generate-unit
  (Lux $;Inst)
  (Lux/wrap ($i;string ../runtime;unit)))

(def: #export (generate-bool value)
  (-> Bool (Lux $;Inst))
  (Lux/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> (Lux $;Inst))
     (Lux/wrap (|>. (<load> value) <wrap>)))]

  [generate-nat  Nat  (|>. (:! Int) $i;long) $i;wrap-long]
  [generate-int  Int  $i;long $i;wrap-long]
  [generate-deg  Deg  (|>. (:! Int) $i;long) $i;wrap-long]
  [generate-real Real $i;double $i;wrap-double]
  [generate-text Text $i;string id]
  )