Browse Source

Do not make a routine for executables with no code to execute

main
Ludovic 'Archivist' Lagouardette 6 months ago
parent
commit
80087bc851
2 changed files with 21 additions and 17 deletions
  1. +20
    -16
      lib.c
  2. +1
    -1
      test/test01.nk

+ 20
- 16
lib.c View File

@ -807,22 +807,26 @@ void ink_compile(struct context *pContext, const char* buffer) {
pContext->panic = 1;
return;
}
integer = ink_itoa(pContext, routine);
integer_size = strlen(integer);
memcpy(main_fn+10, integer, integer_size);
pContext->free(integer);
main_fn[10+integer_size] = 0;
frame.executing.value = ink_add_indigenous(pContext, main_fn, executable_buffer, executable_buffer_top);
if(frame.executing.value < 0) {
pContext->panic = 1;
return;
}
frame.executing.type = INK_FUNCTION;
frame.index = 0;
err = ink_push_fn(pContext, frame);
if(err < 0) {
pContext->panic = 1;
return;
if(executable_buffer_top != 0) {
integer = ink_itoa(pContext, routine);
integer_size = strlen(integer);
memcpy(main_fn + 10, integer, integer_size);
pContext->free(integer);
main_fn[10 + integer_size] = 0;
frame.executing.value = ink_add_indigenous(pContext, main_fn, executable_buffer, executable_buffer_top);
if (frame.executing.value < 0) {
pContext->panic = 1;
return;
}
frame.executing.type = INK_FUNCTION;
frame.index = 0;
err = ink_push_fn(pContext, frame);
if (err < 0) {
pContext->panic = 1;
return;
}
} else {
pContext->routines[pContext->routine_current].panic = INK_ROUTINE_SUCCESS;
}
pContext->routine_current = saved;

+ 1
- 1
test/test01.nk View File

@ -71,4 +71,4 @@ fn string.dump do
# array end it
93 print_utf8
drop drop drop
end
end

Loading…
Cancel
Save