summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2000-08-04 08:11:54 +0000
committerAndi Gutmans <andi@php.net>2000-08-04 08:11:54 +0000
commitfcdc025d112a546e5df3d8ed1a31e2035dc29a84 (patch)
treedb3f5cb2f7a3d439dad0e2f24daa7b9062ff9e04 /Zend
parentde486f789744308e6a0f090f8b8a10d264dab63d (diff)
downloadphp-git-fcdc025d112a546e5df3d8ed1a31e2035dc29a84.tar.gz
- Beautify code. Try and use more macros for splitting instead of
- replicating the code everywhere.
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend.h7
-rw-r--r--Zend/zend_execute.c56
2 files changed, 17 insertions, 46 deletions
diff --git a/Zend/zend.h b/Zend/zend.h
index fb9e8324c4..de05b924d8 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -405,6 +405,11 @@ ZEND_API int zend_get_ini_entry(char *name, uint name_length, zval *contents);
SEPARATE_ZVAL(ppzv); \
}
+#define SEPARATE_ZVAL_TO_MAKE_IS_REF(ppzv) \
+ if (!PZVAL_IS_REF(*ppzv)) { \
+ SEPARATE_ZVAL(ppzv); \
+ (*(ppzv))->is_ref = 1; \
+ }
#define COPY_PZVAL_TO_ZVAL(zv, pzv) \
(zv) = *(pzv); \
@@ -412,7 +417,7 @@ ZEND_API int zend_get_ini_entry(char *name, uint name_length, zval *contents);
zval_copy_ctor(&(zv)); \
(pzv)->refcount--; \
} else { \
- FREE_ZVAL(pzv); \
+ FREE_ZVAL(pzv); \
} \
INIT_PZVAL(&(zv));
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 5bd22db674..fca4cb524a 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1103,17 +1103,9 @@ binary_assign_op_addr: {
opline++;
continue;
}
- if (!PZVAL_IS_REF(*var_ptr)) {
- if ((*var_ptr)->refcount>1) {
- zval *orig_var=*var_ptr;
-
- (*var_ptr)->refcount--;
- ALLOC_ZVAL(*var_ptr);
- **var_ptr = *orig_var;
- zendi_zval_copy_ctor(**var_ptr);
- (*var_ptr)->refcount=1;
- }
- }
+
+ SEPARATE_ZVAL_IF_NOT_REF(var_ptr);
+
EG(binary_op)(*var_ptr, *var_ptr, get_zval_ptr(&opline->op2, Ts, &EG(free_op2), BP_VAR_R));
Ts[opline->result.u.var].var.ptr_ptr = var_ptr;
SELECTIVE_PZVAL_LOCK(*var_ptr, &opline->result);
@@ -1148,17 +1140,9 @@ binary_assign_op_addr: {
zendi_zval_copy_ctor(Ts[opline->result.u.var].tmp_var);
break;
}
- if (!PZVAL_IS_REF(*var_ptr)) {
- if ((*var_ptr)->refcount>1) {
- zval *orig_var = *var_ptr;
-
- (*var_ptr)->refcount--;
- ALLOC_ZVAL(*var_ptr);
- **var_ptr = *orig_var;
- zendi_zval_copy_ctor(**var_ptr);
- (*var_ptr)->refcount=1;
- }
- }
+
+ SEPARATE_ZVAL_IF_NOT_REF(var_ptr);
+
incdec_op(*var_ptr);
switch (opline->opcode) {
case ZEND_PRE_INC:
@@ -1637,10 +1621,8 @@ do_fcall_common:
retval_ptr_ptr = get_zval_ptr_ptr(&opline->op1, Ts, BP_VAR_W);
- if (!PZVAL_IS_REF(*retval_ptr_ptr)) {
- SEPARATE_ZVAL(retval_ptr_ptr);
- (*retval_ptr_ptr)->is_ref = 1;
- }
+ SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr);
+
(*retval_ptr_ptr)->refcount++;
(*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr);
} else {
@@ -1723,21 +1705,8 @@ send_by_ref:
zend_error(E_ERROR, "Only variables can be passed by reference");
}
+ SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr);
varptr = *varptr_ptr;
-
- if (!PZVAL_IS_REF(varptr)) {
- /* code to break away this variable */
- if (varptr->refcount>1) {
- varptr->refcount--;
- ALLOC_ZVAL(*varptr_ptr);
- **varptr_ptr = *varptr;
- varptr = *varptr_ptr;
- varptr->refcount = 1;
- zval_copy_ctor(varptr);
- }
- varptr->is_ref = 1;
- /* at the end of this code refcount is always 1 */
- }
varptr->refcount++;
zend_ptr_stack_push(&EG(argument_stack), varptr);
}
@@ -1931,11 +1900,8 @@ send_by_ref:
INIT_PZVAL(expr_ptr);
} else {
if (opline->extended_value) {
- if (!PZVAL_IS_REF(expr_ptr)) {
- SEPARATE_ZVAL(expr_ptr_ptr);
- expr_ptr = *expr_ptr_ptr;
- expr_ptr->is_ref = 1;
- }
+ SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
+ expr_ptr = *expr_ptr_ptr;
expr_ptr->refcount++;
} else if (PZVAL_IS_REF(expr_ptr)) {
zval *new_expr;