diff options
| author | Stanislav Malyshev <stas@php.net> | 2002-10-16 18:06:36 +0000 |
|---|---|---|
| committer | Stanislav Malyshev <stas@php.net> | 2002-10-16 18:06:36 +0000 |
| commit | 349b3a096aa677b8ee3977a965b42c187b6a5bc5 (patch) | |
| tree | d923e8bd2a51710e2ceb771737acaff96de92a53 /Zend/zend_compile.c | |
| parent | 5ce6d653b8a9e335afec9d1250241ca78e71fa25 (diff) | |
| download | php-git-349b3a096aa677b8ee3977a965b42c187b6a5bc5.tar.gz | |
Fix and generalize $this handling.
ZEND_FETCH_FROM_THIS is removed, IS_UNUSED type on class variables will be
used instead as the sign that it's a fetch from $this
Diffstat (limited to 'Zend/zend_compile.c')
| -rw-r--r-- | Zend/zend_compile.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index cd6815e56a..1777231fe2 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1085,13 +1085,6 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) last_op->opcode = ZEND_INIT_METHOD_CALL; - if (last_op->op2.op_type == IS_UNUSED && last_op->op2.u.EA.type == ZEND_FETCH_FROM_THIS) { - last_op->op2 = last_op->op1; - memset(&last_op->op1, 0, sizeof(znode)); - SET_UNUSED(last_op->op1); - last_op->extended_value = ZEND_FETCH_FROM_THIS; - } - left_bracket->u.constant.value.lval = ZEND_INIT_FCALL_BY_NAME; zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); @@ -2182,29 +2175,49 @@ void zend_do_fetch_property(znode *result, znode *object, znode *property TSRMLS (opline_ptr->op1.u.constant.value.str.len == (sizeof("this")-1)) && !memcmp(opline_ptr->op1.u.constant.value.str.val, "this", sizeof("this"))) { efree(opline_ptr->op1.u.constant.value.str.val); - opline_ptr->op1 = *property; - SET_UNUSED(opline_ptr->op2); - opline_ptr->op2.u.EA.type = ZEND_FETCH_FROM_THIS; + SET_UNUSED(opline_ptr->op1); /* this means $this for objects */ + opline_ptr->op2 = *property; + /* if it was usual fetch, we change it to object fetch */ + switch(opline_ptr->opcode) { + case ZEND_FETCH_W: + opline_ptr->opcode = ZEND_FETCH_OBJ_W; + break; + case ZEND_FETCH_R: + opline_ptr->opcode = ZEND_FETCH_OBJ_R; + break; + case ZEND_FETCH_RW: + opline_ptr->opcode = ZEND_FETCH_OBJ_RW; + break; + case ZEND_FETCH_IS: + opline_ptr->opcode = ZEND_FETCH_OBJ_IS; + break; + case ZEND_FETCH_UNSET: + opline_ptr->opcode = ZEND_FETCH_OBJ_UNSET; + break; + case ZEND_FETCH_FUNC_ARG: + opline_ptr->opcode = ZEND_FETCH_OBJ_FUNC_ARG; + break; + } if (CG(active_class_entry) && (opline_ptr->op1.op_type == IS_CONST)) { if (zend_hash_exists(&CG(active_class_entry)->private_properties, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len+1)) { char *priv_name; int priv_name_length; - mangle_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len); + mangle_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, opline_ptr->op2.u.constant.value.str.val, opline_ptr->op2.u.constant.value.str.len); - STR_FREE(opline_ptr->op1.u.constant.value.str.val); - opline_ptr->op1.u.constant.value.str.val = priv_name; - opline_ptr->op1.u.constant.value.str.len = priv_name_length; - } else if (zend_hash_exists(&CG(active_class_entry)->protected_properties, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len+1)) { + STR_FREE(opline_ptr->op2.u.constant.value.str.val); + opline_ptr->op2.u.constant.value.str.val = priv_name; + opline_ptr->op2.u.constant.value.str.len = priv_name_length; + } else if (zend_hash_exists(&CG(active_class_entry)->protected_properties, opline_ptr->op2.u.constant.value.str.val, opline_ptr->op2.u.constant.value.str.len+1)) { char *prot_name; int prot_name_length; - mangle_property_name(&prot_name, &prot_name_length, "*", 1, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len); + mangle_property_name(&prot_name, &prot_name_length, "*", 1, opline_ptr->op2.u.constant.value.str.val, opline_ptr->op2.u.constant.value.str.len); - STR_FREE(opline_ptr->op1.u.constant.value.str.val); - opline_ptr->op1.u.constant.value.str.val = prot_name; - opline_ptr->op1.u.constant.value.str.len = prot_name_length; + STR_FREE(opline_ptr->op2.u.constant.value.str.val); + opline_ptr->op2.u.constant.value.str.val = prot_name; + opline_ptr->op2.u.constant.value.str.len = prot_name_length; } } *result = opline_ptr->result; |
