aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux
blob: c4b02654138c7144daba4252c504ac679127a347 (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
69
70
71
72
73
74
75
76
77
78
(.using
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [macro
    ["^" pattern]]]]
 ["[0]" /
  [runtime (.only Phase)]
  ["[1][0]" primitive]
  ["[1][0]" structure]
  ["[1][0]" reference]
  ["[1][0]" function]
  ["[1][0]" case]
  ["[1][0]" loop]
  ["//[1]" ///
   ["[1][0]" extension]
   [//
    ["[0]" synthesis]
    [///
     ["[0]" reference]
     ["[1]" phase (.open: "[1]#[0]" monad)]]]]])

(def: .public (generate archive synthesis)
  Phase
  (case synthesis
    (^.template [<tag> <generator>]
      [(pattern (<tag> value))
       (///#in (<generator> value))])
    ([synthesis.bit  /primitive.bit]
     [synthesis.i64  /primitive.i64]
     [synthesis.f64  /primitive.f64]
     [synthesis.text /primitive.text])

    (pattern (synthesis.variant variantS))
    (/structure.variant generate archive variantS)

    (pattern (synthesis.tuple members))
    (/structure.tuple generate archive members)

    {synthesis.#Reference reference}
    (case reference
      {reference.#Variable variable}
      (/reference.variable archive variable)
      
      {reference.#Constant constant}
      (/reference.constant archive constant))

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

    (pattern (synthesis.branch/exec [this that]))
    (/case.exec generate archive [this that])

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

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

    (pattern (synthesis.branch/get [path recordS]))
    (/case.get generate archive [path recordS])

    (pattern (synthesis.loop/scope scope))
    (/loop.scope generate archive scope)

    (pattern (synthesis.loop/again updates))
    (/loop.again generate archive updates)

    (pattern (synthesis.function/abstraction abstraction))
    (/function.abstraction generate archive abstraction)

    (pattern (synthesis.function/apply application))
    (/function.apply generate archive application)

    {synthesis.#Extension extension}
    (///extension.apply archive generate extension)
    ))