swissChili | f3e7f18 | 2021-04-20 13:57:22 -0700 | [diff] [blame] | 1 | #include "compiler.h" |
swissChili | 53472e8 | 2021-05-08 16:06:32 -0700 | [diff] [blame] | 2 | #include "lisp.h" |
swissChili | e9fec8b | 2021-06-22 13:59:33 -0700 | [diff] [blame] | 3 | #include "gc.h" |
swissChili | f68671f | 2021-07-05 14:14:44 -0700 | [diff] [blame] | 4 | #include "plat/plat.h" |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 5 | |
swissChili | 53472e8 | 2021-05-08 16:06:32 -0700 | [diff] [blame] | 6 | int main(int argc, char **argv) |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 7 | { |
swissChili | 53472e8 | 2021-05-08 16:06:32 -0700 | [diff] [blame] | 8 | if (argc < 2) |
swissChili | bed8092 | 2021-04-13 21:58:05 -0700 | [diff] [blame] | 9 | { |
swissChili | e9fec8b | 2021-06-22 13:59:33 -0700 | [diff] [blame] | 10 | puts("pass the program you want to run as the first argument please"); |
swissChili | bed8092 | 2021-04-13 21:58:05 -0700 | [diff] [blame] | 11 | return 1; |
12 | } | ||||
13 | |||||
swissChili | f68671f | 2021-07-05 14:14:44 -0700 | [diff] [blame] | 14 | bool ok; |
swissChili | 7e1393c | 2021-07-07 12:59:12 -0700 | [diff] [blame^] | 15 | struct environment *env = compile_file(argv[1], &ok); |
swissChili | 923b536 | 2021-05-09 20:31:43 -0700 | [diff] [blame] | 16 | |
swissChili | f68671f | 2021-07-05 14:14:44 -0700 | [diff] [blame] | 17 | if (!ok) |
swissChili | 923b536 | 2021-05-09 20:31:43 -0700 | [diff] [blame] | 18 | { |
19 | fprintf(stderr, "Could not open %s\n", argv[1]); | ||||
20 | return 1; | ||||
21 | } | ||||
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 22 | |
swissChili | 7e1393c | 2021-07-07 12:59:12 -0700 | [diff] [blame^] | 23 | value_t (*lisp_main)() = find_function(env, "main")->def0; |
swissChili | e9fec8b | 2021-06-22 13:59:33 -0700 | [diff] [blame] | 24 | |
25 | gc_set_base_here(); | ||||
26 | lisp_main(); | ||||
swissChili | b8fd471 | 2021-06-23 15:32:04 -0700 | [diff] [blame] | 27 | |
28 | free_all(); | ||||
swissChili | 7e1393c | 2021-07-07 12:59:12 -0700 | [diff] [blame^] | 29 | del_env(env); |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 30 | } |