xref: /PHP-7.1/Zend/zend_globals.h (revision ccd4716e)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine                                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 2.00 of the Zend license,     |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.zend.com/license/2_00.txt.                                |
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.              |
14    +----------------------------------------------------------------------+
15    | Authors: Andi Gutmans <andi@zend.com>                                |
16    |          Zeev Suraski <zeev@zend.com>                                |
17    +----------------------------------------------------------------------+
18 */
19 
20 /* $Id$ */
21 
22 #ifndef ZEND_GLOBALS_H
23 #define ZEND_GLOBALS_H
24 
25 
26 #include <setjmp.h>
27 
28 #include "zend_globals_macros.h"
29 
30 #include "zend_stack.h"
31 #include "zend_ptr_stack.h"
32 #include "zend_hash.h"
33 #include "zend_llist.h"
34 #include "zend_objects.h"
35 #include "zend_objects_API.h"
36 #include "zend_modules.h"
37 #include "zend_float.h"
38 #include "zend_multibyte.h"
39 #include "zend_multiply.h"
40 #include "zend_arena.h"
41 
42 /* Define ZTS if you want a thread-safe Zend */
43 /*#undef ZTS*/
44 
45 #ifdef ZTS
46 
47 BEGIN_EXTERN_C()
48 ZEND_API extern int compiler_globals_id;
49 ZEND_API extern int executor_globals_id;
50 END_EXTERN_C()
51 
52 #endif
53 
54 #define SYMTABLE_CACHE_SIZE 32
55 
56 
57 #include "zend_compile.h"
58 
59 /* excpt.h on Digital Unix 4.0 defines function_table */
60 #undef function_table
61 
62 #define ZEND_EARLY_BINDING_COMPILE_TIME 0
63 #define ZEND_EARLY_BINDING_DELAYED      1
64 #define ZEND_EARLY_BINDING_DELAYED_ALL  2
65 
66 typedef struct _zend_vm_stack *zend_vm_stack;
67 typedef struct _zend_ini_entry zend_ini_entry;
68 
69 
70 struct _zend_compiler_globals {
71 	zend_stack loop_var_stack;
72 
73 	zend_class_entry *active_class_entry;
74 
75 	zend_string *compiled_filename;
76 
77 	int zend_lineno;
78 
79 	zend_op_array *active_op_array;
80 
81 	HashTable *function_table;	/* function symbol table */
82 	HashTable *class_table;		/* class table */
83 
84 	HashTable filenames_table;
85 
86 	HashTable *auto_globals;
87 
88 	zend_bool parse_error;
89 	zend_bool in_compilation;
90 	zend_bool short_tags;
91 
92 	zend_bool unclean_shutdown;
93 
94 	zend_bool ini_parser_unbuffered_errors;
95 
96 	zend_llist open_files;
97 
98 	struct _zend_ini_parser_param *ini_parser_param;
99 
100 	uint32_t start_lineno;
101 	zend_bool increment_lineno;
102 
103 	zend_string *doc_comment;
104 	uint32_t extra_fn_flags;
105 
106 	uint32_t compiler_options; /* set of ZEND_COMPILE_* constants */
107 
108 	HashTable const_filenames;
109 
110 	zend_oparray_context context;
111 	zend_file_context file_context;
112 
113 	zend_arena *arena;
114 
115 	zend_string *empty_string;
116 	zend_string *one_char_string[256];
117 	zend_string **known_strings;
118 	uint32_t    known_strings_count;
119 
120 	HashTable interned_strings;
121 
122 	const zend_encoding **script_encoding_list;
123 	size_t script_encoding_list_size;
124 	zend_bool multibyte;
125 	zend_bool detect_unicode;
126 	zend_bool encoding_declared;
127 
128 	zend_ast *ast;
129 	zend_arena *ast_arena;
130 
131 	zend_stack delayed_oplines_stack;
132 
133 #ifdef ZTS
134 	zval **static_members_table;
135 	int last_static_member;
136 #endif
137 };
138 
139 
140 struct _zend_executor_globals {
141 	zval uninitialized_zval;
142 	zval error_zval;
143 
144 	/* symbol table cache */
145 	zend_array *symtable_cache[SYMTABLE_CACHE_SIZE];
146 	zend_array **symtable_cache_limit;
147 	zend_array **symtable_cache_ptr;
148 
149 	zend_array symbol_table;		/* main symbol table */
150 
151 	HashTable included_files;	/* files already included */
152 
153 	JMP_BUF *bailout;
154 
155 	int error_reporting;
156 	int exit_status;
157 
158 	HashTable *function_table;	/* function symbol table */
159 	HashTable *class_table;		/* class table */
160 	HashTable *zend_constants;	/* constants table */
161 
162 	zval          *vm_stack_top;
163 	zval          *vm_stack_end;
164 	zend_vm_stack  vm_stack;
165 
166 	struct _zend_execute_data *current_execute_data;
167 	zend_class_entry *fake_scope; /* used to avoid checks accessing properties */
168 
169 	zend_long precision;
170 
171 	int ticks_count;
172 
173 	HashTable *in_autoload;
174 	zend_function *autoload_func;
175 	zend_bool full_tables_cleanup;
176 
177 	/* for extended information support */
178 	zend_bool no_extensions;
179 
180 	zend_bool vm_interrupt;
181 	zend_bool timed_out;
182 	zend_long hard_timeout;
183 
184 #ifdef ZEND_WIN32
185 	OSVERSIONINFOEX windows_version_info;
186 #endif
187 
188 	HashTable regular_list;
189 	HashTable persistent_list;
190 
191 	int user_error_handler_error_reporting;
192 	zval user_error_handler;
193 	zval user_exception_handler;
194 	zend_stack user_error_handlers_error_reporting;
195 	zend_stack user_error_handlers;
196 	zend_stack user_exception_handlers;
197 
198 	zend_error_handling_t  error_handling;
199 	zend_class_entry      *exception_class;
200 
201 	/* timeout support */
202 	zend_long timeout_seconds;
203 
204 	int lambda_count;
205 
206 	HashTable *ini_directives;
207 	HashTable *modified_ini_directives;
208 	zend_ini_entry *error_reporting_ini_entry;
209 
210 	zend_objects_store objects_store;
211 	zend_object *exception, *prev_exception;
212 	const zend_op *opline_before_exception;
213 	zend_op exception_op[3];
214 
215 	struct _zend_module_entry *current_module;
216 
217 	zend_bool active;
218 	zend_bool valid_symbol_table;
219 
220 	zend_long assertions;
221 
222 	uint32_t           ht_iterators_count;     /* number of allocatd slots */
223 	uint32_t           ht_iterators_used;      /* number of used slots */
224 	HashTableIterator *ht_iterators;
225 	HashTableIterator  ht_iterators_slots[16];
226 
227 	void *saved_fpu_cw_ptr;
228 #if XPFPA_HAVE_CW
229 	XPFPA_CW_DATATYPE saved_fpu_cw;
230 #endif
231 
232 	zend_function trampoline;
233 	zend_op       call_trampoline_op;
234 
235 	void *reserved[ZEND_MAX_RESERVED_RESOURCES];
236 };
237 
238 struct _zend_ini_scanner_globals {
239 	zend_file_handle *yy_in;
240 	zend_file_handle *yy_out;
241 
242 	unsigned int yy_leng;
243 	unsigned char *yy_start;
244 	unsigned char *yy_text;
245 	unsigned char *yy_cursor;
246 	unsigned char *yy_marker;
247 	unsigned char *yy_limit;
248 	int yy_state;
249 	zend_stack state_stack;
250 
251 	char *filename;
252 	int lineno;
253 
254 	/* Modes are: ZEND_INI_SCANNER_NORMAL, ZEND_INI_SCANNER_RAW, ZEND_INI_SCANNER_TYPED */
255 	int scanner_mode;
256 };
257 
258 typedef enum {
259 	ON_TOKEN,
260 	ON_FEEDBACK,
261 	ON_STOP
262 } zend_php_scanner_event;
263 
264 struct _zend_php_scanner_globals {
265 	zend_file_handle *yy_in;
266 	zend_file_handle *yy_out;
267 
268 	unsigned int yy_leng;
269 	unsigned char *yy_start;
270 	unsigned char *yy_text;
271 	unsigned char *yy_cursor;
272 	unsigned char *yy_marker;
273 	unsigned char *yy_limit;
274 	int yy_state;
275 	zend_stack state_stack;
276 	zend_ptr_stack heredoc_label_stack;
277 
278 	/* original (unfiltered) script */
279 	unsigned char *script_org;
280 	size_t script_org_size;
281 
282 	/* filtered script */
283 	unsigned char *script_filtered;
284 	size_t script_filtered_size;
285 
286 	/* input/output filters */
287 	zend_encoding_filter input_filter;
288 	zend_encoding_filter output_filter;
289 	const zend_encoding *script_encoding;
290 
291 	/* initial string length after scanning to first variable */
292 	int scanned_string_len;
293 
294 	/* hooks */
295 	void (*on_event)(zend_php_scanner_event event, int token, int line, void *context);
296 	void *on_event_context;
297 };
298 
299 #endif /* ZEND_GLOBALS_H */
300 
301 /*
302  * Local variables:
303  * tab-width: 4
304  * c-basic-offset: 4
305  * indent-tabs-mode: t
306  * End:
307  */
308