index checks fix

This commit is contained in:
ProgramSnail 2024-11-14 14:14:33 +03:00
parent b198e11416
commit b52a7fcb29
3 changed files with 27 additions and 23 deletions

View file

@ -424,19 +424,20 @@ void run(bytefile *bf, int argc, char **argv) {
case CMD_BUILTIN_Barray: { // CALL Barray %d
size_t elem_count = ip_read_int(&s.ip);
// void **opr_buffer = elem_count > BUFFER_SIZE
// ? alloc(elem_count * sizeof(void *))
// : buffer;
// for (size_t i = 0; i < elem_count; ++i) {
// opr_buffer[elem_count - i - 1] = s_pop();
// }
void **opr_buffer = elem_count > BUFFER_SIZE
? alloc(elem_count * sizeof(void *))
: buffer;
for (size_t i = 0; i < elem_count; ++i) {
opr_buffer[elem_count - i - 1] = s_pop();
}
s_rotate_n(elem_count);
// void *array =
// Barray((aint *)opr_buffer,
// BOX(elem_count)); // NOTE: not shure if elems should be
// added
void *array = Barray((aint *)s_peek(), BOX(elem_count));
// s_rotate_n(elem_count);
void *array =
Barray((aint *)opr_buffer,
BOX(elem_count)); // NOTE: not shure if elems should be
// added
// void *array = Barray((aint *)s_peek(), BOX(elem_count));
s_push(array);
break;
}