1999-04-08 02:10:10 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2014-01-03 11:08:10 +08:00
|
|
|
| Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
|
1999-04-08 02:10:10 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2001-12-11 23:16:21 +08:00
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
1999-07-16 22:58:16 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
2001-12-11 23:16:21 +08:00
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
1999-07-16 22:58:16 +08:00
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
1999-04-08 02:10:10 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Andi Gutmans <andi@zend.com> |
|
|
|
|
| Zeev Suraski <zeev@zend.com> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2003-02-01 09:49:15 +08:00
|
|
|
/* $Id$ */
|
1999-07-16 22:58:16 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "zend.h"
|
|
|
|
#include "zend_API.h"
|
2013-10-31 15:57:12 +08:00
|
|
|
#include "zend_ast.h"
|
1999-04-08 02:10:10 +08:00
|
|
|
#include "zend_globals.h"
|
|
|
|
#include "zend_constants.h"
|
|
|
|
#include "zend_list.h"
|
|
|
|
|
2014-03-19 21:00:28 +08:00
|
|
|
ZEND_API void _zval_dtor_func(zend_refcounted *p ZEND_FILE_LINE_DC)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2014-04-02 18:34:44 +08:00
|
|
|
switch (GC_TYPE(p)) {
|
1999-04-08 02:10:10 +08:00
|
|
|
case IS_STRING:
|
2014-03-19 21:00:28 +08:00
|
|
|
case IS_CONSTANT: {
|
|
|
|
zend_string *str = (zend_string*)p;
|
2014-04-15 19:40:40 +08:00
|
|
|
CHECK_ZVAL_STRING_REL(str);
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_string_release(str);
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-03-19 21:00:28 +08:00
|
|
|
}
|
2014-05-07 19:03:56 +08:00
|
|
|
case IS_ARRAY: {
|
|
|
|
zend_array *arr = (zend_array*)p;
|
2014-12-14 06:06:14 +08:00
|
|
|
|
2014-03-19 21:00:28 +08:00
|
|
|
if (arr != &EG(symbol_table)) {
|
2012-10-18 20:10:35 +08:00
|
|
|
/* break possible cycles */
|
2014-04-02 18:34:44 +08:00
|
|
|
GC_TYPE(arr) = IS_NULL;
|
2014-04-03 19:26:23 +08:00
|
|
|
GC_REMOVE_FROM_BUFFER(arr);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_array_destroy(&arr->ht);
|
2014-08-26 20:21:58 +08:00
|
|
|
efree_size(arr, sizeof(zend_array));
|
2014-02-12 22:08:11 +08:00
|
|
|
}
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
2014-03-19 21:00:28 +08:00
|
|
|
case IS_CONSTANT_AST: {
|
2014-05-07 19:03:56 +08:00
|
|
|
zend_ast_ref *ast = (zend_ast_ref*)p;
|
2014-03-19 21:00:28 +08:00
|
|
|
|
2014-07-27 00:08:31 +08:00
|
|
|
zend_ast_destroy_and_free(ast->ast);
|
2014-08-26 20:21:58 +08:00
|
|
|
efree_size(ast, sizeof(zend_ast_ref));
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-03-19 21:00:28 +08:00
|
|
|
}
|
|
|
|
case IS_OBJECT: {
|
|
|
|
zend_object *obj = (zend_object*)p;
|
2014-12-14 06:06:14 +08:00
|
|
|
|
2014-03-19 21:00:28 +08:00
|
|
|
OBJ_RELEASE(obj);
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2002-03-16 00:26:17 +08:00
|
|
|
}
|
2014-03-19 21:00:28 +08:00
|
|
|
case IS_RESOURCE: {
|
|
|
|
zend_resource *res = (zend_resource*)p;
|
2014-12-14 06:06:14 +08:00
|
|
|
|
2014-04-02 18:34:44 +08:00
|
|
|
if (--GC_REFCOUNT(res) == 0) {
|
2014-02-10 14:04:30 +08:00
|
|
|
/* destroy resource */
|
2014-05-08 06:48:31 +08:00
|
|
|
zend_list_free(res);
|
2014-02-10 14:04:30 +08:00
|
|
|
}
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2001-07-30 12:54:16 +08:00
|
|
|
}
|
2014-03-19 21:00:28 +08:00
|
|
|
case IS_REFERENCE: {
|
|
|
|
zend_reference *ref = (zend_reference*)p;
|
2014-04-02 18:34:44 +08:00
|
|
|
if (--GC_REFCOUNT(ref) == 0) {
|
2014-12-14 06:06:14 +08:00
|
|
|
|
|
|
|
i_zval_ptr_dtor(&ref->val ZEND_FILE_LINE_RELAY_CC);
|
2014-08-26 20:21:58 +08:00
|
|
|
efree_size(ref, sizeof(zend_reference));
|
2014-03-19 21:00:28 +08:00
|
|
|
}
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-02-18 20:27:38 +08:00
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
default:
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-19 21:00:28 +08:00
|
|
|
ZEND_API void _zval_dtor_func_for_ptr(zend_refcounted *p ZEND_FILE_LINE_DC)
|
2014-02-17 21:59:18 +08:00
|
|
|
{
|
2014-04-02 18:34:44 +08:00
|
|
|
switch (GC_TYPE(p)) {
|
2014-02-17 21:59:18 +08:00
|
|
|
case IS_STRING:
|
2014-03-19 21:00:28 +08:00
|
|
|
case IS_CONSTANT: {
|
|
|
|
zend_string *str = (zend_string*)p;
|
2014-04-15 19:40:40 +08:00
|
|
|
CHECK_ZVAL_STRING_REL(str);
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_string_free(str);
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-03-19 21:00:28 +08:00
|
|
|
}
|
2014-05-07 19:03:56 +08:00
|
|
|
case IS_ARRAY: {
|
|
|
|
zend_array *arr = (zend_array*)p;
|
2014-12-14 06:06:14 +08:00
|
|
|
|
2014-03-19 21:00:28 +08:00
|
|
|
if (arr != &EG(symbol_table)) {
|
2014-02-17 21:59:18 +08:00
|
|
|
/* break possible cycles */
|
2014-04-02 18:34:44 +08:00
|
|
|
GC_TYPE(arr) = IS_NULL;
|
2014-04-03 19:26:23 +08:00
|
|
|
GC_REMOVE_FROM_BUFFER(arr);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_array_destroy(&arr->ht);
|
2014-08-26 20:21:58 +08:00
|
|
|
efree_size(arr, sizeof(zend_array));
|
2014-02-17 21:59:18 +08:00
|
|
|
}
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-02-17 21:59:18 +08:00
|
|
|
}
|
2014-03-19 21:00:28 +08:00
|
|
|
case IS_CONSTANT_AST: {
|
2014-05-07 19:03:56 +08:00
|
|
|
zend_ast_ref *ast = (zend_ast_ref*)p;
|
2014-03-19 21:00:28 +08:00
|
|
|
|
2014-07-27 00:08:31 +08:00
|
|
|
zend_ast_destroy_and_free(ast->ast);
|
2014-08-26 20:21:58 +08:00
|
|
|
efree_size(ast, sizeof(zend_ast_ref));
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-03-19 21:00:28 +08:00
|
|
|
}
|
|
|
|
case IS_OBJECT: {
|
|
|
|
zend_object *obj = (zend_object*)p;
|
2014-12-14 06:06:14 +08:00
|
|
|
|
|
|
|
zend_objects_store_del(obj);
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-02-17 21:59:18 +08:00
|
|
|
}
|
2014-03-19 21:00:28 +08:00
|
|
|
case IS_RESOURCE: {
|
|
|
|
zend_resource *res = (zend_resource*)p;
|
2014-12-14 06:06:14 +08:00
|
|
|
|
2014-02-17 21:59:18 +08:00
|
|
|
/* destroy resource */
|
2014-05-08 06:48:31 +08:00
|
|
|
zend_list_free(res);
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-03-19 21:00:28 +08:00
|
|
|
}
|
|
|
|
case IS_REFERENCE: {
|
|
|
|
zend_reference *ref = (zend_reference*)p;
|
2014-12-14 06:06:14 +08:00
|
|
|
|
|
|
|
i_zval_ptr_dtor(&ref->val ZEND_FILE_LINE_RELAY_CC);
|
2014-08-26 20:21:58 +08:00
|
|
|
efree_size(ref, sizeof(zend_reference));
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-02-17 21:59:18 +08:00
|
|
|
}
|
|
|
|
default:
|
2014-04-03 19:26:23 +08:00
|
|
|
break;
|
2014-02-17 21:59:18 +08:00
|
|
|
}
|
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2003-08-25 01:32:47 +08:00
|
|
|
ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC)
|
|
|
|
{
|
2014-04-03 19:26:23 +08:00
|
|
|
switch (Z_TYPE_P(zvalue)) {
|
2003-08-25 01:32:47 +08:00
|
|
|
case IS_STRING:
|
|
|
|
case IS_CONSTANT:
|
2014-04-15 19:40:40 +08:00
|
|
|
CHECK_ZVAL_STRING_REL(Z_STR_P(zvalue));
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_string_release(Z_STR_P(zvalue));
|
2003-08-25 01:32:47 +08:00
|
|
|
break;
|
|
|
|
case IS_ARRAY:
|
2013-11-07 02:21:07 +08:00
|
|
|
case IS_CONSTANT_AST:
|
2003-08-25 01:32:47 +08:00
|
|
|
case IS_OBJECT:
|
|
|
|
case IS_RESOURCE:
|
|
|
|
zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
|
|
|
|
break;
|
2014-04-14 17:24:43 +08:00
|
|
|
case IS_REFERENCE: {
|
|
|
|
zend_reference *ref = (zend_reference*)Z_REF_P(zvalue);
|
|
|
|
|
|
|
|
zval_internal_ptr_dtor(&ref->val);
|
|
|
|
free(ref);
|
|
|
|
break;
|
|
|
|
}
|
2003-08-25 01:32:47 +08:00
|
|
|
case IS_LONG:
|
|
|
|
case IS_DOUBLE:
|
2014-04-30 22:32:42 +08:00
|
|
|
case IS_FALSE:
|
|
|
|
case IS_TRUE:
|
2003-08-25 01:32:47 +08:00
|
|
|
case IS_NULL:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-17 21:59:18 +08:00
|
|
|
ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC)
|
|
|
|
{
|
2014-04-03 19:26:23 +08:00
|
|
|
switch (Z_TYPE_P(zvalue)) {
|
2014-02-17 21:59:18 +08:00
|
|
|
case IS_STRING:
|
|
|
|
case IS_CONSTANT:
|
2014-04-15 19:40:40 +08:00
|
|
|
CHECK_ZVAL_STRING_REL(Z_STR_P(zvalue));
|
2014-08-26 01:24:55 +08:00
|
|
|
zend_string_free(Z_STR_P(zvalue));
|
2014-02-17 21:59:18 +08:00
|
|
|
break;
|
|
|
|
case IS_ARRAY:
|
|
|
|
case IS_CONSTANT_AST:
|
|
|
|
case IS_OBJECT:
|
|
|
|
case IS_RESOURCE:
|
|
|
|
zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
|
|
|
|
break;
|
2014-04-14 17:24:43 +08:00
|
|
|
case IS_REFERENCE: {
|
|
|
|
zend_reference *ref = (zend_reference*)Z_REF_P(zvalue);
|
|
|
|
|
|
|
|
zval_internal_ptr_dtor(&ref->val);
|
|
|
|
free(ref);
|
|
|
|
break;
|
|
|
|
}
|
2014-02-17 21:59:18 +08:00
|
|
|
case IS_LONG:
|
|
|
|
case IS_DOUBLE:
|
2014-04-30 22:32:42 +08:00
|
|
|
case IS_FALSE:
|
|
|
|
case IS_TRUE:
|
2014-02-17 21:59:18 +08:00
|
|
|
case IS_NULL:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-08-25 01:32:47 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
ZEND_API void zval_add_ref(zval *p)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2014-02-28 15:03:05 +08:00
|
|
|
if (Z_REFCOUNTED_P(p)) {
|
2014-03-06 16:37:46 +08:00
|
|
|
if (Z_ISREF_P(p) && Z_REFCOUNT_P(p) == 1) {
|
2015-01-05 22:13:22 +08:00
|
|
|
zend_reference *ref = Z_REF_P(p);
|
2014-06-05 20:04:11 +08:00
|
|
|
ZVAL_COPY(p, Z_REFVAL_P(p));
|
2015-01-05 22:20:13 +08:00
|
|
|
efree_size(ref, sizeof(zend_reference));
|
2014-03-06 16:37:46 +08:00
|
|
|
} else {
|
|
|
|
Z_ADDREF_P(p);
|
|
|
|
}
|
2014-02-10 14:04:30 +08:00
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
|
2014-02-28 15:03:05 +08:00
|
|
|
ZEND_API void zval_add_ref_unref(zval *p)
|
|
|
|
{
|
|
|
|
if (Z_REFCOUNTED_P(p)) {
|
|
|
|
if (Z_ISREF_P(p)) {
|
2014-10-20 17:55:55 +08:00
|
|
|
ZVAL_COPY(p, Z_REFVAL_P(p));
|
2014-02-28 15:03:05 +08:00
|
|
|
} else {
|
|
|
|
Z_ADDREF_P(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2004-09-27 10:29:01 +08:00
|
|
|
ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2014-04-03 19:26:23 +08:00
|
|
|
switch (Z_TYPE_P(zvalue)) {
|
2000-04-27 06:10:06 +08:00
|
|
|
case IS_CONSTANT:
|
1999-04-08 02:10:10 +08:00
|
|
|
case IS_STRING:
|
2014-04-15 19:40:40 +08:00
|
|
|
CHECK_ZVAL_STRING_REL(Z_STR_P(zvalue));
|
2014-08-26 01:24:55 +08:00
|
|
|
Z_STR_P(zvalue) = zend_string_dup(Z_STR_P(zvalue), 0);
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
2014-05-07 19:03:56 +08:00
|
|
|
case IS_ARRAY: {
|
2014-03-20 15:48:49 +08:00
|
|
|
HashTable *ht;
|
2014-12-14 06:06:14 +08:00
|
|
|
|
2014-03-20 15:37:42 +08:00
|
|
|
if (Z_ARR_P(zvalue) == &EG(symbol_table)) {
|
2004-09-27 10:29:01 +08:00
|
|
|
return; /* do nothing */
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
2014-03-20 15:48:49 +08:00
|
|
|
ht = Z_ARRVAL_P(zvalue);
|
|
|
|
ZVAL_NEW_ARR(zvalue);
|
2014-05-24 00:37:53 +08:00
|
|
|
zend_array_dup(Z_ARRVAL_P(zvalue), ht);
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
break;
|
2014-02-10 14:04:30 +08:00
|
|
|
case IS_CONSTANT_AST: {
|
|
|
|
zend_ast_ref *ast = emalloc(sizeof(zend_ast_ref));
|
|
|
|
|
2014-04-02 18:34:44 +08:00
|
|
|
GC_REFCOUNT(ast) = 1;
|
|
|
|
GC_TYPE_INFO(ast) = IS_CONSTANT_AST;
|
2014-02-10 14:04:30 +08:00
|
|
|
ast->ast = zend_ast_copy(Z_ASTVAL_P(zvalue));
|
|
|
|
Z_AST_P(zvalue) = ast;
|
|
|
|
}
|
2013-10-31 15:57:12 +08:00
|
|
|
break;
|
2001-08-07 11:17:33 +08:00
|
|
|
case IS_OBJECT:
|
2014-02-10 14:04:30 +08:00
|
|
|
case IS_RESOURCE:
|
|
|
|
case IS_REFERENCE:
|
|
|
|
Z_ADDREF_P(zvalue);
|
1999-04-08 02:10:10 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API size_t zend_print_variable(zval *var)
|
1999-04-08 02:10:10 +08:00
|
|
|
{
|
2014-12-14 06:06:14 +08:00
|
|
|
return zend_print_zval(var, 0);
|
1999-04-08 02:10:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-18 01:33:37 +08:00
|
|
|
ZEND_API void _zval_dtor_wrapper(zval *zvalue)
|
1999-08-28 03:17:19 +08:00
|
|
|
{
|
2000-01-18 01:33:37 +08:00
|
|
|
zval_dtor(zvalue);
|
1999-08-28 03:17:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-11 18:07:10 +08:00
|
|
|
#if ZEND_DEBUG
|
|
|
|
ZEND_API void _zval_copy_ctor_wrapper(zval *zvalue)
|
|
|
|
{
|
|
|
|
zval_copy_ctor(zvalue);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-25 01:32:47 +08:00
|
|
|
ZEND_API void _zval_internal_dtor_wrapper(zval *zvalue)
|
|
|
|
{
|
|
|
|
zval_internal_dtor(zvalue);
|
|
|
|
}
|
|
|
|
|
1999-08-28 03:17:19 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
ZEND_API void _zval_ptr_dtor_wrapper(zval *zval_ptr)
|
1999-08-28 03:17:19 +08:00
|
|
|
{
|
2014-11-25 18:05:35 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
i_zval_ptr_dtor(zval_ptr ZEND_FILE_LINE_CC);
|
1999-08-28 03:17:19 +08:00
|
|
|
}
|
2003-08-25 01:32:47 +08:00
|
|
|
|
2014-03-11 14:23:14 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
ZEND_API void _zval_internal_ptr_dtor_wrapper(zval *zval_ptr)
|
2003-08-25 01:32:47 +08:00
|
|
|
{
|
|
|
|
zval_internal_ptr_dtor(zval_ptr);
|
|
|
|
}
|
1999-08-28 03:17:19 +08:00
|
|
|
#endif
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API int zval_copy_static_var(zval *p, int num_args, va_list args, zend_hash_key *key) /* {{{ */
|
2010-06-08 23:56:36 +08:00
|
|
|
{
|
2014-07-04 22:03:45 +08:00
|
|
|
zend_array *symbol_table;
|
2010-06-08 23:56:36 +08:00
|
|
|
HashTable *target = va_arg(args, HashTable*);
|
|
|
|
zend_bool is_ref;
|
2014-02-10 14:04:30 +08:00
|
|
|
zval tmp;
|
2010-06-08 23:56:36 +08:00
|
|
|
|
2014-04-03 19:26:23 +08:00
|
|
|
if (Z_CONST_FLAGS_P(p) & (IS_LEXICAL_VAR|IS_LEXICAL_REF)) {
|
|
|
|
is_ref = Z_CONST_FLAGS_P(p) & IS_LEXICAL_REF;
|
2010-06-08 23:56:36 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
symbol_table = zend_rebuild_symbol_table();
|
2014-07-04 22:03:45 +08:00
|
|
|
p = zend_hash_find(&symbol_table->ht, key->key);
|
2014-02-10 14:04:30 +08:00
|
|
|
if (!p) {
|
|
|
|
p = &tmp;
|
|
|
|
ZVAL_NULL(&tmp);
|
|
|
|
if (is_ref) {
|
|
|
|
ZVAL_NEW_REF(&tmp, &tmp);
|
2014-07-04 22:03:45 +08:00
|
|
|
zend_hash_add_new(&symbol_table->ht, key->key, &tmp);
|
2014-03-22 01:34:15 +08:00
|
|
|
Z_ADDREF_P(p);
|
2010-06-08 23:56:36 +08:00
|
|
|
} else {
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_error(E_NOTICE,"Undefined variable: %s", key->key->val);
|
2010-06-08 23:56:36 +08:00
|
|
|
}
|
|
|
|
} else {
|
2014-03-26 22:07:31 +08:00
|
|
|
if (Z_TYPE_P(p) == IS_INDIRECT) {
|
|
|
|
p = Z_INDIRECT_P(p);
|
|
|
|
if (Z_TYPE_P(p) == IS_UNDEF) {
|
|
|
|
if (!is_ref) {
|
|
|
|
zend_error(E_NOTICE,"Undefined variable: %s", key->key->val);
|
|
|
|
p = &tmp;
|
|
|
|
ZVAL_NULL(&tmp);
|
|
|
|
} else {
|
|
|
|
ZVAL_NULL(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-06-08 23:56:36 +08:00
|
|
|
if (is_ref) {
|
2014-06-05 20:04:11 +08:00
|
|
|
ZVAL_MAKE_REF(p);
|
2014-03-22 01:34:15 +08:00
|
|
|
Z_ADDREF_P(p);
|
2014-02-10 14:04:30 +08:00
|
|
|
} else if (Z_ISREF_P(p)) {
|
2014-03-22 01:34:15 +08:00
|
|
|
ZVAL_DUP(&tmp, Z_REFVAL_P(p));
|
2014-02-10 14:04:30 +08:00
|
|
|
p = &tmp;
|
2014-03-22 01:34:15 +08:00
|
|
|
} else if (Z_REFCOUNTED_P(p)) {
|
|
|
|
Z_ADDREF_P(p);
|
2010-06-08 23:56:36 +08:00
|
|
|
}
|
|
|
|
}
|
2014-03-22 01:34:15 +08:00
|
|
|
} else if (Z_REFCOUNTED_P(p)) {
|
|
|
|
Z_ADDREF_P(p);
|
|
|
|
}
|
|
|
|
zend_hash_add(target, key->key, p);
|
2010-06-08 23:56:36 +08:00
|
|
|
return ZEND_HASH_APPLY_KEEP;
|
|
|
|
}
|
|
|
|
/* }}} */
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
2003-02-01 09:49:15 +08:00
|
|
|
* indent-tabs-mode: t
|
1999-04-08 02:10:10 +08:00
|
|
|
* End:
|
|
|
|
*/
|