feat: optimize VM using dispatch table
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#include <vm/fzl_vm.h>
|
||||
#include <vm/internals/opcode.h>
|
||||
|
||||
int op_not(fzl_vm_t *vm)
|
||||
{
|
||||
if (vm->dtop < 1)
|
||||
{
|
||||
snprintf(last_err, sizeof(last_err),
|
||||
"runtime error - expected value in data stack");
|
||||
print_err_data(vm);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fzl_value_t notval = vm->dstack[--vm->dtop];
|
||||
vm->dstack[vm->dtop++] =
|
||||
(fzl_value_t){.type = FZL_TYPE_BOOL, .as.b = !notval.as.b};
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user