{
USE_OPLINE
zend_free_op free_op1, free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = EX_CONSTANT(opline->op2);
+ if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if (IS_CONST == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = EX_CONSTANT(opline->op2);
- do {
- if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_VAR != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if (IS_CONST == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, IS_CONST);
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_VAR != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = EX_CONSTANT(opline->op2);
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_VAR != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if (IS_CONST == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
FREE_OP(free_op_data1);
if (UNEXPECTED(free_op1)) {zval_ptr_dtor_nogc(free_op1);};
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- EX_CONSTANT(opline->op2);
+ dim = EX_CONSTANT(opline->op2);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- EX_CONSTANT(opline->op2);
+ dim = EX_CONSTANT(opline->op2);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- EX_CONSTANT(opline->op2);
+ dim = EX_CONSTANT(opline->op2);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- EX_CONSTANT(opline->op2);
+ dim = EX_CONSTANT(opline->op2);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
{
USE_OPLINE
zend_free_op free_op1, free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = NULL;
+ if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if (IS_UNUSED == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = NULL;
- do {
- if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_VAR != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if (IS_UNUSED == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, IS_UNUSED);
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_VAR != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = NULL;
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_VAR != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if (IS_UNUSED == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
FREE_OP(free_op_data1);
if (UNEXPECTED(free_op1)) {zval_ptr_dtor_nogc(free_op1);};
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- NULL;
+ dim = NULL;
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- NULL;
+ dim = NULL;
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- NULL;
+ dim = NULL;
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- NULL;
+ dim = NULL;
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
{
USE_OPLINE
zend_free_op free_op1, free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
+ if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if (IS_CV == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
- do {
- if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_VAR != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if (IS_CV == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, IS_CV);
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_VAR != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_VAR != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if (IS_CV == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
FREE_OP(free_op_data1);
if (UNEXPECTED(free_op1)) {zval_ptr_dtor_nogc(free_op1);};
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
{
USE_OPLINE
zend_free_op free_op1, free_op2, free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ if (IS_VAR != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
- do {
- if (IS_VAR == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_VAR != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if ((IS_TMP_VAR|IS_VAR) == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, (IS_TMP_VAR|IS_VAR));
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_VAR != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_VAR == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_VAR != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
zval_ptr_dtor_nogc(free_op2);
FREE_OP(free_op_data1);
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_VAR != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
{
USE_OPLINE
zend_free_op free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = EX_CONSTANT(opline->op2);
+ if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if (IS_CONST == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = EX_CONSTANT(opline->op2);
- do {
- if (IS_UNUSED == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_UNUSED != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if (IS_CONST == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, IS_CONST);
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_UNUSED != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = EX_CONSTANT(opline->op2);
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_UNUSED != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if (IS_CONST == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
FREE_OP(free_op_data1);
{
USE_OPLINE
zend_free_op free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = NULL;
+ if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if (IS_UNUSED == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = NULL;
- do {
- if (IS_UNUSED == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_UNUSED != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if (IS_UNUSED == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, IS_UNUSED);
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_UNUSED != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = NULL;
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_UNUSED != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if (IS_UNUSED == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
FREE_OP(free_op_data1);
{
USE_OPLINE
zend_free_op free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
+ if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if (IS_CV == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
- do {
- if (IS_UNUSED == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_UNUSED != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if (IS_CV == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, IS_CV);
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_UNUSED != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_UNUSED != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if (IS_CV == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
FREE_OP(free_op_data1);
{
USE_OPLINE
zend_free_op free_op2, free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ if (IS_UNUSED != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
- do {
- if (IS_UNUSED == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_UNUSED != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if ((IS_TMP_VAR|IS_VAR) == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, (IS_TMP_VAR|IS_VAR));
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_UNUSED != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_UNUSED == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_UNUSED != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
zval_ptr_dtor_nogc(free_op2);
FREE_OP(free_op_data1);
{
USE_OPLINE
zend_free_op free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = EX_CONSTANT(opline->op2);
+ if (IS_CV != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if (IS_CONST == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = EX_CONSTANT(opline->op2);
- do {
- if (IS_CV == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_CV != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if (IS_CONST == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, IS_CONST);
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_CV != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = EX_CONSTANT(opline->op2);
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_CV != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if (IS_CONST == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
FREE_OP(free_op_data1);
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- EX_CONSTANT(opline->op2);
+ dim = EX_CONSTANT(opline->op2);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- EX_CONSTANT(opline->op2);
+ dim = EX_CONSTANT(opline->op2);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- EX_CONSTANT(opline->op2);
+ dim = EX_CONSTANT(opline->op2);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- EX_CONSTANT(opline->op2);
+ dim = EX_CONSTANT(opline->op2);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
{
USE_OPLINE
zend_free_op free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = NULL;
+ if (IS_CV != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if (IS_UNUSED == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = NULL;
- do {
- if (IS_CV == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_CV != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if (IS_UNUSED == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if (IS_UNUSED == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, IS_UNUSED);
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_CV != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = NULL;
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_CV != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if (IS_UNUSED == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
FREE_OP(free_op_data1);
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- NULL;
+ dim = NULL;
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- NULL;
+ dim = NULL;
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- NULL;
+ dim = NULL;
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- NULL;
+ dim = NULL;
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
{
USE_OPLINE
zend_free_op free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
+ if (IS_CV != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if (IS_CV == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = _get_zval_ptr_cv_undef(execute_data, opline->op2.var);
- do {
- if (IS_CV == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_CV != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if (IS_CV == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, IS_CV);
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_CV != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_CV != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if (IS_CV == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
FREE_OP(free_op_data1);
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
+ dim = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op2.var);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
{
USE_OPLINE
zend_free_op free_op2, free_op_data1;
- zval *var_ptr, rv;
+ zval *var_ptr;
zval *value, *container, *dim;
SAVE_OPLINE();
HANDLE_EXCEPTION();
}
- dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ if (IS_CV != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+assign_dim_op_array:
+ SEPARATE_ARRAY(container);
+assign_dim_op_new_array:
+ if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) {
+ var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
+ if (UNEXPECTED(!var_ptr)) {
+ zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
+ goto assign_dim_op_ret_null;
+ }
+ } else {
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
- do {
- if (IS_CV == IS_UNUSED || UNEXPECTED(Z_TYPE_P(container) != IS_ARRAY)) {
- if (IS_CV != IS_UNUSED) {
- ZVAL_DEREF(container);
+ if ((IS_TMP_VAR|IS_VAR) == IS_CONST) {
+ var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
+ } else {
+ var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
}
- if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
- if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(dim) == IS_UNDEF)) {
- dim = GET_OP2_UNDEF_CV(dim, BP_VAR_R);
- }
- value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
- break;
+ if (UNEXPECTED(!var_ptr)) {
+ goto assign_dim_op_ret_null;
}
+ ZVAL_DEREF(var_ptr);
+ SEPARATE_ZVAL_NOREF(var_ptr);
}
- zend_fetch_dimension_address_RW(&rv, container, dim, (IS_TMP_VAR|IS_VAR));
value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
- if (UNEXPECTED(Z_ISERROR(rv))) {
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_NULL(EX_VAR(opline->result.var));
+ binary_op(var_ptr, var_ptr, value);
+
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ }
+ } else {
+ if (IS_CV != IS_UNUSED) {
+ if (EXPECTED(Z_ISREF_P(container))) {
+ container = Z_REFVAL_P(container);
+ if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
+ goto assign_dim_op_array;
+ }
+ } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
+ container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
+ goto assign_dim_op_convert_to_array;
}
- } else {
- ZEND_ASSERT(Z_TYPE(rv) == IS_INDIRECT);
- var_ptr = Z_INDIRECT(rv);
- ZVAL_DEREF(var_ptr);
- SEPARATE_ZVAL_NOREF(var_ptr);
+ }
- binary_op(var_ptr, var_ptr, value);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
- if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
- ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
+ if (IS_CV == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
+ zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
+ } else if (IS_CV != IS_UNUSED) {
+ if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
+ if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
+ zval_ptr_dtor_nogc(container);
+assign_dim_op_convert_to_array:
+ ZVAL_NEW_ARR(container);
+ zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
+ goto assign_dim_op_new_array;
+ }
+
+ if ((IS_TMP_VAR|IS_VAR) == IS_UNUSED) {
+ zend_throw_error(NULL, "[] operator not supported for strings");
+ } else {
+ zend_check_string_offset(dim, BP_VAR_RW);
+ zend_wrong_string_offset();
+ }
+ } else {
+ if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
+ goto assign_dim_op_convert_to_array;
+ }
+ if (UNEXPECTED(!Z_ISERROR_P(container))) {
+ zend_error(E_WARNING, "Cannot use a scalar value as an array");
+ }
+assign_dim_op_ret_null:
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_NULL(EX_VAR(opline->result.var));
+ }
}
+ value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
}
- } while (0);
+ }
zval_ptr_dtor_nogc(free_op2);
FREE_OP(free_op_data1);
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
assign_dim_error:
zval_ptr_dtor_nogc(EX_VAR((opline+1)->op1.var));
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
if (IS_CV != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
zend_error(E_WARNING, "Cannot use a scalar value as an array");
}
- _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
+ dim = _get_zval_ptr_var(opline->op2.var, execute_data, &free_op2);
assign_dim_error:
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {