Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions Zend/zend_operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "zend_strtod.h"
#include "zend_exceptions.h"
#include "zend_closures.h"
#include "zend_interfaces.h"

#if ZEND_USE_TOLOWER_L
#include <locale.h>
Expand Down Expand Up @@ -923,6 +924,19 @@ static zend_always_inline int add_function_fast(zval *result, zval *op1, zval *o
} else if (EXPECTED(type_pair == TYPE_PAIR(IS_ARRAY, IS_ARRAY))) {
add_function_array(result, op1, op2);
return SUCCESS;
} else if (EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_ARRAY)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_DOUBLE)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_LONG))
) {
zend_call_method_with_1_params(op1, Z_OBJCE_P(op1), NULL, "__add", result, op2);
return SUCCESS;
} else if (EXPECTED(type_pair == TYPE_PAIR(IS_ARRAY, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_LONG, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_OBJECT))
) {
zend_call_method_with_1_params(op2, Z_OBJCE_P(op2), NULL, "__add", result, op1);
return SUCCESS;
} else {
return FAILURE;
}
Expand Down Expand Up @@ -994,7 +1008,20 @@ static zend_always_inline int sub_function_fast(zval *result, zval *op1, zval *o
} else if (EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_LONG))) {
ZVAL_DOUBLE(result, Z_DVAL_P(op1) - ((double)Z_LVAL_P(op2)));
return SUCCESS;
} else {
} else if (EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_ARRAY)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_DOUBLE)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_LONG))
) {
zend_call_method_with_1_params(op1, Z_OBJCE_P(op1), NULL, "__sub", result, op2);
return SUCCESS;
} else if (EXPECTED(type_pair == TYPE_PAIR(IS_ARRAY, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_LONG, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_OBJECT))
) {
zend_call_method_with_1_params(op2, Z_OBJCE_P(op2), NULL, "__sub", result, op1);
return SUCCESS;
} else {
return FAILURE;
}
}
Expand Down Expand Up @@ -1077,7 +1104,19 @@ ZEND_API int ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* {
} else if (EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_LONG))) {
ZVAL_DOUBLE(result, Z_DVAL_P(op1) * ((double)Z_LVAL_P(op2)));
return SUCCESS;

} else if (EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_ARRAY)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_DOUBLE)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_LONG))
) {
zend_call_method_with_1_params(op1, Z_OBJCE_P(op1), NULL, "__mul", result, op2);
return SUCCESS;
} else if (EXPECTED(type_pair == TYPE_PAIR(IS_ARRAY, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_LONG, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_OBJECT))
) {
zend_call_method_with_1_params(op2, Z_OBJCE_P(op2), NULL, "__mul", result, op1);
return SUCCESS;
} else {
if (Z_ISREF_P(op1)) {
op1 = Z_REFVAL_P(op1);
Expand Down Expand Up @@ -1265,7 +1304,19 @@ ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {
}
ZVAL_DOUBLE(result, (double)Z_LVAL_P(op1) / Z_DVAL_P(op2));
return SUCCESS;

} else if (EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_ARRAY)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_DOUBLE)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_OBJECT, IS_LONG))
) {
zend_call_method_with_1_params(op1, Z_OBJCE_P(op1), NULL, "__div", result, op2);
return SUCCESS;
} else if (EXPECTED(type_pair == TYPE_PAIR(IS_ARRAY, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_LONG, IS_OBJECT)) ||
EXPECTED(type_pair == TYPE_PAIR(IS_DOUBLE, IS_OBJECT))
) {
zend_call_method_with_1_params(op2, Z_OBJCE_P(op2), NULL, "__div", result, op1);
return SUCCESS;
} else {
if (Z_ISREF_P(op1)) {
op1 = Z_REFVAL_P(op1);
Expand Down