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> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2001-12-11 17:17:38 +08:00
|
|
|
/* $Id$ */
|
1999-07-16 22:58:16 +08:00
|
|
|
|
2000-07-03 07:54:19 +08:00
|
|
|
#ifndef ZEND_H
|
|
|
|
#define ZEND_H
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2013-12-03 14:42:37 +08:00
|
|
|
#define ZEND_VERSION "2.7.0-dev"
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2001-12-30 02:07:08 +08:00
|
|
|
#define ZEND_ENGINE_2
|
|
|
|
|
1999-04-23 11:32:33 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#define BEGIN_EXTERN_C() extern "C" {
|
|
|
|
#define END_EXTERN_C() }
|
|
|
|
#else
|
|
|
|
#define BEGIN_EXTERN_C()
|
|
|
|
#define END_EXTERN_C()
|
|
|
|
#endif
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
/*
|
|
|
|
* general definitions
|
|
|
|
*/
|
|
|
|
|
2000-02-11 23:59:30 +08:00
|
|
|
#ifdef ZEND_WIN32
|
1999-09-07 00:14:08 +08:00
|
|
|
# include "zend_config.w32.h"
|
2001-01-03 16:35:23 +08:00
|
|
|
# define ZEND_PATHS_SEPARATOR ';'
|
2002-05-30 16:52:21 +08:00
|
|
|
#elif defined(NETWARE)
|
2005-02-22 16:48:33 +08:00
|
|
|
# include <zend_config.h>
|
2004-09-22 20:49:08 +08:00
|
|
|
# define ZEND_PATHS_SEPARATOR ';'
|
2001-11-03 21:35:14 +08:00
|
|
|
#elif defined(__riscos__)
|
2005-01-10 05:05:06 +08:00
|
|
|
# include <zend_config.h>
|
2001-11-03 21:35:14 +08:00
|
|
|
# define ZEND_PATHS_SEPARATOR ';'
|
1999-04-08 02:10:10 +08:00
|
|
|
#else
|
2005-01-10 05:05:06 +08:00
|
|
|
# include <zend_config.h>
|
2001-01-03 16:35:23 +08:00
|
|
|
# define ZEND_PATHS_SEPARATOR ':'
|
1999-09-07 00:14:08 +08:00
|
|
|
#endif
|
|
|
|
|
2002-06-08 21:01:05 +08:00
|
|
|
/* Only use this macro if you know for sure that all of the switches values
|
|
|
|
are covered by its case statements */
|
2014-05-17 00:54:01 +08:00
|
|
|
#if ZEND_DEBUG
|
|
|
|
# define EMPTY_SWITCH_DEFAULT_CASE() default: ZEND_ASSERT(0); break;
|
|
|
|
#elif defined(ZEND_WIN32)
|
|
|
|
# define EMPTY_SWITCH_DEFAULT_CASE() default: __assume(0); break;
|
2002-06-08 21:01:05 +08:00
|
|
|
#else
|
2014-05-17 00:54:01 +08:00
|
|
|
# define EMPTY_SWITCH_DEFAULT_CASE()
|
2002-06-08 21:01:05 +08:00
|
|
|
#endif
|
|
|
|
|
1999-09-07 00:14:08 +08:00
|
|
|
/* all HAVE_XXX test have to be after the include of zend_config above */
|
|
|
|
|
2009-06-02 01:51:53 +08:00
|
|
|
#include <stdio.h>
|
2014-02-10 14:04:30 +08:00
|
|
|
#include <assert.h>
|
2009-06-02 01:51:53 +08:00
|
|
|
|
1999-09-07 00:14:08 +08:00
|
|
|
#ifdef HAVE_UNIX_H
|
|
|
|
# include <unix.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STDARG_H
|
|
|
|
# include <stdarg.h>
|
1999-04-08 02:10:10 +08:00
|
|
|
#endif
|
|
|
|
|
2000-01-13 03:52:33 +08:00
|
|
|
#ifdef HAVE_DLFCN_H
|
|
|
|
# include <dlfcn.h>
|
|
|
|
#endif
|
|
|
|
|
2009-08-06 09:33:54 +08:00
|
|
|
#if defined(HAVE_LIBDL) && !defined(ZEND_WIN32)
|
2000-03-25 23:40:08 +08:00
|
|
|
|
|
|
|
# ifndef RTLD_LAZY
|
|
|
|
# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifndef RTLD_GLOBAL
|
|
|
|
# define RTLD_GLOBAL 0
|
|
|
|
# endif
|
|
|
|
|
2004-03-16 00:06:29 +08:00
|
|
|
# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
|
|
|
|
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
|
2005-01-25 21:08:05 +08:00
|
|
|
# elif defined(RTLD_DEEPBIND)
|
|
|
|
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND)
|
2004-03-16 00:06:29 +08:00
|
|
|
# else
|
|
|
|
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
|
|
|
|
# endif
|
2000-01-14 04:34:45 +08:00
|
|
|
# define DL_UNLOAD dlclose
|
2001-08-26 23:25:55 +08:00
|
|
|
# if defined(DLSYM_NEEDS_UNDERSCORE)
|
2002-08-13 23:14:45 +08:00
|
|
|
# define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s)
|
2001-08-26 23:25:55 +08:00
|
|
|
# else
|
|
|
|
# define DL_FETCH_SYMBOL dlsym
|
|
|
|
# endif
|
2002-04-08 01:12:38 +08:00
|
|
|
# define DL_ERROR dlerror
|
|
|
|
# define DL_HANDLE void *
|
|
|
|
# define ZEND_EXTENSIONS_SUPPORT 1
|
2000-02-11 23:59:30 +08:00
|
|
|
#elif defined(ZEND_WIN32)
|
2000-01-14 04:34:45 +08:00
|
|
|
# define DL_LOAD(libname) LoadLibrary(libname)
|
|
|
|
# define DL_FETCH_SYMBOL GetProcAddress
|
|
|
|
# define DL_UNLOAD FreeLibrary
|
|
|
|
# define DL_HANDLE HMODULE
|
|
|
|
# define ZEND_EXTENSIONS_SUPPORT 1
|
2000-01-13 03:52:33 +08:00
|
|
|
#else
|
2000-01-14 04:34:45 +08:00
|
|
|
# define DL_HANDLE void *
|
|
|
|
# define ZEND_EXTENSIONS_SUPPORT 0
|
2000-01-13 03:52:33 +08:00
|
|
|
#endif
|
|
|
|
|
2002-11-12 00:32:57 +08:00
|
|
|
#if HAVE_ALLOCA_H && !defined(_ALLOCA_H)
|
|
|
|
# include <alloca.h>
|
|
|
|
#endif
|
|
|
|
|
2001-12-11 17:17:38 +08:00
|
|
|
/* AIX requires this to be the first thing in the file. */
|
|
|
|
#ifndef __GNUC__
|
2002-11-12 00:32:57 +08:00
|
|
|
# ifndef HAVE_ALLOCA_H
|
2001-12-11 17:17:38 +08:00
|
|
|
# ifdef _AIX
|
2003-08-26 07:24:29 +08:00
|
|
|
#pragma alloca
|
2001-12-11 17:17:38 +08:00
|
|
|
# else
|
|
|
|
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
|
|
|
char *alloca ();
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# endif
|
2000-03-26 22:46:25 +08:00
|
|
|
#endif
|
2000-03-27 00:28:37 +08:00
|
|
|
|
2012-05-24 10:18:01 +08:00
|
|
|
/* Compatibility with non-clang compilers */
|
|
|
|
#ifndef __has_attribute
|
|
|
|
# define __has_attribute(x) 0
|
|
|
|
#endif
|
|
|
|
|
2004-03-17 01:35:57 +08:00
|
|
|
/* GCC x.y.z supplies __GNUC__ = x and __GNUC_MINOR__ = y */
|
2003-08-28 22:53:02 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
# define ZEND_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
|
|
|
#else
|
2003-08-29 01:04:16 +08:00
|
|
|
# define ZEND_GCC_VERSION 0
|
2003-08-28 22:53:02 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ZEND_GCC_VERSION >= 2096
|
|
|
|
# define ZEND_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
|
|
|
#else
|
|
|
|
# define ZEND_ATTRIBUTE_MALLOC
|
|
|
|
#endif
|
|
|
|
|
2012-05-24 10:18:01 +08:00
|
|
|
#if ZEND_GCC_VERSION >= 4003 || __has_attribute(alloc_size)
|
|
|
|
# define ZEND_ATTRIBUTE_ALLOC_SIZE(X) __attribute__ ((alloc_size(X)))
|
|
|
|
# define ZEND_ATTRIBUTE_ALLOC_SIZE2(X,Y) __attribute__ ((alloc_size(X,Y)))
|
|
|
|
#else
|
|
|
|
# define ZEND_ATTRIBUTE_ALLOC_SIZE(X)
|
|
|
|
# define ZEND_ATTRIBUTE_ALLOC_SIZE2(X,Y)
|
|
|
|
#endif
|
|
|
|
|
2003-08-29 00:41:20 +08:00
|
|
|
#if ZEND_GCC_VERSION >= 2007
|
|
|
|
# define ZEND_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
|
|
|
|
#else
|
|
|
|
# define ZEND_ATTRIBUTE_FORMAT(type, idx, first)
|
|
|
|
#endif
|
|
|
|
|
2005-11-25 20:25:05 +08:00
|
|
|
#if ZEND_GCC_VERSION >= 3001 && !defined(__INTEL_COMPILER)
|
2003-08-29 01:31:31 +08:00
|
|
|
# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
|
|
|
|
#else
|
|
|
|
# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first)
|
|
|
|
#endif
|
|
|
|
|
2008-06-27 08:01:25 +08:00
|
|
|
#if ZEND_GCC_VERSION >= 3001
|
|
|
|
# define ZEND_ATTRIBUTE_DEPRECATED __attribute__((deprecated))
|
2008-06-28 02:44:39 +08:00
|
|
|
#elif defined(ZEND_WIN32) && defined(_MSC_VER) && _MSC_VER >= 1300
|
|
|
|
# define ZEND_ATTRIBUTE_DEPRECATED __declspec(deprecated)
|
2008-06-27 08:01:25 +08:00
|
|
|
#else
|
|
|
|
# define ZEND_ATTRIBUTE_DEPRECATED
|
|
|
|
#endif
|
|
|
|
|
2014-07-11 20:32:20 +08:00
|
|
|
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 4003
|
|
|
|
# define ZEND_ATTRIBUTE_UNUSED __attribute__((unused))
|
|
|
|
# define ZEND_ATTRIBUTE_UNUSED_LABEL __attribute__((cold, unused));
|
|
|
|
#else
|
|
|
|
# define ZEND_ATTRIBUTE_UNUSED
|
|
|
|
# define ZEND_ATTRIBUTE_UNUSED_LABEL
|
|
|
|
#endif
|
|
|
|
|
2010-01-16 02:26:53 +08:00
|
|
|
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
|
2008-06-11 21:18:41 +08:00
|
|
|
# define ZEND_FASTCALL __attribute__((fastcall))
|
|
|
|
#elif defined(_MSC_VER) && defined(_M_IX86)
|
|
|
|
# define ZEND_FASTCALL __fastcall
|
|
|
|
#else
|
|
|
|
# define ZEND_FASTCALL
|
|
|
|
#endif
|
|
|
|
|
2010-01-16 02:26:53 +08:00
|
|
|
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004
|
2009-06-01 23:07:42 +08:00
|
|
|
#else
|
|
|
|
# define __restrict__
|
|
|
|
#endif
|
|
|
|
#define restrict __restrict__
|
|
|
|
|
2013-10-24 23:48:09 +08:00
|
|
|
#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(NETWARE)) && !(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
|
2007-11-22 21:27:13 +08:00
|
|
|
# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
|
|
|
|
# define ALLOCA_FLAG(name) \
|
|
|
|
zend_bool name;
|
2007-11-23 23:03:03 +08:00
|
|
|
# define SET_ALLOCA_FLAG(name) \
|
|
|
|
name = 1
|
2007-11-22 21:27:13 +08:00
|
|
|
# define do_alloca_ex(size, limit, use_heap) \
|
|
|
|
((use_heap = (UNEXPECTED((size) > (limit)))) ? emalloc(size) : alloca(size))
|
|
|
|
# define do_alloca(size, use_heap) \
|
|
|
|
do_alloca_ex(size, ZEND_ALLOCA_MAX_SIZE, use_heap)
|
|
|
|
# define free_alloca(p, use_heap) \
|
|
|
|
do { if (UNEXPECTED(use_heap)) efree(p); } while (0)
|
2000-03-16 01:32:29 +08:00
|
|
|
#else
|
2007-11-22 21:27:13 +08:00
|
|
|
# define ALLOCA_FLAG(name)
|
2007-11-23 23:03:03 +08:00
|
|
|
# define SET_ALLOCA_FLAG(name)
|
2009-09-06 23:56:58 +08:00
|
|
|
# define do_alloca(p, use_heap) emalloc(p)
|
|
|
|
# define free_alloca(p, use_heap) efree(p)
|
2000-03-16 01:32:29 +08:00
|
|
|
#endif
|
|
|
|
|
1999-08-29 05:43:24 +08:00
|
|
|
#if ZEND_DEBUG
|
2010-03-31 07:14:19 +08:00
|
|
|
#define ZEND_FILE_LINE_D const char *__zend_filename, const uint __zend_lineno
|
1999-08-28 18:18:54 +08:00
|
|
|
#define ZEND_FILE_LINE_DC , ZEND_FILE_LINE_D
|
2010-03-31 07:14:19 +08:00
|
|
|
#define ZEND_FILE_LINE_ORIG_D const char *__zend_orig_filename, const uint __zend_orig_lineno
|
1999-08-28 18:18:54 +08:00
|
|
|
#define ZEND_FILE_LINE_ORIG_DC , ZEND_FILE_LINE_ORIG_D
|
|
|
|
#define ZEND_FILE_LINE_RELAY_C __zend_filename, __zend_lineno
|
|
|
|
#define ZEND_FILE_LINE_RELAY_CC , ZEND_FILE_LINE_RELAY_C
|
|
|
|
#define ZEND_FILE_LINE_C __FILE__, __LINE__
|
|
|
|
#define ZEND_FILE_LINE_CC , ZEND_FILE_LINE_C
|
|
|
|
#define ZEND_FILE_LINE_EMPTY_C NULL, 0
|
|
|
|
#define ZEND_FILE_LINE_EMPTY_CC , ZEND_FILE_LINE_EMPTY_C
|
|
|
|
#define ZEND_FILE_LINE_ORIG_RELAY_C __zend_orig_filename, __zend_orig_lineno
|
|
|
|
#define ZEND_FILE_LINE_ORIG_RELAY_CC , ZEND_FILE_LINE_ORIG_RELAY_C
|
2012-12-13 18:46:44 +08:00
|
|
|
#define ZEND_ASSERT(c) assert(c)
|
1999-08-28 03:17:19 +08:00
|
|
|
#else
|
|
|
|
#define ZEND_FILE_LINE_D
|
|
|
|
#define ZEND_FILE_LINE_DC
|
1999-08-28 18:18:54 +08:00
|
|
|
#define ZEND_FILE_LINE_ORIG_D
|
|
|
|
#define ZEND_FILE_LINE_ORIG_DC
|
1999-08-28 03:17:19 +08:00
|
|
|
#define ZEND_FILE_LINE_RELAY_C
|
|
|
|
#define ZEND_FILE_LINE_RELAY_CC
|
|
|
|
#define ZEND_FILE_LINE_C
|
|
|
|
#define ZEND_FILE_LINE_CC
|
1999-08-28 18:18:54 +08:00
|
|
|
#define ZEND_FILE_LINE_EMPTY_C
|
|
|
|
#define ZEND_FILE_LINE_EMPTY_CC
|
|
|
|
#define ZEND_FILE_LINE_ORIG_RELAY_C
|
|
|
|
#define ZEND_FILE_LINE_ORIG_RELAY_CC
|
2012-12-13 18:46:44 +08:00
|
|
|
#define ZEND_ASSERT(c)
|
1999-08-28 03:17:19 +08:00
|
|
|
#endif /* ZEND_DEBUG */
|
|
|
|
|
2000-06-27 02:15:33 +08:00
|
|
|
#ifdef ZTS
|
|
|
|
#define ZTS_V 1
|
|
|
|
#else
|
|
|
|
#define ZTS_V 0
|
|
|
|
#endif
|
1999-08-28 03:17:19 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
#include "zend_errors.h"
|
|
|
|
#include "zend_alloc.h"
|
|
|
|
|
2002-06-24 15:11:12 +08:00
|
|
|
#include "zend_types.h"
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2001-04-29 04:21:42 +08:00
|
|
|
#ifdef HAVE_LIMITS_H
|
|
|
|
# include <limits.h>
|
|
|
|
#endif
|
|
|
|
|
2001-04-29 04:13:25 +08:00
|
|
|
#ifndef LONG_MAX
|
|
|
|
#define LONG_MAX 2147483647L
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LONG_MIN
|
|
|
|
#define LONG_MIN (- LONG_MAX - 1)
|
|
|
|
#endif
|
|
|
|
|
2009-03-18 09:08:12 +08:00
|
|
|
#if SIZEOF_LONG == 4
|
|
|
|
#define MAX_LENGTH_OF_LONG 11
|
|
|
|
static const char long_min_digits[] = "2147483648";
|
|
|
|
#elif SIZEOF_LONG == 8
|
|
|
|
#define MAX_LENGTH_OF_LONG 20
|
|
|
|
static const char long_min_digits[] = "9223372036854775808";
|
|
|
|
#else
|
|
|
|
#error "Unknown SIZEOF_LONG"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MAX_LENGTH_OF_DOUBLE 32
|
|
|
|
|
2012-08-07 11:06:13 +08:00
|
|
|
typedef enum {
|
|
|
|
SUCCESS = 0,
|
|
|
|
FAILURE = -1, /* this MUST stay a negative number, or it may affect functions! */
|
2012-08-27 02:06:47 +08:00
|
|
|
} ZEND_RESULT_CODE;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
|
|
|
#include "zend_hash.h"
|
|
|
|
#include "zend_llist.h"
|
|
|
|
|
2014-03-28 06:11:22 +08:00
|
|
|
#define INTERNAL_FUNCTION_PARAMETERS zend_uint param_count, zval *return_value TSRMLS_DC
|
|
|
|
#define INTERNAL_FUNCTION_PARAM_PASSTHRU param_count, return_value TSRMLS_CC
|
|
|
|
|
|
|
|
#define USED_RET() \
|
|
|
|
(!EG(current_execute_data) || \
|
2014-07-03 02:01:25 +08:00
|
|
|
!EG(current_execute_data)->prev_execute_data || \
|
2014-07-07 19:50:44 +08:00
|
|
|
!ZEND_USER_CODE(EG(current_execute_data)->prev_execute_data->func->common.type) || \
|
2014-07-03 02:01:25 +08:00
|
|
|
!(EG(current_execute_data)->prev_execute_data->opline->result_type & EXT_TYPE_UNUSED))
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2009-06-17 16:55:23 +08:00
|
|
|
#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
|
2014-07-16 16:35:48 +08:00
|
|
|
# define ZEND_NORETURN __attribute__((noreturn))
|
2005-06-13 19:22:59 +08:00
|
|
|
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((noreturn));
|
|
|
|
#else
|
2014-07-16 16:35:48 +08:00
|
|
|
# define ZEND_NORETURN
|
2005-06-13 19:22:59 +08:00
|
|
|
# define zend_error_noreturn zend_error
|
|
|
|
#endif
|
|
|
|
|
2002-02-07 22:08:43 +08:00
|
|
|
#include "zend_object_handlers.h"
|
2013-10-31 15:57:12 +08:00
|
|
|
#include "zend_ast.h"
|
2001-08-16 22:04:04 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
/* overloaded elements data types */
|
|
|
|
#define OE_IS_ARRAY (1<<0)
|
|
|
|
#define OE_IS_OBJECT (1<<1)
|
|
|
|
#define OE_IS_METHOD (1<<2)
|
2007-10-07 13:22:07 +08:00
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
#define Z_REFCOUNT_P(pz) zval_refcount_p(pz)
|
2007-10-07 13:22:07 +08:00
|
|
|
#define Z_SET_REFCOUNT_P(pz, rc) zval_set_refcount_p(pz, rc)
|
2014-02-10 14:04:30 +08:00
|
|
|
#define Z_ADDREF_P(pz) zval_addref_p(pz)
|
|
|
|
#define Z_DELREF_P(pz) zval_delref_p(pz)
|
|
|
|
|
|
|
|
#define Z_REFCOUNT(z) Z_REFCOUNT_P(&(z))
|
2007-10-07 13:22:07 +08:00
|
|
|
#define Z_SET_REFCOUNT(z, rc) Z_SET_REFCOUNT_P(&(z), rc)
|
2014-02-10 14:04:30 +08:00
|
|
|
#define Z_ADDREF(z) Z_ADDREF_P(&(z))
|
|
|
|
#define Z_DELREF(z) Z_DELREF_P(&(z))
|
2007-10-07 13:22:07 +08:00
|
|
|
|
2014-06-17 17:50:54 +08:00
|
|
|
#define Z_TRY_ADDREF_P(pz) do { \
|
2014-06-18 15:11:46 +08:00
|
|
|
if (Z_REFCOUNTED_P((pz))) { \
|
2014-06-17 17:50:54 +08:00
|
|
|
Z_ADDREF_P((pz)); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define Z_TRY_DELREF_P(pz) do { \
|
2014-06-18 15:11:46 +08:00
|
|
|
if (Z_REFCOUNTED_P((pz))) { \
|
2014-06-17 17:50:54 +08:00
|
|
|
Z_DELREF_P((pz)); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define Z_TRY_ADDREF(z) Z_TRY_ADDREF_P(&(z))
|
|
|
|
#define Z_TRY_DELREF(z) Z_TRY_DELREF_P(&(z))
|
|
|
|
|
2013-03-11 15:15:22 +08:00
|
|
|
#if ZEND_DEBUG
|
|
|
|
#define zend_always_inline inline
|
|
|
|
#define zend_never_inline
|
|
|
|
#else
|
2007-10-07 13:22:07 +08:00
|
|
|
#if defined(__GNUC__)
|
2009-06-06 06:14:21 +08:00
|
|
|
#if __GNUC__ >= 3
|
2007-11-20 18:19:11 +08:00
|
|
|
#define zend_always_inline inline __attribute__((always_inline))
|
2010-04-20 19:16:39 +08:00
|
|
|
#define zend_never_inline __attribute__((noinline))
|
2009-06-06 06:14:21 +08:00
|
|
|
#else
|
|
|
|
#define zend_always_inline inline
|
2010-04-20 19:16:39 +08:00
|
|
|
#define zend_never_inline
|
2009-06-06 06:14:21 +08:00
|
|
|
#endif
|
2007-10-07 13:22:07 +08:00
|
|
|
#elif defined(_MSC_VER)
|
2007-11-20 18:19:11 +08:00
|
|
|
#define zend_always_inline __forceinline
|
2010-04-20 19:16:39 +08:00
|
|
|
#define zend_never_inline
|
2007-10-07 13:22:07 +08:00
|
|
|
#else
|
2007-11-20 18:19:11 +08:00
|
|
|
#define zend_always_inline inline
|
2010-04-20 19:16:39 +08:00
|
|
|
#define zend_never_inline
|
2007-10-07 13:22:07 +08:00
|
|
|
#endif
|
2013-03-11 15:15:22 +08:00
|
|
|
#endif /* ZEND_DEBUG */
|
2007-10-07 13:22:07 +08:00
|
|
|
|
2010-04-20 19:16:39 +08:00
|
|
|
#if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX)
|
2014-07-09 23:32:09 +08:00
|
|
|
# define EXPECTED(condition) __builtin_expect(!(!(condition)), 1)
|
|
|
|
# define UNEXPECTED(condition) __builtin_expect(!(!(condition)), 0)
|
2007-11-21 22:55:41 +08:00
|
|
|
#else
|
|
|
|
# define EXPECTED(condition) (condition)
|
|
|
|
# define UNEXPECTED(condition) (condition)
|
|
|
|
#endif
|
|
|
|
|
2014-04-24 01:05:16 +08:00
|
|
|
#ifndef XtOffsetOf
|
|
|
|
# if defined(CRAY) || (defined(__ARMCC_VERSION) && !defined(LINUX))
|
|
|
|
# ifdef __STDC__
|
|
|
|
# define XtOffset(p_type, field) _Offsetof(p_type, field)
|
|
|
|
# else
|
|
|
|
# ifdef CRAY2
|
|
|
|
# define XtOffset(p_type, field) \
|
|
|
|
(sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
|
|
|
|
|
|
|
|
# else /* !CRAY2 */
|
|
|
|
|
|
|
|
# define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
|
|
|
|
|
|
|
|
# endif /* !CRAY2 */
|
|
|
|
# endif /* __STDC__ */
|
|
|
|
# else /* ! (CRAY || __arm) */
|
|
|
|
|
|
|
|
# define XtOffset(p_type, field) \
|
|
|
|
((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
|
|
|
|
|
|
|
|
# endif /* !CRAY */
|
|
|
|
|
|
|
|
# ifdef offsetof
|
|
|
|
# define XtOffsetOf(s_type, field) offsetof(s_type, field)
|
|
|
|
# else
|
|
|
|
# define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
#include "zend_string.h"
|
|
|
|
|
2007-11-20 18:19:11 +08:00
|
|
|
static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
|
2014-06-11 06:46:50 +08:00
|
|
|
ZEND_ASSERT(Z_REFCOUNTED_P(pz) || Z_IMMUTABLE_P(pz));
|
2014-04-02 18:34:44 +08:00
|
|
|
return GC_REFCOUNT(Z_COUNTED_P(pz));
|
2007-10-07 13:22:07 +08:00
|
|
|
}
|
|
|
|
|
2007-11-20 18:19:11 +08:00
|
|
|
static zend_always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) {
|
2014-02-10 14:04:30 +08:00
|
|
|
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
|
2014-04-02 18:34:44 +08:00
|
|
|
return GC_REFCOUNT(Z_COUNTED_P(pz)) = rc;
|
2007-10-07 13:22:07 +08:00
|
|
|
}
|
|
|
|
|
2007-11-20 18:19:11 +08:00
|
|
|
static zend_always_inline zend_uint zval_addref_p(zval* pz) {
|
2014-02-10 14:04:30 +08:00
|
|
|
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
|
2014-04-02 18:34:44 +08:00
|
|
|
return ++GC_REFCOUNT(Z_COUNTED_P(pz));
|
2007-10-07 13:22:07 +08:00
|
|
|
}
|
|
|
|
|
2007-11-20 18:19:11 +08:00
|
|
|
static zend_always_inline zend_uint zval_delref_p(zval* pz) {
|
2014-02-10 14:04:30 +08:00
|
|
|
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
|
2014-04-02 18:34:44 +08:00
|
|
|
return --GC_REFCOUNT(Z_COUNTED_P(pz));
|
2007-10-07 13:22:07 +08:00
|
|
|
}
|
1999-04-08 02:10:10 +08:00
|
|
|
|
1999-10-05 23:13:22 +08:00
|
|
|
/* excpt.h on Digital Unix 4.0 defines function_table */
|
|
|
|
#undef function_table
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2001-11-03 19:59:14 +08:00
|
|
|
/* A lot of stuff needs shifiting around in order to include zend_compile.h here */
|
|
|
|
union _zend_function;
|
|
|
|
|
2003-10-18 01:19:44 +08:00
|
|
|
#include "zend_iterators.h"
|
|
|
|
|
2005-02-23 19:15:51 +08:00
|
|
|
struct _zend_serialize_data;
|
|
|
|
struct _zend_unserialize_data;
|
|
|
|
|
|
|
|
typedef struct _zend_serialize_data zend_serialize_data;
|
|
|
|
typedef struct _zend_unserialize_data zend_unserialize_data;
|
|
|
|
|
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
|
|
|
struct _zend_trait_method_reference {
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_string *method_name;
|
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
|
|
|
zend_class_entry *ce;
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_string *class_name;
|
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
|
|
|
};
|
|
|
|
typedef struct _zend_trait_method_reference zend_trait_method_reference;
|
|
|
|
|
|
|
|
struct _zend_trait_precedence {
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_trait_method_reference *trait_method;
|
|
|
|
union {
|
|
|
|
zend_class_entry *ce;
|
|
|
|
zend_string *class_name;
|
|
|
|
} *exclude_from_classes;
|
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
|
|
|
};
|
|
|
|
typedef struct _zend_trait_precedence zend_trait_precedence;
|
|
|
|
|
|
|
|
struct _zend_trait_alias {
|
|
|
|
zend_trait_method_reference *trait_method;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* name for method to be added
|
|
|
|
*/
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_string *alias;
|
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* modifiers to be set on trait method
|
|
|
|
*/
|
|
|
|
zend_uint modifiers;
|
|
|
|
};
|
|
|
|
typedef struct _zend_trait_alias zend_trait_alias;
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
struct _zend_class_entry {
|
|
|
|
char type;
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_string *name;
|
2006-05-10 07:53:23 +08:00
|
|
|
struct _zend_class_entry *parent;
|
2002-03-13 03:22:29 +08:00
|
|
|
int refcount;
|
2002-12-07 01:09:44 +08:00
|
|
|
zend_uint ce_flags;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
|
|
|
HashTable function_table;
|
2003-02-05 21:35:52 +08:00
|
|
|
HashTable properties_info;
|
2014-02-10 14:04:30 +08:00
|
|
|
zval *default_properties_table;
|
|
|
|
zval *default_static_members_table;
|
|
|
|
zval *static_members_table;
|
2001-12-12 02:46:43 +08:00
|
|
|
HashTable constants_table;
|
2010-05-24 22:11:39 +08:00
|
|
|
int default_properties_count;
|
|
|
|
int default_static_members_count;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2001-11-03 19:59:14 +08:00
|
|
|
union _zend_function *constructor;
|
2001-12-27 22:35:09 +08:00
|
|
|
union _zend_function *destructor;
|
2001-12-27 03:54:20 +08:00
|
|
|
union _zend_function *clone;
|
2002-09-04 17:07:58 +08:00
|
|
|
union _zend_function *__get;
|
|
|
|
union _zend_function *__set;
|
2005-07-08 00:07:09 +08:00
|
|
|
union _zend_function *__unset;
|
|
|
|
union _zend_function *__isset;
|
2002-09-04 17:07:58 +08:00
|
|
|
union _zend_function *__call;
|
2007-09-29 16:52:40 +08:00
|
|
|
union _zend_function *__callstatic;
|
2006-05-10 07:53:23 +08:00
|
|
|
union _zend_function *__tostring;
|
2014-02-18 11:13:00 +08:00
|
|
|
union _zend_function *__debugInfo;
|
2005-03-08 06:23:14 +08:00
|
|
|
union _zend_function *serialize_func;
|
|
|
|
union _zend_function *unserialize_func;
|
2001-11-03 19:59:14 +08:00
|
|
|
|
2003-10-19 02:43:31 +08:00
|
|
|
zend_class_iterator_funcs iterator_funcs;
|
2003-10-18 01:19:44 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
/* handlers */
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_object* (*create_object)(zend_class_entry *class_type TSRMLS_DC);
|
2006-05-10 07:53:23 +08:00
|
|
|
zend_object_iterator *(*get_iterator)(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
|
2003-10-23 03:59:58 +08:00
|
|
|
int (*interface_gets_implemented)(zend_class_entry *iface, zend_class_entry *class_type TSRMLS_DC); /* a class implements this interface */
|
2014-02-10 14:04:30 +08:00
|
|
|
union _zend_function *(*get_static_method)(zend_class_entry *ce, zend_string* method TSRMLS_DC);
|
2002-09-04 17:07:58 +08:00
|
|
|
|
2005-02-23 19:15:51 +08:00
|
|
|
/* serializer callbacks */
|
|
|
|
int (*serialize)(zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC);
|
2014-02-10 14:04:30 +08:00
|
|
|
int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC);
|
2005-02-23 19:15:51 +08:00
|
|
|
|
2003-03-05 19:14:44 +08:00
|
|
|
zend_class_entry **interfaces;
|
|
|
|
zend_uint num_interfaces;
|
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
|
|
|
|
|
|
|
zend_class_entry **traits;
|
|
|
|
zend_uint num_traits;
|
|
|
|
zend_trait_alias **trait_aliases;
|
|
|
|
zend_trait_precedence **trait_precedences;
|
2003-03-05 19:14:44 +08:00
|
|
|
|
2010-09-15 15:38:52 +08:00
|
|
|
union {
|
|
|
|
struct {
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_string *filename;
|
2010-09-15 15:38:52 +08:00
|
|
|
zend_uint line_start;
|
|
|
|
zend_uint line_end;
|
2014-02-10 14:04:30 +08:00
|
|
|
zend_string *doc_comment;
|
2010-09-15 15:38:52 +08:00
|
|
|
} user;
|
|
|
|
struct {
|
|
|
|
const struct _zend_function_entry *builtin_functions;
|
|
|
|
struct _zend_module_entry *module;
|
|
|
|
} internal;
|
|
|
|
} info;
|
1999-04-08 02:10:10 +08:00
|
|
|
};
|
|
|
|
|
2003-02-18 17:37:54 +08:00
|
|
|
#include "zend_stream.h"
|
1999-05-23 00:10:51 +08:00
|
|
|
typedef struct _zend_utility_functions {
|
2003-08-29 01:31:31 +08:00
|
|
|
void (*error_function)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
|
|
|
|
int (*printf_function)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
|
1999-04-08 02:10:10 +08:00
|
|
|
int (*write_function)(const char *str, uint str_length);
|
2008-08-16 03:47:33 +08:00
|
|
|
FILE *(*fopen_function)(const char *filename, char **opened_path TSRMLS_DC);
|
2011-09-13 21:29:35 +08:00
|
|
|
void (*message_handler)(long message, const void *data TSRMLS_DC);
|
1999-12-02 06:55:20 +08:00
|
|
|
void (*block_interruptions)(void);
|
|
|
|
void (*unblock_interruptions)(void);
|
2008-08-13 01:20:25 +08:00
|
|
|
int (*get_configuration_directive)(const char *name, uint name_length, zval *contents);
|
2013-12-18 16:32:26 +08:00
|
|
|
void (*ticks_function)(int ticks TSRMLS_DC);
|
2002-09-19 23:58:01 +08:00
|
|
|
void (*on_timeout)(int seconds TSRMLS_DC);
|
2003-02-18 17:37:54 +08:00
|
|
|
int (*stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
|
2003-08-31 17:35:54 +08:00
|
|
|
int (*vspprintf_function)(char **pbuf, size_t max_len, const char *format, va_list ap);
|
2014-05-10 00:21:49 +08:00
|
|
|
zend_string *(*vstrpprintf_function)(size_t max_len, const char *format, va_list ap);
|
2004-09-06 06:40:35 +08:00
|
|
|
char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
|
2008-03-05 21:34:12 +08:00
|
|
|
char *(*resolve_path_function)(const char *filename, int filename_len TSRMLS_DC);
|
1999-04-08 02:10:10 +08:00
|
|
|
} zend_utility_functions;
|
|
|
|
|
1999-05-23 00:10:51 +08:00
|
|
|
typedef struct _zend_utility_values {
|
1999-12-04 21:26:57 +08:00
|
|
|
char *import_use_extension;
|
|
|
|
uint import_use_extension_length;
|
2002-09-03 17:41:41 +08:00
|
|
|
zend_bool html_errors;
|
1999-04-08 02:10:10 +08:00
|
|
|
} zend_utility_values;
|
|
|
|
|
2000-03-26 03:10:07 +08:00
|
|
|
typedef int (*zend_write_func_t)(const char *str, uint str_length);
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
#undef MIN
|
|
|
|
#undef MAX
|
2001-08-11 23:56:40 +08:00
|
|
|
#define MAX(a, b) (((a)>(b))?(a):(b))
|
|
|
|
#define MIN(a, b) (((a)<(b))?(a):(b))
|
1999-12-31 21:56:59 +08:00
|
|
|
#define ZEND_STRL(str) (str), (sizeof(str)-1)
|
2005-01-20 10:02:09 +08:00
|
|
|
#define ZEND_STRS(str) (str), (sizeof(str))
|
2000-06-03 11:05:01 +08:00
|
|
|
#define ZEND_NORMALIZE_BOOL(n) \
|
|
|
|
((n) ? (((n)>0) ? 1 : -1) : 0)
|
2003-08-04 15:52:36 +08:00
|
|
|
#define ZEND_TRUTH(x) ((x) ? 1 : 0)
|
|
|
|
#define ZEND_LOG_XOR(a, b) (ZEND_TRUTH(a) ^ ZEND_TRUTH(b))
|
|
|
|
|
2008-12-31 22:05:22 +08:00
|
|
|
int zend_startup(zend_utility_functions *utility_functions, char **extensions TSRMLS_DC);
|
2001-07-31 12:53:54 +08:00
|
|
|
void zend_shutdown(TSRMLS_D);
|
2002-11-20 01:51:30 +08:00
|
|
|
void zend_register_standard_ini_entries(TSRMLS_D);
|
2002-09-17 20:42:11 +08:00
|
|
|
void zend_post_startup(TSRMLS_D);
|
1999-04-10 19:21:55 +08:00
|
|
|
void zend_set_utility_values(zend_utility_values *utility_values);
|
2001-07-21 22:25:27 +08:00
|
|
|
|
1999-05-15 23:47:24 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2001-07-22 00:21:22 +08:00
|
|
|
ZEND_API void _zend_bailout(char *filename, uint lineno);
|
1999-05-15 23:47:24 +08:00
|
|
|
END_EXTERN_C()
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2001-07-22 00:21:22 +08:00
|
|
|
#define zend_bailout() _zend_bailout(__FILE__, __LINE__)
|
2001-07-21 22:25:27 +08:00
|
|
|
|
2008-03-19 05:14:28 +08:00
|
|
|
#ifdef HAVE_SIGSETJMP
|
|
|
|
# define SETJMP(a) sigsetjmp(a, 0)
|
|
|
|
# define LONGJMP(a,b) siglongjmp(a, b)
|
|
|
|
# define JMP_BUF sigjmp_buf
|
|
|
|
#else
|
|
|
|
# define SETJMP(a) setjmp(a)
|
|
|
|
# define LONGJMP(a,b) longjmp(a, b)
|
|
|
|
# define JMP_BUF jmp_buf
|
|
|
|
#endif
|
|
|
|
|
2001-07-21 22:25:27 +08:00
|
|
|
#define zend_try \
|
|
|
|
{ \
|
2008-03-19 05:14:28 +08:00
|
|
|
JMP_BUF *__orig_bailout = EG(bailout); \
|
|
|
|
JMP_BUF __bailout; \
|
2001-07-21 22:25:27 +08:00
|
|
|
\
|
2006-09-14 18:32:45 +08:00
|
|
|
EG(bailout) = &__bailout; \
|
2008-03-19 05:14:28 +08:00
|
|
|
if (SETJMP(__bailout)==0) {
|
2001-07-21 22:25:27 +08:00
|
|
|
#define zend_catch \
|
2006-05-19 14:09:15 +08:00
|
|
|
} else { \
|
2006-09-14 18:32:45 +08:00
|
|
|
EG(bailout) = __orig_bailout;
|
2001-07-21 22:25:27 +08:00
|
|
|
#define zend_end_try() \
|
2006-05-19 14:09:15 +08:00
|
|
|
} \
|
2006-09-14 18:32:45 +08:00
|
|
|
EG(bailout) = __orig_bailout; \
|
2001-07-21 22:25:27 +08:00
|
|
|
}
|
2007-11-03 03:40:39 +08:00
|
|
|
#define zend_first_try EG(bailout)=NULL; zend_try
|
2001-07-21 22:25:27 +08:00
|
|
|
|
2004-02-19 06:44:40 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2001-07-21 22:25:27 +08:00
|
|
|
ZEND_API char *get_zend_version(void);
|
2014-07-09 20:05:55 +08:00
|
|
|
ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
|
2014-04-21 23:12:10 +08:00
|
|
|
ZEND_API int zend_print_zval(zval *expr, int indent TSRMLS_DC);
|
|
|
|
ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
|
2003-01-12 22:25:58 +08:00
|
|
|
ZEND_API void zend_print_zval_r(zval *expr, int indent TSRMLS_DC);
|
|
|
|
ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC);
|
|
|
|
ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int indent TSRMLS_DC);
|
2008-08-13 01:20:25 +08:00
|
|
|
ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
|
2004-02-19 06:44:40 +08:00
|
|
|
END_EXTERN_C()
|
2001-07-21 22:25:27 +08:00
|
|
|
|
2013-11-18 06:39:31 +08:00
|
|
|
BEGIN_EXTERN_C()
|
|
|
|
ZEND_API void zend_activate(TSRMLS_D);
|
|
|
|
ZEND_API void zend_deactivate(TSRMLS_D);
|
|
|
|
ZEND_API void zend_call_destructors(TSRMLS_D);
|
|
|
|
ZEND_API void zend_activate_modules(TSRMLS_D);
|
|
|
|
ZEND_API void zend_deactivate_modules(TSRMLS_D);
|
|
|
|
ZEND_API void zend_post_deactivate_modules(TSRMLS_D);
|
|
|
|
END_EXTERN_C()
|
2003-07-31 00:13:52 +08:00
|
|
|
|
2000-06-03 09:49:49 +08:00
|
|
|
#if ZEND_DEBUG
|
|
|
|
#define Z_DBG(expr) (expr)
|
|
|
|
#else
|
|
|
|
#define Z_DBG(expr)
|
|
|
|
#endif
|
|
|
|
|
2004-02-20 16:03:27 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2001-01-15 18:52:06 +08:00
|
|
|
ZEND_API void free_estring(char **str_p);
|
2014-02-17 21:59:18 +08:00
|
|
|
ZEND_API void free_string_zval(zval *zv);
|
2004-02-20 16:03:27 +08:00
|
|
|
END_EXTERN_C()
|
2003-02-11 00:11:24 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
/* output support */
|
|
|
|
#define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
|
2009-02-18 18:55:08 +08:00
|
|
|
#define ZEND_WRITE_EX(str, str_len) write_func((str), (str_len))
|
1999-04-08 02:10:10 +08:00
|
|
|
#define ZEND_PUTS(str) zend_write((str), strlen((str)))
|
2009-02-18 18:55:08 +08:00
|
|
|
#define ZEND_PUTS_EX(str) write_func((str), strlen((str)))
|
2013-11-30 06:54:17 +08:00
|
|
|
#define ZEND_PUTC(c) zend_write(&(c), 1)
|
1999-04-08 02:10:10 +08:00
|
|
|
|
1999-04-23 11:32:33 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2003-08-29 01:31:31 +08:00
|
|
|
extern ZEND_API int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
|
2000-03-26 03:10:07 +08:00
|
|
|
extern ZEND_API zend_write_func_t zend_write;
|
2008-08-16 03:47:33 +08:00
|
|
|
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
|
1999-12-02 06:55:20 +08:00
|
|
|
extern ZEND_API void (*zend_block_interruptions)(void);
|
|
|
|
extern ZEND_API void (*zend_unblock_interruptions)(void);
|
2013-12-18 16:32:26 +08:00
|
|
|
extern ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC);
|
2003-08-29 01:31:31 +08:00
|
|
|
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
|
2011-11-22 11:39:12 +08:00
|
|
|
extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
|
2003-02-18 17:37:54 +08:00
|
|
|
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
|
2003-08-31 17:35:54 +08:00
|
|
|
extern int (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
|
2014-05-10 00:21:49 +08:00
|
|
|
extern zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
|
2004-09-06 06:40:35 +08:00
|
|
|
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
|
2008-03-05 21:34:12 +08:00
|
|
|
extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
|
2000-04-19 23:08:06 +08:00
|
|
|
|
2003-08-29 00:41:20 +08:00
|
|
|
ZEND_API void zend_error(int type, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
|
2000-04-19 23:08:06 +08:00
|
|
|
|
2008-08-13 01:20:25 +08:00
|
|
|
void zenderror(const char *error);
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2002-03-13 03:41:02 +08:00
|
|
|
/* The following #define is used for code duality in PHP for Engine 1 & 2 */
|
2002-03-13 03:36:24 +08:00
|
|
|
#define ZEND_STANDARD_CLASS_DEF_PTR zend_standard_class_def
|
2002-03-12 18:08:47 +08:00
|
|
|
extern ZEND_API zend_class_entry *zend_standard_class_def;
|
2002-09-03 18:25:06 +08:00
|
|
|
extern ZEND_API zend_utility_values zend_uv;
|
1999-12-23 04:24:52 +08:00
|
|
|
extern ZEND_API zval zval_used_for_init;
|
1999-12-19 14:39:17 +08:00
|
|
|
|
1999-12-04 21:26:57 +08:00
|
|
|
END_EXTERN_C()
|
1999-04-08 02:10:10 +08:00
|
|
|
|
|
|
|
#define ZEND_UV(name) (zend_uv.name)
|
|
|
|
|
2011-06-03 05:16:50 +08:00
|
|
|
#ifndef ZEND_SIGNALS
|
1999-04-08 02:10:10 +08:00
|
|
|
#define HANDLE_BLOCK_INTERRUPTIONS() if (zend_block_interruptions) { zend_block_interruptions(); }
|
|
|
|
#define HANDLE_UNBLOCK_INTERRUPTIONS() if (zend_unblock_interruptions) { zend_unblock_interruptions(); }
|
2011-06-03 05:16:50 +08:00
|
|
|
#else
|
|
|
|
#include "zend_signal.h"
|
|
|
|
|
2012-01-04 16:25:06 +08:00
|
|
|
#define HANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPUTIONS()
|
|
|
|
#define HANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
|
2011-06-03 05:16:50 +08:00
|
|
|
#endif
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2000-03-06 18:46:40 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2011-09-13 21:29:35 +08:00
|
|
|
ZEND_API void zend_message_dispatcher(long message, const void *data TSRMLS_DC);
|
2000-03-06 18:46:40 +08:00
|
|
|
|
2008-08-13 01:20:25 +08:00
|
|
|
ZEND_API int zend_get_configuration_directive(const char *name, uint name_length, zval *contents);
|
2004-02-20 16:03:27 +08:00
|
|
|
END_EXTERN_C()
|
2000-03-06 03:50:10 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
/* Messages for applications of Zend */
|
2000-06-13 00:07:15 +08:00
|
|
|
#define ZMSG_FAILED_INCLUDE_FOPEN 1L
|
|
|
|
#define ZMSG_FAILED_REQUIRE_FOPEN 2L
|
|
|
|
#define ZMSG_FAILED_HIGHLIGHT_FOPEN 3L
|
|
|
|
#define ZMSG_MEMORY_LEAK_DETECTED 4L
|
|
|
|
#define ZMSG_MEMORY_LEAK_REPEATED 5L
|
|
|
|
#define ZMSG_LOG_SCRIPT_NAME 6L
|
2003-08-19 06:31:11 +08:00
|
|
|
#define ZMSG_MEMORY_LEAKS_GRAND_TOTAL 7L
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2014-03-03 17:09:56 +08:00
|
|
|
#define ZVAL_COPY_VALUE(z, v) \
|
|
|
|
do { \
|
|
|
|
zval *_z1 = (z); \
|
|
|
|
zval *_z2 = (v); \
|
|
|
|
(_z1)->value = (_z2)->value; \
|
2014-04-03 19:26:23 +08:00
|
|
|
Z_TYPE_INFO_P(_z1) = Z_TYPE_INFO_P(_z2); \
|
2010-04-20 19:16:39 +08:00
|
|
|
} while (0)
|
|
|
|
|
2014-03-03 17:09:56 +08:00
|
|
|
#define ZVAL_COPY(z, v) \
|
|
|
|
do { \
|
|
|
|
zval *__z1 = (z); \
|
|
|
|
zval *__z2 = (v); \
|
|
|
|
ZVAL_COPY_VALUE(__z1, __z2); \
|
2014-04-04 06:52:53 +08:00
|
|
|
if (Z_OPT_REFCOUNTED_P(__z1)) { \
|
2014-03-03 17:09:56 +08:00
|
|
|
Z_ADDREF_P(__z1); \
|
|
|
|
} \
|
2014-02-10 14:04:30 +08:00
|
|
|
} while (0)
|
|
|
|
|
2014-03-03 17:09:56 +08:00
|
|
|
#define ZVAL_DUP(z, v) \
|
|
|
|
do { \
|
|
|
|
zval *__z1 = (z); \
|
|
|
|
zval *__z2 = (v); \
|
|
|
|
ZVAL_COPY_VALUE(__z1, __z2); \
|
2014-04-04 06:52:53 +08:00
|
|
|
zval_opt_copy_ctor(__z1); \
|
2014-02-10 14:04:30 +08:00
|
|
|
} while (0)
|
|
|
|
|
2014-03-27 17:39:09 +08:00
|
|
|
#define ZVAL_DEREF(z) do { \
|
|
|
|
if (UNEXPECTED(Z_ISREF_P(z))) { \
|
|
|
|
(z) = Z_REFVAL_P(z); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2014-06-05 20:04:11 +08:00
|
|
|
#define ZVAL_MAKE_REF(zv) do { \
|
|
|
|
zval *__zv = (zv); \
|
|
|
|
if (!Z_ISREF_P(__zv)) { \
|
|
|
|
ZVAL_NEW_REF(__zv, __zv); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2014-03-19 21:00:28 +08:00
|
|
|
#define ZVAL_UNREF(z) do { \
|
|
|
|
zval *_z = (z); \
|
|
|
|
zend_reference *ref; \
|
|
|
|
ZEND_ASSERT(Z_ISREF_P(_z)); \
|
|
|
|
ref = Z_REF_P(_z); \
|
|
|
|
ZVAL_COPY_VALUE(_z, &ref->val); \
|
2014-07-16 16:35:48 +08:00
|
|
|
efree_size(ref, sizeof(zend_reference)); \
|
2014-03-19 21:00:28 +08:00
|
|
|
} while (0)
|
|
|
|
|
2014-06-05 20:04:11 +08:00
|
|
|
#define SEPARATE_STRING(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
|
|
|
if (Z_REFCOUNTED_P(_zv) && \
|
|
|
|
Z_REFCOUNT_P(_zv) > 1) { \
|
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
zval_copy_ctor_func(_zv); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SEPARATE_ARRAY(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
2014-06-11 06:46:50 +08:00
|
|
|
if (Z_REFCOUNT_P(_zv) > 1) { \
|
|
|
|
if (!Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
} \
|
2014-06-05 20:04:11 +08:00
|
|
|
zval_copy_ctor_func(_zv); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SEPARATE_ZVAL_NOREF(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
|
|
|
if (Z_COPYABLE_P(_zv) || \
|
|
|
|
Z_IMMUTABLE_P(_zv)) { \
|
2014-06-11 06:46:50 +08:00
|
|
|
if (Z_REFCOUNT_P(_zv) > 1) { \
|
|
|
|
if (!Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
} \
|
2014-06-05 20:04:11 +08:00
|
|
|
zval_copy_ctor_func(_zv); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2014-04-04 06:52:53 +08:00
|
|
|
#define SEPARATE_ZVAL(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
2014-05-30 18:40:19 +08:00
|
|
|
if (Z_REFCOUNTED_P(_zv) || \
|
|
|
|
Z_IMMUTABLE_P(_zv)) { \
|
2014-06-11 06:46:50 +08:00
|
|
|
if (Z_REFCOUNT_P(_zv) > 1) { \
|
|
|
|
if (Z_COPYABLE_P(_zv) || \
|
|
|
|
Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
if (!Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
} \
|
|
|
|
zval_copy_ctor_func(_zv); \
|
|
|
|
} else if (Z_ISREF_P(_zv)) { \
|
2014-04-04 06:52:53 +08:00
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
ZVAL_DUP(_zv, Z_REFVAL_P(_zv)); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
2010-04-20 19:16:39 +08:00
|
|
|
} while (0)
|
1999-07-24 00:02:51 +08:00
|
|
|
|
2014-04-04 06:52:53 +08:00
|
|
|
#define SEPARATE_ZVAL_IF_NOT_REF(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
2014-06-11 06:46:50 +08:00
|
|
|
if (Z_COPYABLE_P(_zv) || \
|
|
|
|
Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
if (Z_REFCOUNT_P(_zv) > 1) { \
|
|
|
|
if (!Z_IMMUTABLE_P(_zv)) { \
|
2014-05-30 18:40:19 +08:00
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
} \
|
2014-06-11 06:46:50 +08:00
|
|
|
zval_copy_ctor_func(_zv); \
|
2014-05-29 22:21:56 +08:00
|
|
|
} \
|
|
|
|
} \
|
2014-03-03 17:09:56 +08:00
|
|
|
} while (0)
|
2000-02-17 00:00:02 +08:00
|
|
|
|
2014-03-03 17:09:56 +08:00
|
|
|
#define SEPARATE_ARG_IF_REF(varptr) do { \
|
2014-06-05 20:04:11 +08:00
|
|
|
ZVAL_DEREF(varptr); \
|
|
|
|
if (Z_REFCOUNTED_P(varptr)) { \
|
|
|
|
Z_ADDREF_P(varptr); \
|
2014-03-03 17:09:56 +08:00
|
|
|
} \
|
|
|
|
} while (0)
|
2005-02-02 15:19:22 +08:00
|
|
|
|
2006-08-07 23:15:22 +08:00
|
|
|
#define READY_TO_DESTROY(zv) \
|
2014-03-04 21:23:23 +08:00
|
|
|
(Z_REFCOUNTED_P(zv) && Z_REFCOUNT_P(zv) == 1)
|
2006-08-07 23:15:22 +08:00
|
|
|
|
2001-02-14 21:17:49 +08:00
|
|
|
#define ZEND_MAX_RESERVED_RESOURCES 4
|
1999-08-16 03:29:39 +08:00
|
|
|
|
2008-01-22 17:27:48 +08:00
|
|
|
#include "zend_gc.h"
|
2007-07-24 00:17:10 +08:00
|
|
|
#include "zend_operators.h"
|
2004-09-27 06:19:57 +08:00
|
|
|
#include "zend_variables.h"
|
2000-01-29 05:43:46 +08:00
|
|
|
|
2008-03-09 05:54:03 +08:00
|
|
|
typedef enum {
|
|
|
|
EH_NORMAL = 0,
|
|
|
|
EH_SUPPRESS,
|
|
|
|
EH_THROW
|
|
|
|
} zend_error_handling_t;
|
|
|
|
|
2008-08-09 01:47:31 +08:00
|
|
|
typedef struct {
|
|
|
|
zend_error_handling_t handling;
|
|
|
|
zend_class_entry *exception;
|
2014-02-10 14:04:30 +08:00
|
|
|
zval user_handler;
|
2008-08-09 01:47:31 +08:00
|
|
|
} zend_error_handling;
|
|
|
|
|
|
|
|
ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC);
|
|
|
|
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC);
|
2008-08-12 01:19:20 +08:00
|
|
|
ZEND_API void zend_restore_error_handling(zend_error_handling *saved TSRMLS_DC);
|
2008-08-09 01:47:31 +08:00
|
|
|
|
2011-01-17 04:39:22 +08:00
|
|
|
#define DEBUG_BACKTRACE_PROVIDE_OBJECT (1<<0)
|
|
|
|
#define DEBUG_BACKTRACE_IGNORE_ARGS (1<<1)
|
|
|
|
|
2000-07-03 07:54:19 +08:00
|
|
|
#endif /* ZEND_H */
|
1999-09-07 00:14:08 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
2003-02-01 09:49:15 +08:00
|
|
|
* indent-tabs-mode: t
|
1999-09-07 00:14:08 +08:00
|
|
|
* End:
|
|
|
|
*/
|