aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-12-22 18:33:20 +0100
committerBad Diode <bd@badd10de.dev>2021-12-22 18:33:20 +0100
commit7146084c7730274c7739db5e1ede7e5ee910b237 (patch)
tree80a8bc7ea5ac730973f054f20dd0ea9c58e467be
parentd2ed5f0298b24bb1131f8eddd1668639c14c7717 (diff)
downloadbdl-7146084c7730274c7739db5e1ede7e5ee910b237.tar.gz
bdl-7146084c7730274c7739db5e1ede7e5ee910b237.zip
Add print to ir compilation
-rw-r--r--src/ir.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ir.h b/src/ir.h
index a42cd48..845bf63 100644
--- a/src/ir.h
+++ b/src/ir.h
@@ -128,6 +128,17 @@ compile_arithmetic(ProgramIr *program, Procedure *proc, Op op,
128} 128}
129 129
130void 130void
131compile_print(ProgramIr *program, Procedure *proc,
132 size_t line, size_t col, Object *args) {
133 Instruction inst = (Instruction){OP_PRINT, NULL, line, col};
134 while (args != NULL) {
135 compile_object(program, proc, args->head);
136 args = args->tail;
137 array_push(proc->instructions, inst);
138 }
139}
140
141void
131compile_proc_call(ProgramIr *program, Procedure *proc, Object *obj) { 142compile_proc_call(ProgramIr *program, Procedure *proc, Object *obj) {
132 size_t line = obj->line; 143 size_t line = obj->line;
133 size_t col = obj->col; 144 size_t col = obj->col;
@@ -148,6 +159,9 @@ compile_proc_call(ProgramIr *program, Procedure *proc, Object *obj) {
148 case BUILTIN_MOD: { 159 case BUILTIN_MOD: {
149 compile_arithmetic(program, proc, OP_MOD, line, col, obj->tail); 160 compile_arithmetic(program, proc, OP_MOD, line, col, obj->tail);
150 } break; 161 } break;
162 case BUILTIN_PRINT: {
163 compile_print(program, proc, line, col, obj->tail);
164 } break;
151 default: { 165 default: {
152 assert(false && "builtin not implemented"); 166 assert(false && "builtin not implemented");
153 } break; 167 } break;