diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-06-08 13:00:37 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-06-08 13:54:50 +0200 |
commit | 4e410c3411f73da6d27b28ce057159cda7b50b66 (patch) | |
tree | 6fd8ee299fb46c678acce2ce36f7d76fb91a4dbc /vm.c | |
parent | ce6081dbbd588fb111754f3c2c1c93d2421c6ee6 (diff) |
treewide: let uc_cmp() use instruction instead of token numbers
This allows us to drop some token->instruction mapping case switches
in the VM.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 24 |
1 files changed, 2 insertions, 22 deletions
@@ -1634,28 +1634,8 @@ uc_vm_insn_rel(uc_vm *vm, enum insn_type insn) { uc_value_t *r2 = uc_vm_stack_pop(vm); uc_value_t *r1 = uc_vm_stack_pop(vm); - bool res = false; - switch (insn) { - case I_LT: - res = uc_cmp(TK_LT, r1, r2); - break; - - case I_GT: - res = uc_cmp(TK_GT, r1, r2); - break; - - case I_EQ: - res = uc_cmp(TK_EQ, r1, r2); - break; - - case I_NE: - res = uc_cmp(TK_NE, r1, r2); - break; - - default: - break; - } + bool res = uc_cmp(insn, r1, r2); ucv_put(r1); ucv_put(r2); @@ -1679,7 +1659,7 @@ uc_vm_insn_in(uc_vm *vm, enum insn_type insn) arridx < arrlen; arridx++) { item = ucv_array_get(r2, arridx); - if (uc_cmp(TK_EQ, r1, item)) { + if (uc_cmp(I_EQ, r1, item)) { found = true; break; } |