1999-04-08 02:10:10 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2006-01-05 07:53:05 +08:00
|
|
|
| Copyright (c) 1998-2006 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
|
|
|
|
2000-07-03 08:55:36 +08:00
|
|
|
#ifndef ZEND_EXECUTE_H
|
|
|
|
#define ZEND_EXECUTE_H
|
1999-04-08 02:10:10 +08:00
|
|
|
|
|
|
|
#include "zend_compile.h"
|
|
|
|
#include "zend_hash.h"
|
2001-07-29 16:24:38 +08:00
|
|
|
#include "zend_operators.h"
|
2006-05-10 07:53:23 +08:00
|
|
|
#include "zend_variables.h"
|
1999-04-08 02:10:10 +08:00
|
|
|
|
1999-05-23 00:10:51 +08:00
|
|
|
typedef union _temp_variable {
|
1999-04-08 02:10:10 +08:00
|
|
|
zval tmp_var;
|
1999-09-26 13:45:18 +08:00
|
|
|
struct {
|
|
|
|
zval **ptr_ptr;
|
1999-09-29 00:03:09 +08:00
|
|
|
zval *ptr;
|
2003-12-15 00:09:07 +08:00
|
|
|
zend_bool fcall_returned_reference;
|
1999-09-26 13:45:18 +08:00
|
|
|
} var;
|
2004-01-19 20:22:02 +08:00
|
|
|
struct {
|
2004-09-22 06:09:22 +08:00
|
|
|
zval **ptr_ptr;
|
|
|
|
zval *ptr;
|
|
|
|
zend_bool fcall_returned_reference;
|
2004-01-19 20:22:02 +08:00
|
|
|
zval *str;
|
|
|
|
zend_uint offset;
|
|
|
|
} str_offset;
|
2003-12-14 20:32:02 +08:00
|
|
|
zend_class_entry *class_entry;
|
1999-04-08 02:10:10 +08:00
|
|
|
} temp_variable;
|
|
|
|
|
|
|
|
|
2002-05-20 15:17:30 +08:00
|
|
|
BEGIN_EXTERN_C()
|
2001-07-27 18:10:39 +08:00
|
|
|
ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC);
|
2003-01-12 00:12:44 +08:00
|
|
|
ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2001-07-28 18:51:54 +08:00
|
|
|
void init_executor(TSRMLS_D);
|
2001-07-27 18:10:39 +08:00
|
|
|
void shutdown_executor(TSRMLS_D);
|
2004-07-25 15:14:49 +08:00
|
|
|
void shutdown_destructors(TSRMLS_D);
|
2001-07-27 18:10:39 +08:00
|
|
|
ZEND_API void execute(zend_op_array *op_array TSRMLS_DC);
|
2003-01-12 00:12:44 +08:00
|
|
|
ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
|
1999-04-08 02:10:10 +08:00
|
|
|
ZEND_API int zend_is_true(zval *op);
|
2004-01-19 07:47:10 +08:00
|
|
|
#define safe_free_zval_ptr(p) safe_free_zval_ptr_rel(p ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
|
|
|
static inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
2000-06-14 01:58:33 +08:00
|
|
|
{
|
2001-07-27 18:10:39 +08:00
|
|
|
TSRMLS_FETCH();
|
2000-06-14 01:58:33 +08:00
|
|
|
|
|
|
|
if (p!=EG(uninitialized_zval_ptr)) {
|
2004-01-19 07:47:10 +08:00
|
|
|
FREE_ZVAL_REL(p);
|
2000-06-14 01:58:33 +08:00
|
|
|
}
|
|
|
|
}
|
2002-06-17 02:25:05 +08:00
|
|
|
ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
|
2005-09-09 14:48:49 +08:00
|
|
|
ZEND_API int zend_lookup_class_ex(char *name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC);
|
2001-07-28 18:51:54 +08:00
|
|
|
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
|
2003-08-24 21:10:03 +08:00
|
|
|
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
|
2002-02-07 22:08:43 +08:00
|
|
|
|
2000-09-26 19:10:11 +08:00
|
|
|
static inline int i_zend_is_true(zval *op)
|
2000-06-14 01:58:33 +08:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
2006-05-10 07:53:23 +08:00
|
|
|
switch (Z_TYPE_P(op)) {
|
2000-06-14 01:58:33 +08:00
|
|
|
case IS_NULL:
|
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
case IS_LONG:
|
|
|
|
case IS_BOOL:
|
|
|
|
case IS_RESOURCE:
|
2006-05-10 07:53:23 +08:00
|
|
|
result = (Z_LVAL_P(op)?1:0);
|
2000-06-14 01:58:33 +08:00
|
|
|
break;
|
|
|
|
case IS_DOUBLE:
|
2006-05-10 07:53:23 +08:00
|
|
|
result = (Z_DVAL_P(op) ? 1 : 0);
|
2000-06-14 01:58:33 +08:00
|
|
|
break;
|
|
|
|
case IS_STRING:
|
2006-05-10 07:53:23 +08:00
|
|
|
if (Z_STRLEN_P(op) == 0
|
|
|
|
|| (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) {
|
2000-06-14 01:58:33 +08:00
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IS_ARRAY:
|
2006-05-10 07:53:23 +08:00
|
|
|
result = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
|
2000-06-14 01:58:33 +08:00
|
|
|
break;
|
|
|
|
case IS_OBJECT:
|
2004-03-04 21:11:03 +08:00
|
|
|
if(IS_ZEND_STD_OBJECT(*op)) {
|
2004-03-04 21:06:02 +08:00
|
|
|
TSRMLS_FETCH();
|
2005-09-12 19:48:57 +08:00
|
|
|
|
|
|
|
if (Z_OBJ_HT_P(op)->cast_object) {
|
|
|
|
zval tmp;
|
2006-05-10 07:53:23 +08:00
|
|
|
if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_BOOL TSRMLS_CC) == SUCCESS) {
|
2005-09-12 19:48:57 +08:00
|
|
|
result = Z_LVAL(tmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (Z_OBJ_HT_P(op)->get) {
|
|
|
|
zval *tmp = Z_OBJ_HT_P(op)->get(op TSRMLS_CC);
|
|
|
|
if(Z_TYPE_P(tmp) != IS_OBJECT) {
|
|
|
|
/* for safety - avoid loop */
|
|
|
|
convert_to_boolean(tmp);
|
|
|
|
result = Z_LVAL_P(tmp);
|
|
|
|
zval_ptr_dtor(&tmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-03-04 21:06:02 +08:00
|
|
|
}
|
2006-05-10 07:53:23 +08:00
|
|
|
result = 1;
|
2000-06-14 01:58:33 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-07-31 12:53:54 +08:00
|
|
|
ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC);
|
1999-04-08 02:10:10 +08:00
|
|
|
|
1999-04-13 02:29:09 +08:00
|
|
|
/* dedicated Zend executor functions - do not use! */
|
2001-07-27 18:10:39 +08:00
|
|
|
static inline void zend_ptr_stack_clear_multiple(TSRMLS_D)
|
2000-06-14 01:58:33 +08:00
|
|
|
{
|
|
|
|
void **p = EG(argument_stack).top_element-2;
|
|
|
|
int delete_count = (ulong) *p;
|
|
|
|
|
|
|
|
EG(argument_stack).top -= (delete_count+2);
|
|
|
|
while (--delete_count>=0) {
|
2006-05-31 21:01:57 +08:00
|
|
|
zval *q = *(zval **)(--p);
|
|
|
|
*p = NULL;
|
|
|
|
zval_ptr_dtor(&q);
|
2000-06-14 01:58:33 +08:00
|
|
|
}
|
|
|
|
EG(argument_stack).top_element = p;
|
|
|
|
}
|
|
|
|
|
2001-07-27 18:10:39 +08:00
|
|
|
static inline int zend_ptr_stack_get_arg(int requested_arg, void **data TSRMLS_DC)
|
2000-06-14 01:58:33 +08:00
|
|
|
{
|
|
|
|
void **p = EG(argument_stack).top_element-2;
|
|
|
|
int arg_count = (ulong) *p;
|
|
|
|
|
|
|
|
if (requested_arg>arg_count) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
*data = (p-arg_count+requested_arg-1);
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
1999-04-13 02:29:09 +08:00
|
|
|
|
2001-07-28 18:51:54 +08:00
|
|
|
void execute_new_code(TSRMLS_D);
|
1999-04-08 02:10:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* services */
|
2004-03-16 18:14:57 +08:00
|
|
|
ZEND_API char *get_active_class_name(char **space TSRMLS_DC);
|
2001-07-30 15:43:02 +08:00
|
|
|
ZEND_API char *get_active_function_name(TSRMLS_D);
|
2001-07-27 18:10:39 +08:00
|
|
|
ZEND_API char *zend_get_executed_filename(TSRMLS_D);
|
|
|
|
ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
|
2001-07-30 15:43:02 +08:00
|
|
|
ZEND_API zend_bool zend_is_executing(TSRMLS_D);
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2000-12-05 21:04:05 +08:00
|
|
|
ZEND_API void zend_set_timeout(long seconds);
|
2001-07-30 15:43:02 +08:00
|
|
|
ZEND_API void zend_unset_timeout(TSRMLS_D);
|
2000-07-02 23:39:54 +08:00
|
|
|
ZEND_API void zend_timeout(int dummy);
|
2003-08-03 16:21:08 +08:00
|
|
|
ZEND_API zend_class_entry *zend_fetch_class(char *class_name, uint class_name_len, int fetch_type TSRMLS_DC);
|
2004-02-05 00:30:15 +08:00
|
|
|
void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC);
|
2000-06-16 22:27:28 +08:00
|
|
|
|
2000-06-16 09:54:56 +08:00
|
|
|
#ifdef ZEND_WIN32
|
2000-06-16 22:27:28 +08:00
|
|
|
void zend_init_timeout_thread();
|
|
|
|
void zend_shutdown_timeout_thread();
|
|
|
|
#define WM_REGISTER_ZEND_TIMEOUT (WM_USER+1)
|
|
|
|
#define WM_UNREGISTER_ZEND_TIMEOUT (WM_USER+2)
|
2000-06-16 09:54:56 +08:00
|
|
|
#endif
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
#define zendi_zval_copy_ctor(p) zval_copy_ctor(&(p))
|
|
|
|
#define zendi_zval_dtor(p) zval_dtor(&(p))
|
|
|
|
|
|
|
|
#define active_opline (*EG(opline_ptr))
|
|
|
|
|
2002-11-24 04:44:12 +08:00
|
|
|
/* The following tries to resolve the classname of a zval of type object.
|
|
|
|
* Since it is slow it should be only used in error messages.
|
|
|
|
*/
|
2006-05-10 07:53:23 +08:00
|
|
|
#define Z_OBJ_CLASS_NAME_P(zval) ((zval) && Z_TYPE_P(zval) == IS_OBJECT && Z_OBJ_HT_P(zval)->get_class_entry != NULL && Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC) ? Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC)->name : "")
|
2002-11-24 04:44:12 +08:00
|
|
|
|
2005-01-22 10:29:18 +08:00
|
|
|
ZEND_API zval** zend_get_compiled_variable_value(zend_execute_data *execute_data_ptr, zend_uint var);
|
|
|
|
|
2005-06-10 17:54:38 +08:00
|
|
|
#define ZEND_USER_OPCODE_CONTINUE 0 /* execute next opcode */
|
|
|
|
#define ZEND_USER_OPCODE_RETURN 1 /* exit from executor (return from function) */
|
|
|
|
#define ZEND_USER_OPCODE_DISPATCH 2 /* call original opcode handler */
|
|
|
|
|
2005-06-16 14:00:48 +08:00
|
|
|
#define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */
|
|
|
|
|
2005-06-10 17:54:38 +08:00
|
|
|
ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, opcode_handler_t handler);
|
|
|
|
ZEND_API opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode);
|
|
|
|
|
2005-06-16 19:50:08 +08:00
|
|
|
/* former zend_execute_locks.h */
|
|
|
|
typedef struct _zend_free_op {
|
|
|
|
zval* var;
|
|
|
|
/* int is_var; */
|
|
|
|
} zend_free_op;
|
|
|
|
|
2005-06-16 22:27:08 +08:00
|
|
|
ZEND_API zval *zend_get_zval_ptr(znode *node, temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
|
|
|
|
ZEND_API zval **zend_get_zval_ptr_ptr(znode *node, temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
|
2005-06-16 19:50:08 +08:00
|
|
|
|
2005-06-24 20:33:53 +08:00
|
|
|
ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
|
2005-06-16 19:50:08 +08:00
|
|
|
|
2002-05-20 15:17:30 +08:00
|
|
|
END_EXTERN_C()
|
|
|
|
|
2000-07-03 08:55:36 +08:00
|
|
|
#endif /* ZEND_EXECUTE_H */
|
2003-02-01 09:49:15 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*/
|