Simplify OP_JUMP_IF implementation

Same method as when simplifying OP_POP's implementation: use the
lookup table along with OPCODE_DATA_TYPE abuse.  In this case I made a
lookup table called OP_POP for this method to work, but it wasn't difficult.
This commit is contained in:
2024-04-25 03:01:59 +05:30
parent 81caa577fe
commit c378591e3f
2 changed files with 14 additions and 7 deletions

View File

@@ -89,6 +89,13 @@ err_t vm_pop_byte(vm_t *, data_t *);
err_t vm_pop_hword(vm_t *, data_t *);
err_t vm_pop_word(vm_t *, data_t *);
typedef err_t (*pop_f)(vm_t *, data_t *);
static const pop_f POP_ROUTINES[] = {
[OP_POP_BYTE] = vm_pop_byte,
[OP_POP_HWORD] = vm_pop_hword,
[OP_POP_WORD] = vm_pop_word,
};
err_t vm_push_byte(vm_t *, data_t);
err_t vm_push_hword(vm_t *, data_t);
err_t vm_push_word(vm_t *, data_t);