summaryrefslogtreecommitdiffhomepage
path: root/vm.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-11-14 22:10:12 +0100
committerJo-Philipp Wich <jo@mein.io>2022-11-15 01:21:32 +0100
commitfdc9b6a3841d7346dab6f4aeea06322be0d3ee95 (patch)
tree39537641aa77efc0202d60fd270a592d4b660070 /vm.c
parent5fd5e8c3d785da27b90320f6ac93853ecf87eeae (diff)
compiler: fix `??=`, `||=` and `&&=` logical assignment semantics
When compiling logical assignment expressions, ensure that the right hand side of the assignment is not evaluated when the assignment condition is unfulfilled. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c28
1 files changed, 0 insertions, 28 deletions
diff --git a/vm.c b/vm.c
index 3bf9836..5bc071b 100644
--- a/vm.c
+++ b/vm.c
@@ -1409,31 +1409,6 @@ uc_vm_value_bitop(uc_vm_t *vm, uc_vm_insn_t operation, uc_value_t *value, uc_val
}
static uc_value_t *
-uc_vm_value_logical(uc_vm_t *vm, uc_vm_insn_t operation, uc_value_t *value, uc_value_t *operand)
-{
- uc_value_t *rv = NULL;
-
- switch (operation) {
- case I_LTRUE:
- rv = ucv_get(ucv_is_truish(value) ? operand : value);
- break;
-
- case I_LFALSE:
- rv = ucv_get(ucv_is_truish(value) ? value : operand);
- break;
-
- case I_LNULL:
- rv = ucv_get(value == NULL ? operand : value);
- break;
-
- default:
- break;
- }
-
- return rv;
-}
-
-static uc_value_t *
uc_vm_string_concat(uc_vm_t *vm, uc_value_t *v1, uc_value_t *v2)
{
char buf[sizeof(void *)], *s1, *s2;
@@ -1492,9 +1467,6 @@ uc_vm_value_arith(uc_vm_t *vm, uc_vm_insn_t operation, uc_value_t *value, uc_val
operation == I_BAND || operation == I_BXOR || operation == I_BOR)
return uc_vm_value_bitop(vm, operation, value, operand);
- if (operation == I_LTRUE || operation == I_LFALSE || operation == I_LNULL)
- return uc_vm_value_logical(vm, operation, value, operand);
-
if (operation == I_ADD && (ucv_type(value) == UC_STRING || ucv_type(operand) == UC_STRING))
return uc_vm_string_concat(vm, value, operand);