php-src/Zend/zend_execute.h

173 lines
4.8 KiB
C
Raw Normal View History

1999-04-08 02:10:10 +08:00
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
2002-01-06 23:21:36 +08:00
| Copyright (c) 1998-2002 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 |
| available at through the world-wide-web at |
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> |
+----------------------------------------------------------------------+
*/
1999-07-16 22:58:16 +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"
#include "zend_variables.h"
2001-07-29 16:24:38 +08:00
#include "zend_operators.h"
1999-04-08 02:10:10 +08:00
typedef union _temp_variable {
1999-04-08 02:10:10 +08:00
zval tmp_var;
struct {
zval **ptr_ptr;
zval *ptr;
} var;
1999-04-08 02:10:10 +08:00
struct {
1999-07-24 02:41:58 +08:00
zval tmp_var; /* a dummy */
1999-04-08 02:10:10 +08:00
union {
struct {
zval *str;
2002-04-24 02:06:54 +08:00
zend_uint offset;
} str_offset;
2000-04-11 04:21:13 +08:00
zend_property_reference overloaded_element;
} data;
1999-04-08 02:10:10 +08:00
unsigned char type;
zend_class_entry *class_entry;
1999-04-08 02:10:10 +08:00
} EA;
} temp_variable;
2002-05-20 15:17:30 +08:00
BEGIN_EXTERN_C()
ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC);
1999-04-08 02:10:10 +08:00
void init_executor(TSRMLS_D);
void shutdown_executor(TSRMLS_D);
ZEND_API void execute(zend_op_array *op_array TSRMLS_DC);
1999-04-08 02:10:10 +08:00
ZEND_API int zend_is_true(zval *op);
static inline void safe_free_zval_ptr(zval *p)
{
TSRMLS_FETCH();
if (p!=EG(uninitialized_zval_ptr)) {
FREE_ZVAL(p);
}
}
ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
static inline int i_zend_is_true(zval *op)
{
int result;
switch (op->type) {
case IS_NULL:
result = 0;
break;
case IS_LONG:
case IS_BOOL:
case IS_RESOURCE:
result = (op->value.lval?1:0);
break;
case IS_DOUBLE:
result = (op->value.dval ? 1 : 0);
break;
case IS_STRING:
if (op->value.str.len == 0
|| (op->value.str.len==1 && op->value.str.val[0]=='0')) {
result = 0;
} else {
result = 1;
}
break;
case IS_ARRAY:
result = (zend_hash_num_elements(op->value.ht)?1:0);
break;
case IS_OBJECT:
/* OBJ-TBI */
result = 1;
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
/* dedicated Zend executor functions - do not use! */
static inline void zend_ptr_stack_clear_multiple(TSRMLS_D)
{
void **p = EG(argument_stack).top_element-2;
int delete_count = (ulong) *p;
EG(argument_stack).top -= (delete_count+2);
while (--delete_count>=0) {
zval_ptr_dtor((zval **) --p);
}
EG(argument_stack).top_element = p;
}
static inline int zend_ptr_stack_get_arg(int requested_arg, void **data TSRMLS_DC)
{
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;
}
void execute_new_code(TSRMLS_D);
1999-04-08 02:10:10 +08:00
/* services */
2001-07-30 15:43:02 +08:00
ZEND_API char *get_active_function_name(TSRMLS_D);
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);
#ifdef ZEND_WIN32
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)
#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))
void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts TSRMLS_DC);
1999-04-08 02:10:10 +08:00
#define IS_OVERLOADED_OBJECT 1
#define IS_STRING_OFFSET 2
/* 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.
*/
#define Z_OBJ_CLASS_NAME_P(zval) ((zval) && (zval)->type == 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-05-20 15:17:30 +08:00
END_EXTERN_C()
#endif /* ZEND_EXECUTE_H */