aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;