Permalink
Browse files

- Don't use magic numbers

  • Loading branch information...
1 parent de25255 commit 993f70c1d20784a69ca4a9907d6415f4be02adfe @andigutmans andigutmans committed Aug 12, 2004
Showing with 8 additions and 6 deletions.
  1. +2 −2 Zend/zend_compile.c
  2. +3 −0 Zend/zend_compile.h
  3. +3 −4 Zend/zend_execute.c
View
4 Zend/zend_compile.c
@@ -3353,7 +3353,7 @@ void zend_do_foreach_cont(znode *value, znode *key, znode *as_token, znode *fore
value = tmp;
/* Mark extended_value in case both key and value are being used */
- CG(active_op_array)->opcodes[foreach_token->u.opline_num].extended_value |= 2;
+ CG(active_op_array)->opcodes[foreach_token->u.opline_num].extended_value |= ZEND_FE_FETCH_WITH_KEY;
}
if ((key->op_type != IS_UNUSED) && (key->u.EA.type & ZEND_PARSED_REFERENCE_VARIABLE)) {
@@ -3366,7 +3366,7 @@ void zend_do_foreach_cont(znode *value, znode *key, znode *as_token, znode *fore
zend_error(E_COMPILE_ERROR, "Cannot create references to elements of a temporary array expression");
}
/* Mark extended_value for assign-by-reference */
- CG(active_op_array)->opcodes[foreach_token->u.opline_num].extended_value |= 1;
+ CG(active_op_array)->opcodes[foreach_token->u.opline_num].extended_value |= ZEND_FE_FETCH_BYREF;
}
if (key->op_type != IS_UNUSED) {
View
3 Zend/zend_compile.h
@@ -794,6 +794,9 @@ int zendlex(znode *zendlval TSRMLS_DC);
#define ZEND_FETCH_STANDARD 0
#define ZEND_FETCH_ADD_LOCK 1
+#define ZEND_FE_FETCH_BYREF 1
+#define ZEND_FE_FETCH_WITH_KEY 2
+
#define ZEND_MEMBER_FUNC_CALL 1<<0
#define ZEND_ARG_SEND_BY_REF (1<<0)
View
7 Zend/zend_execute.c
@@ -3779,8 +3779,7 @@ int zend_fe_fetch_handler(ZEND_OPCODE_HANDLER_ARGS)
HashTable *fe_ht;
zend_object_iterator *iter = NULL;
int key_type;
- /* extended_value & 2 means that the key is also needed */
- zend_bool use_key = opline->extended_value & 2;
+ zend_bool use_key = opline->extended_value & ZEND_FE_FETCH_WITH_KEY;
PZVAL_LOCK(array);
@@ -3858,13 +3857,13 @@ int zend_fe_fetch_handler(ZEND_OPCODE_HANDLER_ARGS)
break;
}
- if (opline->extended_value & 1) {
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
SEPARATE_ZVAL_IF_NOT_REF(value);
(*value)->is_ref = 1;
}
if (!use_key) {
- if (opline->extended_value & 1) {
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
EX_T(opline->result.u.var).var.ptr_ptr = value;
(*value)->refcount++;
} else {

0 comments on commit 993f70c

Please sign in to comment.