aboutsummaryrefslogtreecommitdiffstats
path: root/src/bootstrap/main.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-15 17:58:05 +0200
committerBad Diode <bd@badd10de.dev>2021-10-15 17:58:05 +0200
commit87b1a0d4a833dd0b2164481be45f7d1c59375040 (patch)
tree87828c2149c7db2880b22a306b2c5d3511185cae /src/bootstrap/main.c
parent14814ecbf53760654aab34e0613abf347a54113f (diff)
downloadbdl-87b1a0d4a833dd0b2164481be45f7d1c59375040.tar.gz
bdl-87b1a0d4a833dd0b2164481be45f7d1c59375040.zip
Add boilerplate for GC allocator
Diffstat (limited to 'src/bootstrap/main.c')
-rwxr-xr-xsrc/bootstrap/main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bootstrap/main.c b/src/bootstrap/main.c
index 5191fd0..575a924 100755
--- a/src/bootstrap/main.c
+++ b/src/bootstrap/main.c
@@ -1,6 +1,7 @@
1#include <assert.h> 1#include <assert.h>
2#include <getopt.h> 2#include <getopt.h>
3#include <stdbool.h> 3#include <stdbool.h>
4#include <stdint.h>
4#include <stdio.h> 5#include <stdio.h>
5#include <stdlib.h> 6#include <stdlib.h>
6#include <string.h> 7#include <string.h>
@@ -12,6 +13,7 @@
12#include "objects.c" 13#include "objects.c"
13#include "parser.c" 14#include "parser.c"
14#include "environment.c" 15#include "environment.c"
16#include "gc.c"
15#include "primitives.c" 17#include "primitives.c"
16 18
17// 19//
@@ -26,6 +28,9 @@
26 28
27void 29void
28init(void) { 30init(void) {
31 // Initialize garbage collector.
32 init_gc();
33
29 // Initialize singletons. 34 // Initialize singletons.
30 obj_nil = alloc_object(OBJ_TYPE_NIL); 35 obj_nil = alloc_object(OBJ_TYPE_NIL);
31 obj_true = alloc_object(OBJ_TYPE_BOOL); 36 obj_true = alloc_object(OBJ_TYPE_BOOL);
@@ -99,7 +104,6 @@ process_source(const StringView *source) {
99 while (has_next_token(&visitor) && peek_token(&visitor).type != TOKEN_EOF) { 104 while (has_next_token(&visitor) && peek_token(&visitor).type != TOKEN_EOF) {
100 Object *root = parse_tree(&visitor); 105 Object *root = parse_tree(&visitor);
101 if (root == obj_err || errors_n != 0) { 106 if (root == obj_err || errors_n != 0) {
102 free_objects(root);
103 break; 107 break;
104 } 108 }
105 109
@@ -109,7 +113,6 @@ process_source(const StringView *source) {
109 display(result); 113 display(result);
110 printf("\n"); 114 printf("\n");
111 } 115 }
112 free_objects(root);
113 } 116 }
114 117
115 if (tokens.buf != NULL) { 118 if (tokens.buf != NULL) {