blob: b2e4923c495046eb0170e07e53e12b067c63fdde (
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
|
(;module:
lux
(lux (control monad)
(data text/format)
[macro #+ Monad<Lux> "Lux/" Monad<Lux>]
[host #+ jvm-import])
(luxc ["&" base]
(lang ["la" analysis]
["ls" synthesis])
["&;" analyser]
["&;" synthesizer]
(compiler ["&;" common])))
(jvm-import #long java.lang.Object)
(jvm-import org.objectweb.asm.Opcodes)
(jvm-import org.objectweb.asm.MethodVisitor
(visitLdcInsn [Object] void))
(def: unit-value Text "\u0000unit\u0000")
(def: (compiler-literal value)
(-> Top (Lux &common;Compiled))
(do Monad<Lux>
[visitor &common;get-visitor
#let [_ (MethodVisitor.visitLdcInsn [(:! java.lang.Object value)])]]
(wrap [])))
(def: (compile-synthesis synthesis)
(-> ls;Synthesis (Lux &common;Compiled))
(case synthesis
#ls;Unit
(compiler-literal &common;unit-value)
(^template [<tag>]
(<tag> value)
(compiler-literal value))
([#ls;Bool]
[#ls;Nat]
[#ls;Int]
[#ls;Deg]
[#ls;Real]
[#ls;Char]
[#ls;Text])
_
(macro;fail "Unrecognized synthesis.")))
(def: (eval type code)
&;Eval
(undefined))
(def: analyse
&;Analyser
(&analyser;analyser eval))
(def: #export (compile input)
(-> Code (Lux &common;Compiled))
(do Monad<Lux>
[analysis (analyse input)]
(compile-synthesis (&synthesizer;synthesize analysis))))
|