aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/translation/js/expression.lux
blob: 822f51e35c2c188f9951ddf86d42935358634a44 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(.module:
  [lux #*
   [control
    [monad (#+ do)]]]
  [//
   [runtime (#+ Phase)]
   ["." primitive]
   ["." structure]
   ["." reference]
   ["." function]
   ["." case]
   ["." loop]
   ["." ///
    ["." extension]
    [//
     ["." synthesis]]]])

(def: #export (translate synthesis)
  Phase
  (case synthesis
    (^template [<tag> <generator>]
      (^ (<tag> value))
      (:: ///.monad wrap (<generator> value)))
    ([synthesis.bit  primitive.bit]
     [synthesis.i64  primitive.i64]
     [synthesis.f64  primitive.f64]
     [synthesis.text primitive.text])

    (^ (synthesis.variant variantS))
    (structure.variant translate variantS)

    (^ (synthesis.tuple members))
    (structure.tuple translate members)

    (#synthesis.Reference value)
    (:: reference.system reference value)

    (^ (synthesis.branch/case case))
    (case.case translate case)

    (^ (synthesis.branch/let let))
    (case.let translate let)

    (^ (synthesis.branch/if if))
    (case.if translate if)

    (^ (synthesis.loop/scope scope))
    (loop.scope translate scope)

    (^ (synthesis.loop/recur updates))
    (loop.recur translate updates)

    (^ (synthesis.function/abstraction abstraction))
    (function.function translate abstraction)

    (^ (synthesis.function/apply application))
    (function.apply translate application)

    (#synthesis.Extension extension)
    (extension.apply translate extension)))