]> granicus.if.org Git - php/commitdiff
- Nuke delete(). It was a big mistake to introduce it and I finally
authorAndi Gutmans <andi@php.net>
Sun, 14 Jul 2002 19:23:18 +0000 (19:23 +0000)
committerAndi Gutmans <andi@php.net>
Sun, 14 Jul 2002 19:23:18 +0000 (19:23 +0000)
- understand why Java didn't do so.
- If you still want to control destruction of your object then either make
- sure you kill all references or create a destruction method which you
- call yourself.

Zend/ZEND_CHANGES
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_execute.c
Zend/zend_language_parser.y
Zend/zend_language_scanner.l

index 85c60a44e449fc2eacc3f5e9079ff2a6c3f4af9a..1e96a5a021d6810155bb2cb0bd65b926e6e2dd51 100644 (file)
@@ -121,19 +121,6 @@ Changes in the Zend Engine 2.0
         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
index 49a388e5c0d5198282f82a62e4614bfa433ef575..a927731a175e0a10cacac974132400a9b2fd0a39 100644 (file)
@@ -2625,7 +2625,7 @@ void zend_do_indirect_references(znode *result, znode *num_references, znode *va
 }
 
 
-void zend_do_unset(znode *variable, int type TSRMLS_DC)
+void zend_do_unset(znode *variable TSRMLS_DC)
 {
        zend_op *last_op;
 
@@ -2643,7 +2643,6 @@ void zend_do_unset(znode *variable, int type TSRMLS_DC)
                        break;
 
        }
-       last_op->extended_value = type;
 }
 
 
index 8e523c9df4f5a33b24c29524e96f50cc800afca2..b51d576ff113ec29caa3fb6b5ed5ecd244f6e8f9 100644 (file)
@@ -354,7 +354,7 @@ void zend_do_new_list_end(TSRMLS_D);
 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);
@@ -623,7 +623,6 @@ int zendlex(znode *zendlval TSRMLS_DC);
 
 /* unset types */
 #define ZEND_UNSET_REG 0
-#define ZEND_UNSET_OBJ 1
 
 /* var status for backpatching */
 #define BP_VAR_R                       0
index 9559905d9fb867936026ca04e53f5d32d6fb6ce3..fca3ff2a36dbb91d0d81d4979b12fc4998be20be 100644 (file)
@@ -2755,11 +2755,7 @@ send_by_ref:
                        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);
@@ -2767,16 +2763,6 @@ send_by_ref:
                                                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) {
@@ -2788,10 +2774,6 @@ send_by_ref:
                        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;
@@ -2818,44 +2800,14 @@ send_by_ref:
                                                                                } 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: 
index 9147534040ba9e2485c1ed05ea2f4609cddad52f..5d89928981cc0f129ba240fea3967ef7b306bf39 100644 (file)
@@ -67,7 +67,7 @@
 %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
@@ -211,7 +211,6 @@ unticked_statement:
                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); } ';'
 ;
 
@@ -252,7 +251,7 @@ unset_variables:
 ;
 
 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:
index d8c2ac4d496b5ed512d5bcbc0a4ae98c1a147782..90449598620ffddf07fc7bde5b06513bbbe98f73 100644 (file)
@@ -625,10 +625,6 @@ NEWLINE ("\r"|"\n"|"\r\n")
        return T_NEW;
 }
 
-<ST_IN_SCRIPTING>"delete" {
-       return T_DELETE;
-}
-
 <ST_IN_SCRIPTING>"var" {
        return T_VAR;
 }