aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/generation/jvm.lux
blob: eed30cf71d0066e679228a152d963a7a3344c5df (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
61
62
63
64
65
66
67
68
(.module:
  [lux #*
   [abstract
    [monad (#+ do)]]]
  ["." / #_
   [runtime (#+ Phase)]
   ["#." primitive]
   ["#." structure]
   ["#." reference]
   ["#." function]
   ["#." case]
   ["#." loop]
   ["//#" ///
    ["#." extension]
    [//
     [analysis (#+)]
     ["." synthesis]
     ["." reference]]]])

(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 reference)
    (case reference
      (#reference.Variable variable)
      (/reference.variable variable)
      
      (#reference.Constant constant)
      (/reference.constant constant))

    (^ (synthesis.branch/case [valueS pathS]))
    (/case.case generate valueS pathS)

    (^ (synthesis.branch/let [inputS register bodyS]))
    (/case.let generate inputS register bodyS)

    (^ (synthesis.branch/if [conditionS thenS elseS]))
    (/case.if generate conditionS thenS elseS)

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

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

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

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

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