aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/translation/js/primitive.lux
blob: 139fcb1914afac4fe43efe7886209e2444f4cdc3 (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
38
(.module:
  [lux (#- i64)
   [control
    [pipe (#+ cond> new>)]]
   [data
    [number
     ["." frac]]]
   [host
    ["_" js (#+ Computation)]]]
  [//
   ["//." runtime]])

(def: #export bit
  (-> Bit Computation)
  _.boolean)

(def: #export (i64 value)
  (-> (I64 Any) Computation)
  (//runtime.i64//new (|> value //runtime.high .int _.i32)
                      (|> value //runtime.low .int _.i32)))

(def: #export f64
  (-> Frac Computation)
  (|>> (cond> [(f/= frac.positive-infinity)]
              [(new> _.positive-infinity [])]
              
              [(f/= frac.negative-infinity)]
              [(new> _.negative-infinity [])]
              
              [(f/= frac.not-a-number)]
              [(new> _.not-a-number [])]
              
              ## else
              [_.number])))

(def: #export text
  (-> Text Computation)
  _.string)