Skip to content

Commit

Permalink
- Don't use magic numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Gutmans committed Aug 12, 2004
1 parent de25255 commit 993f70c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Zend/zend_compile.c
Expand Up @@ -3353,7 +3353,7 @@ void zend_do_foreach_cont(znode *value, znode *key, znode *as_token, znode *fore
value = tmp; value = tmp;


/* Mark extended_value in case both key and value are being used */ /* 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)) { if ((key->op_type != IS_UNUSED) && (key->u.EA.type & ZEND_PARSED_REFERENCE_VARIABLE)) {
Expand All @@ -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"); zend_error(E_COMPILE_ERROR, "Cannot create references to elements of a temporary array expression");
} }
/* Mark extended_value for assign-by-reference */ /* 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) { if (key->op_type != IS_UNUSED) {
Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_compile.h
Expand Up @@ -794,6 +794,9 @@ int zendlex(znode *zendlval TSRMLS_DC);
#define ZEND_FETCH_STANDARD 0 #define ZEND_FETCH_STANDARD 0
#define ZEND_FETCH_ADD_LOCK 1 #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_MEMBER_FUNC_CALL 1<<0


#define ZEND_ARG_SEND_BY_REF (1<<0) #define ZEND_ARG_SEND_BY_REF (1<<0)
Expand Down
7 changes: 3 additions & 4 deletions Zend/zend_execute.c
Expand Up @@ -3779,8 +3779,7 @@ int zend_fe_fetch_handler(ZEND_OPCODE_HANDLER_ARGS)
HashTable *fe_ht; HashTable *fe_ht;
zend_object_iterator *iter = NULL; zend_object_iterator *iter = NULL;
int key_type; int key_type;
/* extended_value & 2 means that the key is also needed */ zend_bool use_key = opline->extended_value & ZEND_FE_FETCH_WITH_KEY;
zend_bool use_key = opline->extended_value & 2;


PZVAL_LOCK(array); PZVAL_LOCK(array);


Expand Down Expand Up @@ -3858,13 +3857,13 @@ int zend_fe_fetch_handler(ZEND_OPCODE_HANDLER_ARGS)
break; break;
} }


if (opline->extended_value & 1) { if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
SEPARATE_ZVAL_IF_NOT_REF(value); SEPARATE_ZVAL_IF_NOT_REF(value);
(*value)->is_ref = 1; (*value)->is_ref = 1;
} }


if (!use_key) { 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; EX_T(opline->result.u.var).var.ptr_ptr = value;
(*value)->refcount++; (*value)->refcount++;
} else { } else {
Expand Down

0 comments on commit 993f70c

Please sign in to comment.