-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaot_cli.af
More file actions
45 lines (38 loc) · 761 Bytes
/
Copy pathaot_cli.af
File metadata and controls
45 lines (38 loc) · 761 Bytes
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
use' lang.af
\ ## AOT compilation
\
\ Specify `--build=<out_path>` AFTER the input paths:
\
\ astil examples/aot.af --build=out.exe
\ ./out.exe
\
\ See `./aot.af` for compiling from INSIDE the program.
fun: main { -- exit }
if .has_interp .then
" hello world (JIT mode)!" .log .lf
else
" hello world (AOT-compiled)!" .log .lf
end
\ OK exit code
0
end
\ Run immediately in JIT mode.
.main
\ ## Bonus example
\
\ You can "automatically" make an executable from a REPL session.
\ In your shell:
\
\ astil lang.af - --build=out.exe
\
\ In the Forth REPL:
\
\ fun: main { -- exit } " hello world!" .log .lf 0 end
\ \ Then hit Ctrl+D (not Ctrl+C) to terminate stdin.
\
\ In your shell:
\
\ ./out.exe
\ \ hello world!
\
\ Voila!