blob: 4fa032f7fe9070ae9d7d5cb0cfb0c199955dc5ce (
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
(.module:
[lux #*
[control
[monad (#+ do)]]
[data
["." error]
["." text
format]]
["." io (#+ IO Process io)]
[time
["." instant]]
[cli (#+ program:)]
[world
["." file (#+ File)]
["." console]]
[platform
["." compiler
["." cli (#+ Configuration)]
[meta
["." archive]
[io
["." context]]]
["." phase
["." translation]
["." statement]]
[default
["." platform (#+ Platform)]
["." init]
["." syntax]]]]
## ["." interpreter]
]
[luxc
[lang
["." host/jvm]
[translation
["." jvm
["." runtime]
["." expression]
[procedure
["." common]]]]]])
(def: (or-crash! failure-description action)
(All [a]
(-> Text (Process a) (IO a)))
(do io.Monad<IO>
[?output action]
(case ?output
(#error.Error error)
(exec (log! (format text.new-line
failure-description text.new-line
error text.new-line))
(io.exit +1))
(#error.Success output)
(wrap output))))
(def: (timed action)
(All [a]
(-> (-> Any (Process a)) (Process a)))
(do io.Monad<Process>
[start (io.from-io instant.now)
result (action [])
finish (io.from-io instant.now)
#let [elapsed-time (instant.span start finish)
_ (log! (format text.new-line
"Elapsed time: " (%duration elapsed-time)))]]
(wrap result)))
(def: jvm-platform
(IO (Platform Process host/jvm.Anchor host/jvm.Inst host/jvm.Definition))
(do io.Monad<IO>
[host jvm.init]
(wrap {#platform.host host
#platform.phase expression.translate
#platform.runtime runtime.translate
#platform.file-system file.JVM@System})))
(program: [{service cli.service}]
(do io.Monad<IO>
[platform ..jvm-platform
console (:: @ map error.assume console.open)]
(case service
(#cli.Compilation configuration)
(<| (or-crash! "Compilation failed:")
..timed
(function (_ _)
(do (:: (get@ #platform.file-system platform) &monad)
[state (platform.initialize platform common.bundle)
_ (platform.compile platform (set@ #cli.module syntax.prelude configuration) state)
## _ (compile platform configuration state)
## _ (cache/io.clean target ...)
]
(wrap (log! "Compilation complete!")))))
(#cli.Interpretation configuration)
## TODO: Fix the interpreter...
(undefined)
## (<| (or-crash! "Interpretation failed:")
## (interpreter.run io.Monad<Process> console platform configuration common.bundle))
)))
|