summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend-parser.y2
-rw-r--r--Zend/zend.h1
-rw-r--r--Zend/zend_API.c2
-rw-r--r--Zend/zend_execute.c13
-rw-r--r--Zend/zend_execute.h2
-rw-r--r--Zend/zend_execute_API.c15
-rw-r--r--Zend/zend_extensions.h2
-rw-r--r--Zend/zend_variables.c6
8 files changed, 25 insertions, 18 deletions
diff --git a/Zend/zend-parser.y b/Zend/zend-parser.y
index 27fe60c3dc..9d5219b47d 100644
--- a/Zend/zend-parser.y
+++ b/Zend/zend-parser.y
@@ -530,7 +530,7 @@ static_scalar: /* compile-time evaluated scalars */
| T_STRING { do_fetch_constant(&$$, &$1, ZEND_CT CLS_CC); }
| '+' static_scalar { $$ = $1; }
| '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; minus_one.value.lval = -1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one); $$ = $2; }
- | T_ARRAY '(' static_array_pair_list ')' { $$ = $3; }
+ | T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type = IS_CONSTANT_ARRAY; }
;
diff --git a/Zend/zend.h b/Zend/zend.h
index 7f99fc6356..6bdc6e07d4 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -267,6 +267,7 @@ typedef int (*zend_write_func_t)(const char *str, uint str_length);
#define IS_BOOL 6
#define IS_RESOURCE 7
#define IS_CONSTANT 8
+#define IS_CONSTANT_ARRAY 9
/* Special data type to temporarily mark large numbers */
#define FLAG_IS_BC 9 /* for parser internal use only */
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 8cb751d066..c856b6672d 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -202,7 +202,7 @@ ZEND_API inline int _object_init_ex(zval *arg, zend_class_entry *class_type ZEND
zval *tmp;
if (!class_type->constants_updated) {
- zend_hash_apply(&class_type->default_properties, (int (*)(void *)) zval_update_constant);
+ zend_hash_apply_with_argument(&class_type->default_properties, (int (*)(void *,void *)) zval_update_constant, (void *) 1);
class_type->constants_updated = 1;
}
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index c699b1c5eb..e05ccf4a12 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -516,7 +516,7 @@ static void zend_fetch_var_address(znode *result, znode *op1, znode *op2, temp_v
if (op2->u.fetch_type == ZEND_FETCH_LOCAL) {
FREE_OP(op1, free_op1);
} else if (op2->u.fetch_type == ZEND_FETCH_STATIC) {
- zval_update_constant(retval);
+ zval_update_constant(retval, (void *) 1);
}
if (varname == &tmp_varname) {
@@ -1317,7 +1317,7 @@ binary_assign_op_addr: {
zval *value;
value = get_zval_ptr(&opline->op2, Ts, &EG(free_op2), BP_VAR_R);
- zend_assign_to_variable(&opline->result, &opline->op1, &opline->op2, value, (EG(free_op2)?IS_TMP_VAR:opline->op2.op_type), Ts ELS_CC);
+ zend_assign_to_variable(&opline->result, &opline->op1, &opline->op2, value, (EG(free_op2)?IS_TMP_VAR:opline->op2.op_type), Ts ELS_CC);
/* zend_assign_to_variable() always takes care of op2, never free it! */
}
NEXT_OPCODE();
@@ -1782,18 +1782,15 @@ send_by_ref:
zval **param, *assignment_value;
if (zend_ptr_stack_get_arg(opline->op1.u.constant.value.lval, (void **) &param ELS_CC)==FAILURE) {
- if (opline->op2.u.constant.type == IS_CONSTANT) {
+ if (opline->op2.u.constant.type == IS_CONSTANT || opline->op2.u.constant.type==IS_CONSTANT_ARRAY) {
zval *default_value;
- zval tmp;
ALLOC_ZVAL(default_value);
*default_value = opline->op2.u.constant;
- if (!zend_get_constant(default_value->value.str.val, default_value->value.str.len, &tmp)) {
- default_value->type = IS_STRING;
+ if (opline->op2.u.constant.type==IS_CONSTANT_ARRAY) {
zval_copy_ctor(default_value);
- } else {
- *default_value = tmp;
}
+ zval_update_constant(&default_value, 0);
default_value->refcount=0;
default_value->is_ref=0;
param = &default_value;
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index 449e4e39de..2ff01f9c18 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -55,7 +55,7 @@ ZEND_API int zend_is_true(zval *op);
ZEND_API inline void safe_free_zval_ptr(zval *p);
ZEND_API int zend_eval_string(char *str, zval *retval_ptr CLS_DC ELS_DC);
ZEND_API inline int i_zend_is_true(zval *op);
-ZEND_API int zval_update_constant(zval **pp);
+ZEND_API int zval_update_constant(zval **pp, void *arg);
ZEND_API inline void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts ELS_DC);
/* dedicated Zend executor functions - do not use! */
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index f5916a1023..21ee9c40c0 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -286,9 +286,10 @@ ZEND_API int zend_is_true(zval *op)
}
-ZEND_API int zval_update_constant(zval **pp)
+ZEND_API int zval_update_constant(zval **pp, void *arg)
{
zval *p = *pp;
+ zend_bool inline_change = (zend_bool) arg;
if (p->type == IS_CONSTANT) {
zval c;
@@ -304,16 +305,22 @@ ZEND_API int zval_update_constant(zval **pp)
p->value.str.val,
p->value.str.val);
p->type = IS_STRING;
+ if (!inline_change) {
+ zval_copy_ctor(p);
+ }
} else {
- STR_FREE(p->value.str.val);
+ if (inline_change) {
+ STR_FREE(p->value.str.val);
+ }
*p = c;
}
INIT_PZVAL(p);
p->refcount = refcount;
- } else if (p->type == IS_ARRAY) {
+ } else if (p->type == IS_CONSTANT_ARRAY) {
SEPARATE_ZVAL(pp);
p = *pp;
- zend_hash_apply(p->value.ht, (int (*)(void *)) zval_update_constant);
+ p->type = IS_ARRAY;
+ zend_hash_apply_with_argument(p->value.ht, (int (*)(void *,void *)) zval_update_constant, (void *) 1);
}
return 0;
}
diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h
index 1dff4785a9..51d47f1379 100644
--- a/Zend/zend_extensions.h
+++ b/Zend/zend_extensions.h
@@ -23,7 +23,7 @@
#include "zend_compile.h"
-#define ZEND_EXTENSION_API_NO 20000521
+#define ZEND_EXTENSION_API_NO 20000531
typedef struct _zend_extension_version_info {
int zend_extension_api_no;
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index 2fa87df02d..e1639a8ad8 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -61,7 +61,8 @@ ZEND_API void _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC)
case IS_CONSTANT:
STR_FREE_REL(zvalue->value.str.val);
break;
- case IS_ARRAY: {
+ case IS_ARRAY:
+ case IS_CONSTANT_ARRAY: {
ELS_FETCH();
if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) {
@@ -125,7 +126,8 @@ ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC)
}
zvalue->value.str.val = (char *) estrndup_rel(zvalue->value.str.val, zvalue->value.str.len);
break;
- case IS_ARRAY: {
+ case IS_ARRAY:
+ case IS_CONSTANT_ARRAY: {
zval *tmp;
HashTable *original_ht = zvalue->value.ht;
ELS_FETCH();