Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 224 lines (189 sloc) 7.205 kB
573b460 @andigutmans Zend Library
andigutmans authored
1 /*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
61e93cc @andigutmans - Update copyright notices to 2006
andigutmans authored
5 | Copyright (c) 1998-2006 Zend Technologies Ltd. (http://www.zend.com) |
573b460 @andigutmans Zend Library
andigutmans authored
6 +----------------------------------------------------------------------+
d863d52 Update headers.
Sebastian Bergmann authored
7 | This source file is subject to version 2.00 of the Zend license, |
b5b1117 @zsuraski License update
zsuraski authored
8 | that is bundled with this package in the file LICENSE, and is |
f68c7ff updating license information in the headers.
James Cox authored
9 | available through the world-wide-web at the following url: |
d863d52 Update headers.
Sebastian Bergmann authored
10 | http://www.zend.com/license/2_00.txt. |
b5b1117 @zsuraski License update
zsuraski authored
11 | If you did not receive a copy of the Zend license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@zend.com so we can mail you a copy immediately. |
573b460 @andigutmans Zend Library
andigutmans authored
14 +----------------------------------------------------------------------+
15 | Authors: Andi Gutmans <andi@zend.com> |
16 | Zeev Suraski <zeev@zend.com> |
17 +----------------------------------------------------------------------+
18 */
19
333406b - Added some missing CVS $Id$ tags, headers and footers.
foobar authored
20 /* $Id$ */
b5b1117 @zsuraski License update
zsuraski authored
21
a617217 Replace macros which begin with an underscore through an appropiately
Sascha Schumann authored
22 #ifndef ZEND_EXECUTE_H
23 #define ZEND_EXECUTE_H
573b460 @andigutmans Zend Library
andigutmans authored
24
25 #include "zend_compile.h"
26 #include "zend_hash.h"
51b9245 @andigutmans - More object junk
andigutmans authored
27 #include "zend_operators.h"
637a404 - MFH as discussed
Marcus Boerger authored
28 #include "zend_variables.h"
573b460 @andigutmans Zend Library
andigutmans authored
29
1250c43 @zsuraski * Add struct name to all typedef's so that they can be debugged with …
zsuraski authored
30 typedef union _temp_variable {
573b460 @andigutmans Zend Library
andigutmans authored
31 zval tmp_var;
4fff038 @andigutmans - Changed Ts{}.var to Ts{}.var.ptr_ptr.
andigutmans authored
32 struct {
33 zval **ptr_ptr;
b56fd46 @andigutmans - First part of the patch which makes reads use ptr and not ptr_ptr.
andigutmans authored
34 zval *ptr;
3a42bab @zsuraski Fix behavior of return-by-reference functions. Remove erroneous warn…
zsuraski authored
35 zend_bool fcall_returned_reference;
4fff038 @andigutmans - Changed Ts{}.var to Ts{}.var.ptr_ptr.
andigutmans authored
36 } var;
21f0964 @andigutmans - Hopefully fix bug #26696.
andigutmans authored
37 struct {
d9252aa @andigutmans - Fix for bug #29707
andigutmans authored
38 zval **ptr_ptr;
39 zval *ptr;
40 zend_bool fcall_returned_reference;
21f0964 @andigutmans - Hopefully fix bug #26696.
andigutmans authored
41 zval *str;
42 zend_uint offset;
43 } str_offset;
e94e3e1 @zsuraski Some cleanup
zsuraski authored
44 zend_class_entry *class_entry;
573b460 @andigutmans Zend Library
andigutmans authored
45 } temp_variable;
46
47
0450ab9 @zsuraski MFZE1 (Expose more C++ APIs)
zsuraski authored
48 BEGIN_EXTERN_C()
2c254ba @zsuraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
49 ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC);
2c44fab - Ported the zend_execute_internal hook to ZendEngine2.
Derick Rethans authored
50 ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
573b460 @andigutmans Zend Library
andigutmans authored
51
b4f3b9d @zsuraski Redesigned thread safety mechanism - nua nua
zsuraski authored
52 void init_executor(TSRMLS_D);
2c254ba @zsuraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
53 void shutdown_executor(TSRMLS_D);
0cd2da0 - Execute destructors earlier (Florian Schaper, fschaper at intux org)
Marcus Boerger authored
54 void shutdown_destructors(TSRMLS_D);
2c254ba @zsuraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
55 ZEND_API void execute(zend_op_array *op_array TSRMLS_DC);
2c44fab - Ported the zend_execute_internal hook to ZendEngine2.
Derick Rethans authored
56 ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC);
573b460 @andigutmans Zend Library
andigutmans authored
57 ZEND_API int zend_is_true(zval *op);
3df0288 Improove debug capabilities
Marcus Boerger authored
58 #define safe_free_zval_ptr(p) safe_free_zval_ptr_rel(p ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
59 static inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
60 {
2c254ba @zsuraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
61 TSRMLS_FETCH();
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
62
63 if (p!=EG(uninitialized_zval_ptr)) {
3df0288 Improove debug capabilities
Marcus Boerger authored
64 FREE_ZVAL_REL(p);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
65 }
66 }
690c85b @andigutmans - Fix bug in class constants
andigutmans authored
67 ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
9305339 Changed "instanceof" and "catch" operators, is_a() and is_subclass_of…
Dmitry Stogov authored
68 ZEND_API int zend_lookup_class_ex(char *name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC);
b4f3b9d @zsuraski Redesigned thread safety mechanism - nua nua
zsuraski authored
69 ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
d3473d1 - Provide a unified way to display uncaught exceptions, which shows
Marcus Boerger authored
70 ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
6608f07 @smalyshev Mega-commit: Enter the new object model
smalyshev authored
71
99771d9 Remove --enable-c9x-inline option. We now use a syntax which is compa…
Sascha Schumann authored
72 static inline int i_zend_is_true(zval *op)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
73 {
74 int result;
75
637a404 - MFH as discussed
Marcus Boerger authored
76 switch (Z_TYPE_P(op)) {
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
77 case IS_NULL:
78 result = 0;
79 break;
80 case IS_LONG:
81 case IS_BOOL:
82 case IS_RESOURCE:
637a404 - MFH as discussed
Marcus Boerger authored
83 result = (Z_LVAL_P(op)?1:0);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
84 break;
85 case IS_DOUBLE:
637a404 - MFH as discussed
Marcus Boerger authored
86 result = (Z_DVAL_P(op) ? 1 : 0);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
87 break;
88 case IS_STRING:
637a404 - MFH as discussed
Marcus Boerger authored
89 if (Z_STRLEN_P(op) == 0
90 || (Z_STRLEN_P(op)==1 && Z_STRVAL_P(op)[0]=='0')) {
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
91 result = 0;
92 } else {
93 result = 1;
94 }
95 break;
96 case IS_ARRAY:
637a404 - MFH as discussed
Marcus Boerger authored
97 result = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
98 break;
99 case IS_OBJECT:
97e7ce7 @smalyshev fix the fix
smalyshev authored
100 if(IS_ZEND_STD_OBJECT(*op)) {
f9c6520 @smalyshev Fix object true value: if we are in compat mode and it's Zend object -
smalyshev authored
101 TSRMLS_FETCH();
9d1f2f3 Fixed bug #34199 (if($obj)/if(!$obj) inconsistency)
Dmitry Stogov authored
102
103 if (Z_OBJ_HT_P(op)->cast_object) {
104 zval tmp;
637a404 - MFH as discussed
Marcus Boerger authored
105 if (Z_OBJ_HT_P(op)->cast_object(op, &tmp, IS_BOOL TSRMLS_CC) == SUCCESS) {
9d1f2f3 Fixed bug #34199 (if($obj)/if(!$obj) inconsistency)
Dmitry Stogov authored
106 result = Z_LVAL(tmp);
107 break;
108 }
109 } else if (Z_OBJ_HT_P(op)->get) {
110 zval *tmp = Z_OBJ_HT_P(op)->get(op TSRMLS_CC);
111 if(Z_TYPE_P(tmp) != IS_OBJECT) {
112 /* for safety - avoid loop */
113 convert_to_boolean(tmp);
114 result = Z_LVAL_P(tmp);
115 zval_ptr_dtor(&tmp);
116 break;
117 }
118 }
f9c6520 @smalyshev Fix object true value: if we are in compat mode and it's Zend object -
smalyshev authored
119 }
637a404 - MFH as discussed
Marcus Boerger authored
120 result = 1;
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
121 break;
122 default:
123 result = 0;
124 break;
125 }
126 return result;
127 }
128
d76cf1d @zsuraski More TSRMLS_FETCH work
zsuraski authored
129 ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC);
573b460 @andigutmans Zend Library
andigutmans authored
130
39a7f4c @zsuraski This patch is a go. Not fully optimized yet, but working properly.
zsuraski authored
131 /* dedicated Zend executor functions - do not use! */
2c254ba @zsuraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
132 static inline void zend_ptr_stack_clear_multiple(TSRMLS_D)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
133 {
134 void **p = EG(argument_stack).top_element-2;
135 int delete_count = (ulong) *p;
136
137 EG(argument_stack).top -= (delete_count+2);
138 while (--delete_count>=0) {
8df40bd Keeping consistent arg_stack during arguments freeing (Exception from…
Dmitry Stogov authored
139 zval *q = *(zval **)(--p);
140 *p = NULL;
141 zval_ptr_dtor(&q);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
142 }
143 EG(argument_stack).top_element = p;
144 }
145
2c254ba @zsuraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
146 static inline int zend_ptr_stack_get_arg(int requested_arg, void **data TSRMLS_DC)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
147 {
148 void **p = EG(argument_stack).top_element-2;
149 int arg_count = (ulong) *p;
150
151 if (requested_arg>arg_count) {
152 return FAILURE;
153 }
154 *data = (p-arg_count+requested_arg-1);
155 return SUCCESS;
156 }
39a7f4c @zsuraski This patch is a go. Not fully optimized yet, but working properly.
zsuraski authored
157
b4f3b9d @zsuraski Redesigned thread safety mechanism - nua nua
zsuraski authored
158 void execute_new_code(TSRMLS_D);
573b460 @andigutmans Zend Library
andigutmans authored
159
160
161 /* services */
09e7647 Improve error message
Marcus Boerger authored
162 ZEND_API char *get_active_class_name(char **space TSRMLS_DC);
4187439 @zsuraski More TSRMLS_FETCH work
zsuraski authored
163 ZEND_API char *get_active_function_name(TSRMLS_D);
2c254ba @zsuraski Get rid of ELS_*(), and use TSRMLS_*() instead.
zsuraski authored
164 ZEND_API char *zend_get_executed_filename(TSRMLS_D);
165 ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
4187439 @zsuraski More TSRMLS_FETCH work
zsuraski authored
166 ZEND_API zend_bool zend_is_executing(TSRMLS_D);
573b460 @andigutmans Zend Library
andigutmans authored
167
848e51f @zsuraski Expose all timeout functions
zsuraski authored
168 ZEND_API void zend_set_timeout(long seconds);
4187439 @zsuraski More TSRMLS_FETCH work
zsuraski authored
169 ZEND_API void zend_unset_timeout(TSRMLS_D);
b72a273 @andigutmans - Forgot ZEND_API
andigutmans authored
170 ZEND_API void zend_timeout(int dummy);
9d7122f @zsuraski Generalize fetch_class
zsuraski authored
171 ZEND_API zend_class_entry *zend_fetch_class(char *class_name, uint class_name_len, int fetch_type TSRMLS_DC);
c5d8422 @zsuraski Reinstate early-binding for classes.
zsuraski authored
172 void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC);
84eb48f @zsuraski Ok, this time here's some real Win32 system programming :)
zsuraski authored
173
ef0bd3d @zsuraski - Move timeout code to Zend
zsuraski authored
174 #ifdef ZEND_WIN32
84eb48f @zsuraski Ok, this time here's some real Win32 system programming :)
zsuraski authored
175 void zend_init_timeout_thread();
176 void zend_shutdown_timeout_thread();
177 #define WM_REGISTER_ZEND_TIMEOUT (WM_USER+1)
178 #define WM_UNREGISTER_ZEND_TIMEOUT (WM_USER+2)
ef0bd3d @zsuraski - Move timeout code to Zend
zsuraski authored
179 #endif
180
573b460 @andigutmans Zend Library
andigutmans authored
181 #define zendi_zval_copy_ctor(p) zval_copy_ctor(&(p))
182 #define zendi_zval_dtor(p) zval_dtor(&(p))
183
184 #define active_opline (*EG(opline_ptr))
185
e8214a3 @andigutmans - Commit Marcus' cleanup of abstract and static inheritance and improve
andigutmans authored
186 /* The following tries to resolve the classname of a zval of type object.
187 * Since it is slow it should be only used in error messages.
188 */
637a404 - MFH as discussed
Marcus Boerger authored
189 #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 : "")
e8214a3 @andigutmans - Commit Marcus' cleanup of abstract and static inheritance and improve
andigutmans authored
190
8838c0f @andigutmans - Two new API calls for Derick (retreive CV name and value) by Dmitry
andigutmans authored
191 ZEND_API zval** zend_get_compiled_variable_value(zend_execute_data *execute_data_ptr, zend_uint var);
192
84b96e9 Fix so that extensions like xdebug, can overload opcodes in all execu…
Dmitry Stogov authored
193 #define ZEND_USER_OPCODE_CONTINUE 0 /* execute next opcode */
194 #define ZEND_USER_OPCODE_RETURN 1 /* exit from executor (return from function) */
195 #define ZEND_USER_OPCODE_DISPATCH 2 /* call original opcode handler */
196
3c1a774 USER_OPCODE API is improvet.
Dmitry Stogov authored
197 #define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */
198
84b96e9 Fix so that extensions like xdebug, can overload opcodes in all execu…
Dmitry Stogov authored
199 ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, opcode_handler_t handler);
200 ZEND_API opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode);
201
87c9e68 @smalyshev export zval getters
smalyshev authored
202 /* former zend_execute_locks.h */
203 typedef struct _zend_free_op {
204 zval* var;
205 /* int is_var; */
206 } zend_free_op;
207
999998e @smalyshev rename to zend_
smalyshev authored
208 ZEND_API zval *zend_get_zval_ptr(znode *node, temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
209 ZEND_API zval **zend_get_zval_ptr_ptr(znode *node, temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC);
87c9e68 @smalyshev export zval getters
smalyshev authored
210
61b9ded Export zend_do_fcall() helper from executor
Dmitry Stogov authored
211 ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
87c9e68 @smalyshev export zval getters
smalyshev authored
212
0450ab9 @zsuraski MFZE1 (Expose more C++ APIs)
zsuraski authored
213 END_EXTERN_C()
214
a617217 Replace macros which begin with an underscore through an appropiately
Sascha Schumann authored
215 #endif /* ZEND_EXECUTE_H */
333406b - Added some missing CVS $Id$ tags, headers and footers.
foobar authored
216
217 /*
218 * Local variables:
219 * tab-width: 4
220 * c-basic-offset: 4
221 * indent-tabs-mode: t
222 * End:
223 */
Something went wrong with that request. Please try again.