aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-11-02 14:07:46 +0100
committerBad Diode <bd@badd10de.dev>2021-11-02 14:07:46 +0100
commitfedab6bac08333ca31e69f21add7b66c575ec87c (patch)
treeee40a85250e04a632ba674b29767bf5d270731d0 /src/compiler.h
parent9866fad84ada32ef4f386e8be6ca09bd3711f034 (diff)
downloadbdl-fedab6bac08333ca31e69f21add7b66c575ec87c.tar.gz
bdl-fedab6bac08333ca31e69f21add7b66c575ec87c.zip
Add compilation of `display` primitive
Diffstat (limited to 'src/compiler.h')
-rw-r--r--src/compiler.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/compiler.h b/src/compiler.h
index 76d6ccf..18e8a3e 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -139,6 +139,12 @@ compile_type_predicate(OpType op, Object* args) {
139 printf(" ;; <-- compile_type_predicate\n"); 139 printf(" ;; <-- compile_type_predicate\n");
140} 140}
141 141
142
143// TODO: Next -> numerical comparison operators =, <=, ...
144// "=", "<", ">", "<=", ">=",
145// "not", "and", "or",
146// NOTE: Make sure to stop evaluating if the condition is not met.
147
142void 148void
143compile_arithmetic_list(OpType op, Object* args) { 149compile_arithmetic_list(OpType op, Object* args) {
144 printf(" ;; --> compile_arithmetic_list\n"); 150 printf(" ;; --> compile_arithmetic_list\n");
@@ -183,6 +189,11 @@ compile_proc_call(Object *obj) {
183 if (sv_equal(&obj->head->text, &STRING("bool?"))) { 189 if (sv_equal(&obj->head->text, &STRING("bool?"))) {
184 compile_type_predicate(OP_IS_BOOL, obj->tail); 190 compile_type_predicate(OP_IS_BOOL, obj->tail);
185 } 191 }
192 if (sv_equal(&obj->head->text, &STRING("display"))) {
193 compile_object(obj->tail->head);
194 printf(" pop rdi\n");
195 printf(" call display\n");
196 }
186} 197}
187 198
188void 199void
@@ -199,6 +210,14 @@ compile_object(Object *obj) {
199 210
200void 211void
201compile(Root *roots) { 212compile(Root *roots) {
213 printf("%%define NIL_VAL %d\n", NIL_VAL);
214 printf("%%define BOOL_MASK %d\n", BOOL_MASK);
215 printf("%%define BOOL_TAG %d\n", BOOL_TAG);
216 printf("%%define BOOL_SHIFT %d\n", BOOL_SHIFT);
217 printf("%%define FIXNUM_MASK %d\n", FIXNUM_MASK);
218 printf("%%define FIXNUM_TAG %d\n", FIXNUM_TAG);
219 printf("%%define FIXNUM_SHIFT %d\n", FIXNUM_SHIFT);
220 printf("\n");
202 emit_file(PRELUDE_FILE); 221 emit_file(PRELUDE_FILE);
203 for (size_t i = 0; i < array_size(roots); i++) { 222 for (size_t i = 0; i < array_size(roots); i++) {
204 Object *root = roots[i]; 223 Object *root = roots[i];