1999-04-08 02:10:10 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2000-03-06 13:26:39 +08:00
|
|
|
| Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
|
1999-04-08 02:10:10 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2000-03-06 13:26:39 +08:00
|
|
|
| This source file is subject to version 0.92 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 |
|
2000-03-06 13:26:39 +08:00
|
|
|
| http://www.zend.com/license/0_92.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
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
#ifndef _EXECUTE_H
|
|
|
|
#define _EXECUTE_H
|
|
|
|
|
|
|
|
#include "zend_compile.h"
|
|
|
|
#include "zend_hash.h"
|
2000-06-14 01:58:33 +08:00
|
|
|
#include "zend_variables.h"
|
|
|
|
#include "zend_execute_locks.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;
|
1999-09-26 13:45:18 +08:00
|
|
|
} 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
|
|
|
|
2000-04-07 00:34:55 +08:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
zval *str;
|
|
|
|
int offset;
|
|
|
|
} str_offset;
|
2000-04-11 04:21:13 +08:00
|
|
|
zend_property_reference overloaded_element;
|
2000-04-07 00:34:55 +08:00
|
|
|
} data;
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
unsigned char type;
|
|
|
|
} EA;
|
|
|
|
} temp_variable;
|
|
|
|
|
|
|
|
|
|
|
|
ZEND_API extern void (*zend_execute)(zend_op_array *op_array ELS_DC);
|
|
|
|
|
|
|
|
void init_executor(CLS_D ELS_DC);
|
|
|
|
void shutdown_executor(ELS_D);
|
|
|
|
void execute(zend_op_array *op_array ELS_DC);
|
|
|
|
ZEND_API int zend_is_true(zval *op);
|
2000-06-14 01:58:33 +08:00
|
|
|
ZEND_API inline void safe_free_zval_ptr(zval *p)
|
2000-06-14 15:06:33 +08:00
|
|
|
#if defined(C9X_INLINE_SEMANTICS)
|
2000-06-14 01:58:33 +08:00
|
|
|
{
|
|
|
|
ELS_FETCH();
|
|
|
|
|
|
|
|
if (p!=EG(uninitialized_zval_ptr)) {
|
|
|
|
FREE_ZVAL(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
;
|
|
|
|
#endif
|
|
|
|
|
2000-05-07 02:49:46 +08:00
|
|
|
ZEND_API int zend_eval_string(char *str, zval *retval_ptr CLS_DC ELS_DC);
|
2000-06-14 01:58:33 +08:00
|
|
|
ZEND_API inline int i_zend_is_true(zval *op)
|
2000-06-14 15:06:33 +08:00
|
|
|
#if defined(C9X_INLINE_SEMANTICS)
|
2000-06-14 01:58:33 +08:00
|
|
|
{
|
|
|
|
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:
|
|
|
|
result = (zend_hash_num_elements(op->value.obj.properties)?1:0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
;
|
|
|
|
#endif
|
|
|
|
|
2000-06-01 03:07:09 +08:00
|
|
|
ZEND_API int zval_update_constant(zval **pp, void *arg);
|
1999-04-08 02:10:10 +08:00
|
|
|
|
1999-04-13 02:29:09 +08:00
|
|
|
/* dedicated Zend executor functions - do not use! */
|
2000-06-14 01:58:33 +08:00
|
|
|
ZEND_API inline void zend_ptr_stack_clear_multiple(ELS_D)
|
2000-06-14 15:06:33 +08:00
|
|
|
#if defined(C9X_INLINE_SEMANTICS)
|
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) {
|
|
|
|
zval_ptr_dtor((zval **) --p);
|
|
|
|
}
|
|
|
|
EG(argument_stack).top_element = p;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ZEND_API inline int zend_ptr_stack_get_arg(int requested_arg, void **data ELS_DC)
|
2000-06-14 15:06:33 +08:00
|
|
|
#if defined(C9X_INLINE_SEMANTICS)
|
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;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
;
|
|
|
|
#endif
|
1999-04-13 02:29:09 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
#if SUPPORT_INTERACTIVE
|
|
|
|
void execute_new_code(CLS_D);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* services */
|
1999-12-02 06:55:20 +08:00
|
|
|
ZEND_API char *get_active_function_name(void);
|
1999-04-08 02:10:10 +08:00
|
|
|
ZEND_API char *zend_get_executed_filename(ELS_D);
|
|
|
|
ZEND_API uint zend_get_executed_lineno(ELS_D);
|
2000-02-04 22:45:58 +08:00
|
|
|
ZEND_API zend_bool zend_is_executing(void);
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2000-06-16 09:54:56 +08:00
|
|
|
void zend_set_timeout(long seconds);
|
|
|
|
void zend_unset_timeout(void);
|
2000-07-02 23:39:54 +08:00
|
|
|
ZEND_API void zend_timeout(int dummy);
|
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))
|
|
|
|
|
2000-06-14 01:58:33 +08:00
|
|
|
ZEND_API inline void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts ELS_DC)
|
2000-06-14 15:06:33 +08:00
|
|
|
#if defined(C9X_INLINE_SEMANTICS)
|
2000-06-14 01:58:33 +08:00
|
|
|
{
|
|
|
|
zval *variable_ptr = *variable_ptr_ptr;
|
|
|
|
zval *value_ptr;
|
|
|
|
|
|
|
|
|
|
|
|
if (!value_ptr_ptr) {
|
|
|
|
zend_error(E_ERROR, "Cannot create references to string offsets nor overloaded objects");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
value_ptr = *value_ptr_ptr;
|
|
|
|
if (variable_ptr == EG(error_zval_ptr) || value_ptr==EG(error_zval_ptr)) {
|
|
|
|
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
|
|
|
/* } else if (variable_ptr==&EG(uninitialized_zval) || variable_ptr!=value_ptr) { */
|
|
|
|
} else if (variable_ptr_ptr != value_ptr_ptr) {
|
|
|
|
variable_ptr->refcount--;
|
|
|
|
if (variable_ptr->refcount==0) {
|
|
|
|
zendi_zval_dtor(*variable_ptr);
|
|
|
|
FREE_ZVAL(variable_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!PZVAL_IS_REF(value_ptr)) {
|
|
|
|
/* break it away */
|
|
|
|
value_ptr->refcount--;
|
|
|
|
if (value_ptr->refcount>0) {
|
|
|
|
ALLOC_ZVAL(*value_ptr_ptr);
|
|
|
|
**value_ptr_ptr = *value_ptr;
|
|
|
|
value_ptr = *value_ptr_ptr;
|
|
|
|
zendi_zval_copy_ctor(*value_ptr);
|
|
|
|
}
|
|
|
|
value_ptr->refcount = 1;
|
|
|
|
value_ptr->is_ref = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*variable_ptr_ptr = value_ptr;
|
|
|
|
value_ptr->refcount++;
|
|
|
|
} else {
|
|
|
|
if (variable_ptr->refcount>1) { /* we need to break away */
|
|
|
|
SEPARATE_ZVAL(variable_ptr_ptr);
|
|
|
|
}
|
|
|
|
(*variable_ptr_ptr)->is_ref = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result && (result->op_type != IS_UNUSED)) {
|
|
|
|
Ts[result->u.var].var.ptr_ptr = variable_ptr_ptr;
|
|
|
|
SELECTIVE_PZVAL_LOCK(*variable_ptr_ptr, result);
|
|
|
|
AI_USE_PTR(Ts[result->u.var].var);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
;
|
|
|
|
#endif
|
1999-04-08 02:10:10 +08:00
|
|
|
|
|
|
|
#define IS_OVERLOADED_OBJECT 1
|
|
|
|
#define IS_STRING_OFFSET 2
|
|
|
|
|
|
|
|
#endif /* _EXECUTE_H */
|