cvs: ZendEngine2 / zend_compile.c zend_compile.h

From: Date: Wed, 28 Jan 2004 10:25:46 +0000
Subject: cvs: ZendEngine2 / zend_compile.c zend_compile.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2289@lists.php.net to get a copy of this message
zeev Wed Jan 28 05:25:46 2004 EDT Modified files: /ZendEngine2 zend_compile.c zend_compile.h Log: Prevent classes from implementing interfaces that have the same function http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.519&r2=1.520&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.519 ZendEngine2/zend_compile.c:1.520 --- ZendEngine2/zend_compile.c:1.519 Wed Jan 28 04:13:41 2004 +++ ZendEngine2/zend_compile.c Wed Jan 28 05:25:45 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.519 2004/01/28 09:13:41 zeev Exp $ */ +/* $Id: zend_compile.c,v 1.520 2004/01/28 10:25:45 zeev Exp $ */ #include "zend_language_parser.h" #include "zend.h" @@ -1733,6 +1733,14 @@ return 1; /* method doesn't exist in child, copy from parent */ } + if (parent->common.fn_flags & ZEND_ACC_ABSTRACT + && child->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_IMPLEMENTED_ABSTRACT)) { + zend_error(E_COMPILE_ERROR, "Can't inherit abstract function %s::%s() (previously declared abstract in %s)", + parent->common.scope->name, + child->common.function_name, + child->common.prototype->common.scope->name); + } + if (parent_flags & ZEND_ACC_FINAL) { zend_error(E_COMPILE_ERROR, "Cannot override final method %s::%s()", ZEND_FN_SCOPE_NAME(parent), child->common.function_name); } @@ -1766,8 +1774,9 @@ } } - if (parent_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_ABSTRACT)) { + if (parent_flags & ZEND_ACC_ABSTRACT) { child->common.prototype = parent; + child->common.fn_flags |= ZEND_ACC_IMPLEMENTED_ABSTRACT; } else if (parent->common.prototype) { child->common.prototype = parent->common.prototype; } @@ -2427,6 +2436,23 @@ } +#if 0 +/* This is a part of an incomplete patch, coming soon */ +ZEND_API void zend_do_extends(znode *result, znode *class_token, zend_bool is_first_parent TSRMLS_DC) +{ + zend_bool is_class = CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE; + + if (is_class) { + if (!is_first_parent) { + zend_error(E_COMPILE_ERROR, "Classes may extend only one parent"); + } else { + *result = *class_token; + } + } else { /* interface */ + } +} +#endif + void zend_do_implements_interface(znode *interface_znode TSRMLS_DC) { zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.270&r2=1.271&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.270 ZendEngine2/zend_compile.h:1.271 --- ZendEngine2/zend_compile.h:1.270 Sat Jan 24 11:59:24 2004 +++ ZendEngine2/zend_compile.h Wed Jan 28 05:25:45 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.270 2004/01/24 16:59:24 helly Exp $ */ +/* $Id: zend_compile.h,v 1.271 2004/01/28 10:25:45 zeev Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -100,6 +100,7 @@ #define ZEND_ACC_INTERFACE 0x08 #define ZEND_ACC_ABSTRACT_CLASS 0x10 #define ZEND_ACC_FINAL_CLASS 0x20 +#define ZEND_ACC_IMPLEMENTED_ABSTRACT 0x40 #define ZEND_ACC_ALLOW_STATIC 0x80

« previous php.zend-engine.cvs (#2289) next »