cvs: ZendEngine2 / zend_API.c zend_API.h zend_compile.c zend_compile.h zend_interfaces.c zend_object_handlers.c
| From: | Zeev Suraski | Date: | Thu, 12 Feb 2004 13:49:56 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_API.h zend_compile.c zend_compile.h zend_interfaces.c zend_object_handlers.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2369@lists.php.net to get a copy of this message | ||
zeev Thu Feb 12 08:49:56 2004 EDT
Modified files:
/ZendEngine2 zend_API.c zend_API.h zend_compile.c zend_compile.h
zend_interfaces.c zend_object_handlers.c
Log:
- Check return-by-reference bit when implementing interface prototypes
- Add infrastructure for built-in functions to hint whether they
return by reference or not. It is NOT currently used for anything,
except for interface prototypes (you can use it to request that the
function that implements your prototype returns by reference or
doesn't return by reference).
For downwards compatibility - by default, interface prototypes are
agnostic as to whether the function that implements them returns
by reference or not. Use ZEND_BEGIN_ARG_INFO_EX() with
ZEND_RETURN_VALUE/ZEND_RETURN_REFERENCE to change that.
- Fix ArrayAccess::getOffset() to conduct additional checks.
If your getOffset() should work with multidimensional arrays - it
must return by reference.
http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.238&r2=1.239&ty=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.238 ZendEngine2/zend_API.c:1.239
--- ZendEngine2/zend_API.c:1.238 Sat Jan 24 11:59:23 2004
+++ ZendEngine2/zend_API.c Thu Feb 12 08:49:54 2004
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.238 2004/01/24 16:59:23 helly Exp $ */
+/* $Id: zend_API.c,v 1.239 2004/02/12 13:49:54 zeev Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1221,10 +1221,12 @@
internal_function->arg_info = ptr->arg_info+1;
internal_function->num_args = ptr->num_args;
internal_function->pass_rest_by_reference = ptr->arg_info[0].pass_by_reference;
+ internal_function->return_reference = ptr->arg_info[0].return_reference;
} else {
internal_function->arg_info = NULL;
internal_function->num_args = 0;
internal_function->pass_rest_by_reference = 0;
+ internal_function->return_reference = 0;
}
if (ptr->flags) {
if (!(ptr->flags & ZEND_ACC_PPP_MASK)) {
http://cvs.php.net/diff.php/ZendEngine2/zend_API.h?r1=1.177&r2=1.178&ty=u
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.177 ZendEngine2/zend_API.h:1.178
--- ZendEngine2/zend_API.h:1.177 Sun Jan 18 19:38:51 2004
+++ ZendEngine2/zend_API.h Thu Feb 12 08:49:54 2004
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.177 2004/01/19 00:38:51 helly Exp $ */
+/* $Id: zend_API.h,v 1.178 2004/02/12 13:49:54 zeev Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -57,12 +57,14 @@
ZEND_FENTRY(name, ZEND_FN(classname##_##alias),
arg_info, flags)
#define ZEND_ME_MAPPING(name, func_name, arg_types) ZEND_NAMED_FE(name, ZEND_FN(func_name),
arg_types)
-#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, pass_by_ref },
-#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, pass_by_ref },
-#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, sizeof(#name)-1,
#classname, sizeof(#classname)-1, allow_null, pass_by_ref },
-#define ZEND_BEGIN_ARG_INFO(name, pass_rest_by_reference) \
- zend_arg_info name[] = { \
- ZEND_ARG_PASS_INFO(pass_rest_by_reference)
+#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, pass_by_ref, 0
},
+#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, pass_by_ref, 0 },
+#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, sizeof(#name)-1,
#classname, sizeof(#classname)-1, allow_null, pass_by_ref, 0 },
+#define ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, return_reference) \
+ zend_arg_info name[] = { \
+ { NULL, 0, NULL, 0, 0, pass_rest_by_reference, return_reference },
+#define ZEND_BEGIN_ARG_INFO(name, pass_rest_by_reference) \
+ ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, ZEND_RETURN_REFERENCE_AGNOSTIC)
#define ZEND_END_ARG_INFO() };
/* Name macros */
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.541&r2=1.542&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.541 ZendEngine2/zend_compile.c:1.542
--- ZendEngine2/zend_compile.c:1.541 Wed Feb 11 17:13:39 2004
+++ ZendEngine2/zend_compile.c Thu Feb 12 08:49:54 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.541 2004/02/11 22:13:39 helly Exp $ */
+/* $Id: zend_compile.c,v 1.542 2004/02/12 13:49:54 zeev Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -1718,6 +1718,11 @@
return 0;
}
+ if (fe->common.prototype->common.return_reference != ZEND_RETURN_REFERENCE_AGNOSTIC
+ && fe->common.return_reference != fe->common.prototype->common.return_reference)
{
+ return 0;
+ }
+
for (i=0; i< fe->common.num_args; i++) {
if (ZEND_LOG_XOR(fe->common.arg_info[i].class_name,
fe->common.prototype->common.arg_info[i].class_name)) {
/* Only one has a type hint and the other one doesn't */
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.274&r2=1.275&ty=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.274 ZendEngine2/zend_compile.h:1.275
--- ZendEngine2/zend_compile.h:1.274 Wed Feb 4 11:30:14 2004
+++ ZendEngine2/zend_compile.h Thu Feb 12 08:49:55 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.274 2004/02/04 16:30:14 zeev Exp $ */
+/* $Id: zend_compile.h,v 1.275 2004/02/12 13:49:55 zeev Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -140,6 +140,7 @@
zend_uint class_name_len;
zend_bool allow_null;
zend_bool pass_by_reference;
+ zend_bool return_reference;
} zend_arg_info;
struct _zend_op_array {
@@ -152,6 +153,7 @@
zend_uint num_args;
zend_arg_info *arg_info;
zend_bool pass_rest_by_reference;
+ unsigned char return_reference;
/* END of common elements */
zend_uint *refcount;
@@ -174,7 +176,6 @@
zend_op *start_op;
int backpatch_count;
- zend_bool return_reference;
zend_bool done_pass_two;
zend_bool uses_this;
@@ -188,6 +189,10 @@
};
+#define ZEND_RETURN_VALUE 0
+#define ZEND_RETURN_REFERENCE 1
+#define ZEND_RETURN_REFERENCE_AGNOSTIC 2
+
typedef struct _zend_internal_function {
/* Common elements */
zend_uchar type;
@@ -198,6 +203,7 @@
zend_uint num_args;
zend_arg_info *arg_info;
zend_bool pass_rest_by_reference;
+ unsigned char return_reference;
/* END of common elements */
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
@@ -217,6 +223,7 @@
zend_uint num_args;
zend_arg_info *arg_info;
zend_bool pass_rest_by_reference;
+ unsigned char return_reference;
} common;
zend_op_array op_array;
http://cvs.php.net/diff.php/ZendEngine2/zend_interfaces.c?r1=1.13&r2=1.14&ty=u
Index: ZendEngine2/zend_interfaces.c
diff -u ZendEngine2/zend_interfaces.c:1.13 ZendEngine2/zend_interfaces.c:1.14
--- ZendEngine2/zend_interfaces.c:1.13 Mon Jan 26 17:33:52 2004
+++ ZendEngine2/zend_interfaces.c Thu Feb 12 08:49:55 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_interfaces.c,v 1.13 2004/01/26 22:33:52 helly Exp $ */
+/* $Id: zend_interfaces.c,v 1.14 2004/02/12 13:49:55 zeev Exp $ */
#include "zend.h"
#include "zend_API.h"
@@ -385,7 +385,7 @@
zend_function_entry *zend_funcs_traversable = NULL;
static
-ZEND_BEGIN_ARG_INFO(arginfo_arrayaccess_offset, 0)
+ZEND_BEGIN_ARG_INFO(arginfo_arrayaccess_offset, 0)
ZEND_ARG_INFO(0, offset)
ZEND_END_ARG_INFO();
http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.92&r2=1.93&ty=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.92 ZendEngine2/zend_object_handlers.c:1.93
--- ZendEngine2/zend_object_handlers.c:1.92 Sun Feb 8 12:23:20 2004
+++ ZendEngine2/zend_object_handlers.c Thu Feb 12 08:49:55 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.92 2004/02/08 17:23:20 zeev Exp $ */
+/* $Id: zend_object_handlers.c,v 1.93 2004/02/12 13:49:55 zeev Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -386,9 +386,15 @@
}
return 0;
}
- if (retval->refcount > 0) { /* Should always be the case */
- retval->refcount--;
+
+ if ((type == BP_VAR_W || type == BP_VAR_RW)
+ && !retval->is_ref) {
+ zend_error(E_ERROR, "offsetGet() must return by reference for multi-dimensional array
support");
}
+
+ /* Undo PZVAL_LOCK() */
+ retval->refcount--;
+
return retval;
} else {
zend_error(E_ERROR, "Cannot use object of type %s as array", ce->name);