print $obj->address . "\n";
?>
- * Forced deletion of objects.
-
- The Zend Engine 1.0 had no means to force deletion of an object
- if there are still references to it. The newly introduced delete
- statement calls the object's destructor and frees it even if the
- object is referenced by some other places in the engine. Other
- references to the deleted object become stale and trying to
- access them results in a fatal error.
-
- Note that if you have a user-defined function delete() in an old
- script, this script will yield a parser error with the Zend
- Engine 2.0, since 'delete' is now a reserved word.
-
* Nested classes (namespaces).
The Zend Engine 1.0 provided only three scopes: the global
void zend_do_cast(znode *result, znode *expr, int type TSRMLS_DC);
void zend_do_include_or_eval(int type, znode *result, znode *op1 TSRMLS_DC);
-void zend_do_unset(znode *variable, int type TSRMLS_DC);
+void zend_do_unset(znode *variable TSRMLS_DC);
void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC);
void zend_do_foreach_begin(znode *foreach_token, znode *array, znode *open_brackets_token, znode *as_token, int variable TSRMLS_DC);
/* unset types */
#define ZEND_UNSET_REG 0
-#define ZEND_UNSET_OBJ 1
/* var status for backpatching */
#define BP_VAR_R 0
case ZEND_UNSET_VAR:
{
zval tmp, *variable = get_zval_ptr(&EX(opline)->op1, EX(Ts), &EG(free_op1), BP_VAR_R);
- zval **object;
- zend_bool unset_object;
-
- unset_object = (EX(opline)->extended_value == ZEND_UNSET_OBJ);
if (variable->type != IS_STRING) {
tmp = *variable;
zval_copy_ctor(&tmp);
variable = &tmp;
}
- if (unset_object) {
- if (zend_hash_find(EG(active_symbol_table), variable->value.str.val, variable->value.str.len+1, (void **)&object) == FAILURE) {
- zend_error(E_ERROR, "Cannot delete non-existing object");
- }
- if (Z_TYPE_PP(object) != IS_OBJECT) {
- zend_error(E_ERROR, "Cannot call delete on non-object type");
- }
- Z_OBJ_HT_PP(object)->delete_obj(*object TSRMLS_CC);
- }
-
zend_hash_del(EG(active_symbol_table), variable->value.str.val, variable->value.str.len+1);
if (variable == &tmp) {
case ZEND_UNSET_DIM_OBJ: {
zval **container = get_zval_ptr_ptr(&EX(opline)->op1, EX(Ts), BP_VAR_R);
zval *offset = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R);
- zend_bool unset_object;
- zval **object;
-
- unset_object = (EX(opline)->extended_value == ZEND_UNSET_OBJ);
if (container) {
HashTable *ht;
} else {
index = offset->value.lval;
}
-
- if (unset_object) {
- if (zend_hash_index_find(ht, index, (void **)&object) == FAILURE) {
- zend_error(E_ERROR, "Cannot delete non-existing object");
- }
- if (Z_TYPE_PP(object) != IS_OBJECT) {
- zend_error(E_ERROR, "Cannot call delete on non-object type");
- }
- Z_OBJ_HT_PP(object)->delete_obj(*object TSRMLS_CC);
- }
zend_hash_index_del(ht, index);
break;
}
case IS_STRING:
- if (unset_object) {
- if (zend_hash_find(ht, offset->value.str.val, offset->value.str.len+1, (void **)&object) == FAILURE) {
- zend_error(E_ERROR, "Cannot delete non-existing object");
- }
- if (Z_TYPE_PP(object) != IS_OBJECT) {
- zend_error(E_ERROR, "Cannot call delete on non-object type");
- }
- Z_OBJ_HT_PP(object)->delete_obj(*object TSRMLS_CC);
- }
-
zend_hash_del(ht, offset->value.str.val, offset->value.str.len+1);
break;
case IS_NULL:
- if (unset_object) {
- if (zend_hash_find(ht, "", sizeof(""), (void **)&object) == FAILURE) {
- zend_error(E_ERROR, "Cannot delete non-existing object");
- }
- if (Z_TYPE_PP(object) != IS_OBJECT) {
- zend_error(E_ERROR, "Cannot call delete on non-object type");
- }
- Z_OBJ_HT_PP(object)->delete_obj(*object TSRMLS_CC);
- }
-
zend_hash_del(ht, "", sizeof(""));
break;
default:
%left '*' '/' '%'
%right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@'
%right '['
-%nonassoc T_NEW T_DELETE
+%nonassoc T_NEW
%token T_EXIT
%token T_IF
%left T_ELSEIF
T_CATCH '(' catch_or_import_class_entry T_VARIABLE ')' { zend_do_begin_catch(&$1, &$8, &$9, 1 TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
additional_catches
| T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); }
- | T_DELETE variable ';' { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$2, ZEND_UNSET_OBJ TSRMLS_CC); }
| T_IMPORT { zend_do_begin_import(TSRMLS_C); } import_rule T_FROM catch_or_import_class_entry { zend_do_end_import(&$5 TSRMLS_CC); } ';'
;
;
unset_variable:
- variable { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1, ZEND_UNSET_REG TSRMLS_CC); }
+ variable { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1 TSRMLS_CC); }
;
use_filename: