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

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

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

  [i64  (I64 Any) (<| _.long .int) (_.wrap #jvm.Long)]
  [f64  Frac      _.double         (_.wrap #jvm.Double)]
  [text Text      _.string         (<|)]
  )