aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/generation/js.lux
blob: df0db4c79d87c31865d01e566a0a845154f9332d (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 ("#/." system)]
   ["." function]
   ["." case]
   ["." loop]
   ["." ///
    ["." extension]
    [//
     ["." synthesis]]]])

(def: #export (generate 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 generate variantS)

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

    (#synthesis.Reference value)
    (reference/reference value)

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

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

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

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

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

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

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

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