aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/primitive.lux
blob: 6903b065d0fd10a12ba0aca06e1f116d4f9d9baa (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)
   [target
    [jvm
     ["." descriptor]
     ["$t" type]]]
   [tool
    [compiler
     [phase ("operation@." monad)]]]]
  [luxc
   [lang
    [host
     ["." jvm (#+ Inst Operation)
      ["_" inst]]]]])

(def: #export bit
  (-> Bit (Operation Inst))
  (let [Boolean (descriptor.class "java.lang.Boolean")]
    (function (_ value)
      (operation@wrap (_.GETSTATIC Boolean (if value "TRUE" "FALSE") Boolean)))))

(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 descriptor.long)]
  [f64  Frac      _.double         (_.wrap descriptor.double)]
  [text Text      _.string         (<|)]
  )