summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-11-10 16:14:44 +0000
committerMarcus Boerger <helly@php.net>2003-11-10 16:14:44 +0000
commit296529b886660ee95fc3182430164e7793028a3e (patch)
tree6db0ec498fe64fe2015e5f350a4489466b20461c /Zend
parentda6d68d9190abe6ef863d4157fba5255a7a7be58 (diff)
downloadphp-git-296529b886660ee95fc3182430164e7793028a3e.tar.gz
Split isset/isempty for object property and object dimension hooking.
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_compile.c4
-rw-r--r--Zend/zend_compile.h2
-rw-r--r--Zend/zend_execute.c21
-rw-r--r--Zend/zend_object_handlers.c7
-rw-r--r--Zend/zend_object_handlers.h6
-rw-r--r--Zend/zend_objects_API.c2
6 files changed, 38 insertions, 4 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index b6971b781f..691f1faef7 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3050,9 +3050,11 @@ void zend_do_isset_or_isempty(int type, znode *result, znode *variable TSRMLS_DC
last_op->opcode = ZEND_ISSET_ISEMPTY_VAR;
break;
case ZEND_FETCH_DIM_IS:
- case ZEND_FETCH_OBJ_IS:
last_op->opcode = ZEND_ISSET_ISEMPTY_DIM_OBJ;
break;
+ case ZEND_FETCH_OBJ_IS:
+ last_op->opcode = ZEND_ISSET_ISEMPTY_PROP_OBJ;
+ break;
}
last_op->result.op_type = IS_TMP_VAR;
last_op->extended_value = type;
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 43f9524025..d53c242ade 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -673,6 +673,8 @@ int zendlex(znode *zendlval TSRMLS_DC);
#define ZEND_ASSIGN_DIM 147
+#define ZEND_ISSET_ISEMPTY_PROP_OBJ 148
+
/* end of block */
/* END: OPCODES */
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index a3e557f218..7ebb1ee86c 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -3769,7 +3769,7 @@ int zend_isset_isempty_var_handler(ZEND_OPCODE_HANDLER_ARGS)
}
-int zend_isset_isempty_dim_obj_handler(ZEND_OPCODE_HANDLER_ARGS)
+static int zend_isset_isempty_dim_prop_obj_handler(int prop_dim, ZEND_OPCODE_HANDLER_ARGS)
{
zval **container = get_obj_zval_ptr_ptr(&EX(opline)->op1, EX(Ts), BP_VAR_R TSRMLS_CC);
zval *offset = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R);
@@ -3831,7 +3831,11 @@ int zend_isset_isempty_dim_obj_handler(ZEND_OPCODE_HANDLER_ARGS)
break;
}
} else if ((*container)->type == IS_OBJECT) {
- result = Z_OBJ_HT_P(*container)->has_property(*container, offset, (EX(opline)->extended_value == ZEND_ISEMPTY) TSRMLS_CC);
+ if (prop_dim) {
+ result = Z_OBJ_HT_P(*container)->has_property(*container, offset, (EX(opline)->extended_value == ZEND_ISEMPTY) TSRMLS_CC);
+ } else {
+ result = Z_OBJ_HT_P(*container)->has_dimension(*container, offset, (EX(opline)->extended_value == ZEND_ISEMPTY) TSRMLS_CC);
+ }
} else if ((*container)->type == IS_STRING) { /* string offsets */
switch (EX(opline)->extended_value) {
case ZEND_ISSET:
@@ -3865,6 +3869,18 @@ int zend_isset_isempty_dim_obj_handler(ZEND_OPCODE_HANDLER_ARGS)
}
+int zend_isset_isempty_dim_obj_handler(ZEND_OPCODE_HANDLER_ARGS)
+{
+ zend_isset_isempty_dim_prop_obj_handler(0, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
+}
+
+
+int zend_isset_isempty_prop_obj_handler(ZEND_OPCODE_HANDLER_ARGS)
+{
+ zend_isset_isempty_dim_prop_obj_handler(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
+}
+
+
int zend_exit_handler(ZEND_OPCODE_HANDLER_ARGS)
{
if (EX(opline)->op1.op_type != IS_UNUSED) {
@@ -4217,6 +4233,7 @@ void zend_init_opcodes_handlers()
zend_opcode_handlers[ZEND_ISSET_ISEMPTY_VAR] = zend_isset_isempty_var_handler;
zend_opcode_handlers[ZEND_ISSET_ISEMPTY_DIM_OBJ] = zend_isset_isempty_dim_obj_handler;
+ zend_opcode_handlers[ZEND_ISSET_ISEMPTY_PROP_OBJ] = zend_isset_isempty_prop_obj_handler;
zend_opcode_handlers[ZEND_PRE_INC_OBJ] = zend_pre_inc_obj_handler;
zend_opcode_handlers[ZEND_PRE_DEC_OBJ] = zend_pre_dec_obj_handler;
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 56d212f387..637d3c37ff 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -386,6 +386,12 @@ static void zend_std_write_dimension(zval *object, zval *offset, zval *value TSR
}
+static void zend_std_has_dimension(zval *object, zval *offset, zval *value TSRMLS_DC)
+{
+ zend_error(E_ERROR, "Cannot use object as array");
+}
+
+
static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC)
{
zend_object *zobj;
@@ -902,6 +908,7 @@ zend_object_handlers std_object_handlers = {
NULL, /* set */
zend_std_has_property, /* has_property */
zend_std_unset_property, /* unset_property */
+ zend_std_has_dimension, /* has_dimension */
zend_std_unset_dimension, /* unset_dimension */
zend_std_get_properties, /* get_properties */
zend_std_get_method, /* get_method */
diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h
index cf11b93574..3e98d7713b 100644
--- a/Zend/zend_object_handlers.h
+++ b/Zend/zend_object_handlers.h
@@ -53,10 +53,13 @@ typedef zval* (*zend_object_get_t)(zval *property TSRMLS_DC);
/* Used to check if a property of the object exists */
typedef int (*zend_object_has_property_t)(zval *object, zval *member, int check_empty TSRMLS_DC);
+/* Used to check if a dimension of the object exists */
+typedef int (*zend_object_has_dimension_t)(zval *object, zval *member, int check_empty TSRMLS_DC);
+
/* Used to remove a property of the object */
typedef void (*zend_object_unset_property_t)(zval *object, zval *member TSRMLS_DC);
-/* Used to remove a property of the object */
+/* Used to remove a dimension of the object */
typedef void (*zend_object_unset_dimension_t)(zval *object, zval *offset TSRMLS_DC);
/* Used to get hash of the properties of the object, as hash of zval's */
@@ -98,6 +101,7 @@ typedef struct _zend_object_handlers {
zend_object_set_t set;
zend_object_has_property_t has_property;
zend_object_unset_property_t unset_property;
+ zend_object_has_dimension_t has_dimension;
zend_object_unset_dimension_t unset_dimension;
zend_object_get_properties_t get_properties;
zend_object_get_method_t get_method;
diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c
index 58ef78c4e3..86fd2aab5b 100644
--- a/Zend/zend_objects_API.c
+++ b/Zend/zend_objects_API.c
@@ -280,6 +280,8 @@ static zend_object_handlers zend_object_proxy_handlers = {
zend_object_proxy_set, /* set */
NULL, /* has_property */
NULL, /* unset_property */
+ NULL, /* has_dimension */
+ NULL, /* unset_dimension */
NULL, /* get_properties */
NULL, /* get_method */
NULL, /* call_method */