]> granicus.if.org Git - php/commitdiff
Make parent:: work in runtime bindings as well
authorZeev Suraski <zeev@php.net>
Wed, 7 Mar 2001 10:07:25 +0000 (10:07 +0000)
committerZeev Suraski <zeev@php.net>
Wed, 7 Mar 2001 10:07:25 +0000 (10:07 +0000)
Zend/zend_compile.c
Zend/zend_execute.c

index 020dce50799828633c402aae63f134b0f33ada2f..439d0f34d43cdae6f9ac27e8847bdd96a01e093f 100644 (file)
@@ -871,10 +871,9 @@ void zend_do_begin_class_member_function_call(znode *class_name, znode *function
        opline->opcode = ZEND_INIT_FCALL_BY_NAME;
        zend_str_tolower(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len);
        if ((class_name->u.constant.value.str.len == sizeof("parent")-1)
-               && !memcmp(class_name->u.constant.value.str.val, "parent", sizeof("parent")-1)) {
-               if (!CG(active_class_entry) || !CG(active_class_entry)->parent) {
-                       zend_error(E_COMPILE_ERROR, "No parent class available in this context");
-               }
+               && !memcmp(class_name->u.constant.value.str.val, "parent", sizeof("parent")-1)
+               && CG(active_class_entry)
+               && CG(active_class_entry)->parent) {
                efree(class_name->u.constant.value.str.val);
                class_name->u.constant.value.str.len = CG(active_class_entry)->parent->name_length;
                class_name->u.constant.value.str.val = estrndup(CG(active_class_entry)->parent->name, class_name->u.constant.value.str.len);
index 747def6ed667cada3897aeb63848bae5db6b80ab..5e0297893707ac15c559c8220a440703649bb2fd 100644 (file)
@@ -1401,10 +1401,6 @@ binary_assign_op_addr: {
                                                        zend_class_entry *ce;
                                                        zval **object_ptr_ptr;
 
-                                                       if (zend_hash_find(EG(class_table), opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len+1, (void **) &ce)==FAILURE) {
-                                                               zend_error(E_ERROR, "Undefined class name '%s'", opline->op1.u.constant.value.str.val);
-                                                       }
-                                                       active_function_table = &ce->function_table;
                                                        if (zend_hash_find(EG(active_symbol_table), "this", sizeof("this"), (void **) &object_ptr_ptr)==FAILURE) {
                                                                object.ptr=NULL;
                                                        } else {
@@ -1413,6 +1409,15 @@ binary_assign_op_addr: {
                                                                object.ptr = *object_ptr_ptr;
                                                                object.ptr->refcount++; /* For this pointer */
                                                        }
+                                                       if (zend_hash_find(EG(class_table), opline->op1.u.constant.value.str.val, opline->op1.u.constant.value.str.len+1, (void **) &ce)==FAILURE) { /* class doesn't exist */
+                                                               /* test for parent:: special case - if it doesn't exist - error out */
+                                                               if (opline->op1.u.constant.value.str.len!=(sizeof("parent")-1)
+                                                                       || memcmp(opline->op1.u.constant.value.str.val, "parent", sizeof("parent")-1)!=0
+                                                                       || !(ce = object.ptr->value.obj.ce->parent)) {
+                                                                       zend_error(E_ERROR, "Undefined class name '%s'", opline->op1.u.constant.value.str.val);
+                                                               }
+                                                       }
+                                                       active_function_table = &ce->function_table;
                                                } else { /* used for member function calls */
                                                        object.ptr = _get_object_zval_ptr(&opline->op1, Ts, &EG(free_op1) ELS_CC);