Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 233 lines (199 sloc) 5.969 kb
573b460 @andigutmans Zend Library
andigutmans authored
1 /*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5e55e47 @zsuraski It's official now...
zsuraski authored
5 | Copyright (c) 1998-2000 Zend Technologies Ltd. (http://www.zend.com) |
573b460 @andigutmans Zend Library
andigutmans authored
6 +----------------------------------------------------------------------+
5e55e47 @zsuraski It's official now...
zsuraski authored
7 | This source file is subject to version 0.92 of the Zend license, |
b5b1117 @zsuraski License update
zsuraski authored
8 | that is bundled with this package in the file LICENSE, and is |
9 | available at through the world-wide-web at |
5e55e47 @zsuraski It's official now...
zsuraski authored
10 | http://www.zend.com/license/0_92.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
b5b1117 @zsuraski License update
zsuraski authored
20
573b460 @andigutmans Zend Library
andigutmans authored
21 #ifndef _EXECUTE_H
22 #define _EXECUTE_H
23
24 #include "zend_compile.h"
25 #include "zend_hash.h"
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
26 #include "zend_variables.h"
27 #include "zend_execute_locks.h"
573b460 @andigutmans Zend Library
andigutmans authored
28
1250c43 @zsuraski * Add struct name to all typedef's so that they can be debugged with …
zsuraski authored
29 typedef union _temp_variable {
573b460 @andigutmans Zend Library
andigutmans authored
30 zval tmp_var;
4fff038 @andigutmans - Changed Ts{}.var to Ts{}.var.ptr_ptr.
andigutmans authored
31 struct {
32 zval **ptr_ptr;
b56fd46 @andigutmans - First part of the patch which makes reads use ptr and not ptr_ptr.
andigutmans authored
33 zval *ptr;
4fff038 @andigutmans - Changed Ts{}.var to Ts{}.var.ptr_ptr.
andigutmans authored
34 } var;
573b460 @andigutmans Zend Library
andigutmans authored
35 struct {
028cf1a @zsuraski Fix bug #1812
zsuraski authored
36 zval tmp_var; /* a dummy */
573b460 @andigutmans Zend Library
andigutmans authored
37
a9159c2 @andigutmans Initial preparation for OO overloading patch
andigutmans authored
38 union {
39 struct {
40 zval *str;
41 int offset;
42 } str_offset;
e663d85 @zsuraski Fix object overloading support
zsuraski authored
43 zend_property_reference overloaded_element;
a9159c2 @andigutmans Initial preparation for OO overloading patch
andigutmans authored
44 } data;
45
573b460 @andigutmans Zend Library
andigutmans authored
46 unsigned char type;
47 } EA;
48 } temp_variable;
49
50
51 ZEND_API extern void (*zend_execute)(zend_op_array *op_array ELS_DC);
52
53 void init_executor(CLS_D ELS_DC);
54 void shutdown_executor(ELS_D);
55 void execute(zend_op_array *op_array ELS_DC);
56 ZEND_API int zend_is_true(zval *op);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
57 ZEND_API inline void safe_free_zval_ptr(zval *p)
35f43ad Rename C0x-inline to C9x-inline, and frame preprocessor directives in
Sascha Schumann authored
58 #if defined(C9X_INLINE_SEMANTICS)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
59 {
60 ELS_FETCH();
61
62 if (p!=EG(uninitialized_zval_ptr)) {
63 FREE_ZVAL(p);
64 }
65 }
66 #else
67 ;
68 #endif
69
dc704e2 @andigutmans - Make zend_eval_string() return SUCCESS/FAILURE
andigutmans authored
70 ZEND_API int zend_eval_string(char *str, zval *retval_ptr CLS_DC ELS_DC);
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
71 ZEND_API inline int i_zend_is_true(zval *op)
35f43ad Rename C0x-inline to C9x-inline, and frame preprocessor directives in
Sascha Schumann authored
72 #if defined(C9X_INLINE_SEMANTICS)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
73 {
74 int result;
75
76 switch (op->type) {
77 case IS_NULL:
78 result = 0;
79 break;
80 case IS_LONG:
81 case IS_BOOL:
82 case IS_RESOURCE:
83 result = (op->value.lval?1:0);
84 break;
85 case IS_DOUBLE:
86 result = (op->value.dval ? 1 : 0);
87 break;
88 case IS_STRING:
89 if (op->value.str.len == 0
90 || (op->value.str.len==1 && op->value.str.val[0]=='0')) {
91 result = 0;
92 } else {
93 result = 1;
94 }
95 break;
96 case IS_ARRAY:
97 result = (zend_hash_num_elements(op->value.ht)?1:0);
98 break;
99 case IS_OBJECT:
100 result = (zend_hash_num_elements(op->value.obj.properties)?1:0);
101 break;
102 default:
103 result = 0;
104 break;
105 }
106 return result;
107 }
108 #else
109 ;
110 #endif
111
13b6762 @zsuraski Fix a bug in static initializers/default values/class member variable…
zsuraski authored
112 ZEND_API int zval_update_constant(zval **pp, void *arg);
573b460 @andigutmans Zend Library
andigutmans authored
113
39a7f4c @zsuraski This patch is a go. Not fully optimized yet, but working properly.
zsuraski authored
114 /* dedicated Zend executor functions - do not use! */
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
115 ZEND_API inline void zend_ptr_stack_clear_multiple(ELS_D)
35f43ad Rename C0x-inline to C9x-inline, and frame preprocessor directives in
Sascha Schumann authored
116 #if defined(C9X_INLINE_SEMANTICS)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
117 {
118 void **p = EG(argument_stack).top_element-2;
119 int delete_count = (ulong) *p;
120
121 EG(argument_stack).top -= (delete_count+2);
122 while (--delete_count>=0) {
123 zval_ptr_dtor((zval **) --p);
124 }
125 EG(argument_stack).top_element = p;
126 }
127 #else
128 ;
129 #endif
130
131 ZEND_API inline int zend_ptr_stack_get_arg(int requested_arg, void **data ELS_DC)
35f43ad Rename C0x-inline to C9x-inline, and frame preprocessor directives in
Sascha Schumann authored
132 #if defined(C9X_INLINE_SEMANTICS)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
133 {
134 void **p = EG(argument_stack).top_element-2;
135 int arg_count = (ulong) *p;
136
137 if (requested_arg>arg_count) {
138 return FAILURE;
139 }
140 *data = (p-arg_count+requested_arg-1);
141 return SUCCESS;
142 }
143 #else
144 ;
145 #endif
39a7f4c @zsuraski This patch is a go. Not fully optimized yet, but working properly.
zsuraski authored
146
573b460 @andigutmans Zend Library
andigutmans authored
147 #if SUPPORT_INTERACTIVE
148 void execute_new_code(CLS_D);
149 #endif
150
151
152 /* services */
9353650 Fix warnings surfacing in maintainer-mode.
Stig S. Bakken authored
153 ZEND_API char *get_active_function_name(void);
573b460 @andigutmans Zend Library
andigutmans authored
154 ZEND_API char *zend_get_executed_filename(ELS_D);
155 ZEND_API uint zend_get_executed_lineno(ELS_D);
b6197bc @zsuraski Maintain a state of whether we're compiling and/or executing
zsuraski authored
156 ZEND_API zend_bool zend_is_executing(void);
573b460 @andigutmans Zend Library
andigutmans authored
157
ef0bd3d @zsuraski - Move timeout code to Zend
zsuraski authored
158 void zend_set_timeout(long seconds);
159 void zend_unset_timeout(void);
84eb48f @zsuraski Ok, this time here's some real Win32 system programming :)
zsuraski authored
160 void zend_timeout(int dummy);
161
ef0bd3d @zsuraski - Move timeout code to Zend
zsuraski authored
162 #ifdef ZEND_WIN32
84eb48f @zsuraski Ok, this time here's some real Win32 system programming :)
zsuraski authored
163 void zend_init_timeout_thread();
164 void zend_shutdown_timeout_thread();
165 #define WM_REGISTER_ZEND_TIMEOUT (WM_USER+1)
166 #define WM_UNREGISTER_ZEND_TIMEOUT (WM_USER+2)
ef0bd3d @zsuraski - Move timeout code to Zend
zsuraski authored
167 #endif
168
573b460 @andigutmans Zend Library
andigutmans authored
169 #define zendi_zval_copy_ctor(p) zval_copy_ctor(&(p))
170 #define zendi_zval_dtor(p) zval_dtor(&(p))
171
172 #define active_opline (*EG(opline_ptr))
173
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
174 ZEND_API inline void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts ELS_DC)
35f43ad Rename C0x-inline to C9x-inline, and frame preprocessor directives in
Sascha Schumann authored
175 #if defined(C9X_INLINE_SEMANTICS)
df74f1d Add optional support for C0x inline semantics.
Sascha Schumann authored
176 {
177 zval *variable_ptr = *variable_ptr_ptr;
178 zval *value_ptr;
179
180
181 if (!value_ptr_ptr) {
182 zend_error(E_ERROR, "Cannot create references to string offsets nor overloaded objects");
183 return;
184 }
185
186 value_ptr = *value_ptr_ptr;
187 if (variable_ptr == EG(error_zval_ptr) || value_ptr==EG(error_zval_ptr)) {
188 variable_ptr_ptr = &EG(uninitialized_zval_ptr);
189 /* } else if (variable_ptr==&EG(uninitialized_zval) || variable_ptr!=value_ptr) { */
190 } else if (variable_ptr_ptr != value_ptr_ptr) {
191 variable_ptr->refcount--;
192 if (variable_ptr->refcount==0) {
193 zendi_zval_dtor(*variable_ptr);
194 FREE_ZVAL(variable_ptr);
195 }
196
197 if (!PZVAL_IS_REF(value_ptr)) {
198 /* break it away */
199 value_ptr->refcount--;
200 if (value_ptr->refcount>0) {
201 ALLOC_ZVAL(*value_ptr_ptr);
202 **value_ptr_ptr = *value_ptr;
203 value_ptr = *value_ptr_ptr;
204 zendi_zval_copy_ctor(*value_ptr);
205 }
206 value_ptr->refcount = 1;
207 value_ptr->is_ref = 1;
208 }
209
210 *variable_ptr_ptr = value_ptr;
211 value_ptr->refcount++;
212 } else {
213 if (variable_ptr->refcount>1) { /* we need to break away */
214 SEPARATE_ZVAL(variable_ptr_ptr);
215 }
216 (*variable_ptr_ptr)->is_ref = 1;
217 }
218
219 if (result && (result->op_type != IS_UNUSED)) {
220 Ts[result->u.var].var.ptr_ptr = variable_ptr_ptr;
221 SELECTIVE_PZVAL_LOCK(*variable_ptr_ptr, result);
222 AI_USE_PTR(Ts[result->u.var].var);
223 }
224 }
225 #else
226 ;
227 #endif
573b460 @andigutmans Zend Library
andigutmans authored
228
229 #define IS_OVERLOADED_OBJECT 1
230 #define IS_STRING_OFFSET 2
231
232 #endif /* _EXECUTE_H */
Something went wrong with that request. Please try again.