aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/expression.jvm.lux
blob: df126628ce17237e7085f7a252b92d559dd7d488 (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
(.module:
  [lux #*
   [language
    [compiler
     ["." synthesis]
     ["." extension]]]]
  [luxc
   [lang
    [host
     [jvm (#+ Compiler)]]]]
  [//
   ["." common]
   ["." primitive]
   ["." structure]
   ["." reference]
   ["." case]
   ["." loop]
   ["." function]])

(def: #export (translate synthesis)
  Compiler
  (case synthesis
    (^ (synthesis.bit value))
    (primitive.bit value)
    
    (^ (synthesis.i64 value))
    (primitive.i64 value)
    
    (^ (synthesis.f64 value))
    (primitive.f64 value)
    
    (^ (synthesis.text value))
    (primitive.text value)

    (^ (synthesis.variant [lefts right? value]))
    (structure.variant translate lefts right? value)

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

    (^ (synthesis.variable variable))
    (reference.variable variable)

    (^ (synthesis.constant constant))
    (reference.constant constant)

    (^ (synthesis.branch/let [input register expr]))
    (case.let translate input register expr)

    (^ (synthesis.branch/if [test then else]))
    (case.if translate test then else)

    (^ (synthesis.branch/case [input path]))
    (case.case translate input path)

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

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

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

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

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