blob: 1ece9ae7549f878dea2a27f1f2e6a2900dc569a4 [file] [log] [blame]
swissChilif3e7f182021-04-20 13:57:22 -07001#include "compiler.h"
swissChili53472e82021-05-08 16:06:32 -07002#include "lisp.h"
swissChilie9fec8b2021-06-22 13:59:33 -07003#include "gc.h"
swissChilif68671f2021-07-05 14:14:44 -07004#include "plat/plat.h"
swissChili7a6f5eb2021-04-13 16:46:02 -07005
swissChili53472e82021-05-08 16:06:32 -07006int main(int argc, char **argv)
swissChili7a6f5eb2021-04-13 16:46:02 -07007{
swissChili53472e82021-05-08 16:06:32 -07008 if (argc < 2)
swissChilibed80922021-04-13 21:58:05 -07009 {
swissChilie9fec8b2021-06-22 13:59:33 -070010 puts("pass the program you want to run as the first argument please");
swissChilibed80922021-04-13 21:58:05 -070011 return 1;
12 }
13
swissChilif68671f2021-07-05 14:14:44 -070014 bool ok;
15 struct environment env = compile_file(argv[1], &ok);
swissChili923b5362021-05-09 20:31:43 -070016
swissChilif68671f2021-07-05 14:14:44 -070017 if (!ok)
swissChili923b5362021-05-09 20:31:43 -070018 {
19 fprintf(stderr, "Could not open %s\n", argv[1]);
20 return 1;
21 }
swissChili7a6f5eb2021-04-13 16:46:02 -070022
swissChilie9fec8b2021-06-22 13:59:33 -070023 value_t (*lisp_main)() = find_function(&env, "main")->def0;
24
25 gc_set_base_here();
26 lisp_main();
swissChilib8fd4712021-06-23 15:32:04 -070027
28 free_all();
swissChili708d4c42021-07-04 17:40:07 -070029 del_env(&env);
swissChili7a6f5eb2021-04-13 16:46:02 -070030}