1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-25 22:53:16 +00:00

Update printing for operating on pointers.

This commit is contained in:
Calvin Rose 2023-09-05 17:01:31 -05:00
parent efbc46c69e
commit 97963d1396

View File

@ -1149,7 +1149,7 @@ static void emit_binop(JanetSysIR *ir, JanetBuffer *buffer, JanetBuffer *tempbuf
/* Add nested for loops for any dimensionality of array */
while (ir->type_defs[operand_type].prim == JANET_PRIM_ARRAY) {
/* TODO - turn to do while to handle max uint32_t size */
/* TODO - handle fixed_count == SIZE_MAX */
janet_formatb(buffer, "for (size_t _j%u = 0; _j%u < %u; _j%u++) ",
index_index, index_index,
ir->type_defs[operand_type].array.fixed_count,
@ -1164,12 +1164,20 @@ static void emit_binop(JanetSysIR *ir, JanetBuffer *buffer, JanetBuffer *tempbuf
index_index++;
}
Janet index_part = janet_wrap_buffer(tempbuf);
janet_formatb(buffer, "_r%u%V = _r%u%V %s _r%u%V;\n",
instruction.three.dest, index_part,
instruction.three.lhs, index_part,
op,
instruction.three.rhs, index_part);
if (is_pointer) {
janet_formatb(buffer, "*_r%u = *_r%u %s *_r%u;\n",
instruction.three.dest,
instruction.three.lhs,
op,
instruction.three.rhs);
} else {
Janet index_part = janet_wrap_buffer(tempbuf);
janet_formatb(buffer, "_r%u%V = _r%u%V %s _r%u%V;\n",
instruction.three.dest, index_part,
instruction.three.lhs, index_part,
op,
instruction.three.rhs, index_part);
}
}
void janet_sys_ir_lower_to_c(JanetSysIR *ir, JanetBuffer *buffer) {