mirror of
https://github.com/php/php-src.git
synced 2026-04-24 16:38:25 +02:00
Export zend_unary_op_produces_error() and use in optimizer
Don't repeat this logic, as it's going to become more complex.
This commit is contained in:
@@ -64,11 +64,7 @@ int zend_optimizer_eval_unary_op(zval *result, zend_uchar opcode, zval *op1) /*
|
||||
unary_op_type unary_op = get_unary_op(opcode);
|
||||
|
||||
if (unary_op) {
|
||||
if (opcode == ZEND_BW_NOT
|
||||
&& Z_TYPE_P(op1) != IS_LONG
|
||||
&& Z_TYPE_P(op1) != IS_DOUBLE
|
||||
&& Z_TYPE_P(op1) != IS_STRING) {
|
||||
/* produces "Unsupported operand types" exception */
|
||||
if (zend_unary_op_produces_error(opcode, op1)) {
|
||||
return FAILURE;
|
||||
}
|
||||
return unary_op(result, op1);
|
||||
|
||||
+1
-1
@@ -8223,7 +8223,7 @@ static inline bool zend_try_ct_eval_binary_op(zval *result, uint32_t opcode, zva
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
bool zend_unary_op_produces_error(uint32_t opcode, zval *op)
|
||||
ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op)
|
||||
{
|
||||
if (opcode == ZEND_BW_NOT) {
|
||||
return Z_TYPE_P(op) <= IS_TRUE || Z_TYPE_P(op) == IS_ARRAY;
|
||||
|
||||
@@ -1163,5 +1163,6 @@ END_EXTERN_C()
|
||||
#define ZEND_COMPILE_DEFAULT_FOR_EVAL 0
|
||||
|
||||
ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zval *op2);
|
||||
ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, zval *op);
|
||||
|
||||
#endif /* ZEND_COMPILE_H */
|
||||
|
||||
Reference in New Issue
Block a user