Skip to content

Commit 3fe698b

Browse files
committed
Mark "top-level" functions.
1 parent 03384ca commit 3fe698b

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

Zend/zend_compile.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5895,6 +5895,10 @@ void zend_compile_func_decl(znode *result, zend_ast *ast, zend_bool toplevel) /*
58955895

58965896
CG(active_op_array) = op_array;
58975897

5898+
if (toplevel) {
5899+
op_array->fn_flags |= ZEND_ACC_TOP_LEVEL;
5900+
}
5901+
58985902
zend_oparray_context_begin(&orig_oparray_context);
58995903

59005904
if (CG(compiler_options) & ZEND_COMPILE_EXTENDED_INFO) {

Zend/zend_compile.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ typedef struct _zend_oparray_context {
223223
/* Function has typed arguments / class has typed props | | | */
224224
#define ZEND_ACC_HAS_TYPE_HINTS (1 << 8) /* ? | X | | */
225225
/* | | | */
226+
/* Top-level class or function declaration | | | */
227+
#define ZEND_ACC_TOP_LEVEL (1 << 9) /* X | X | | */
228+
/* | | | */
226229
/* Class Flags (unused: 16...) | | | */
227230
/* =========== | | | */
228231
/* | | | */
@@ -240,75 +243,72 @@ typedef struct _zend_oparray_context {
240243
/* | | | */
241244
/* Class has magic methods __get/__set/__unset/ | | | */
242245
/* __isset that use guards | | | */
243-
#define ZEND_ACC_USE_GUARDS (1 << 9) /* X | | | */
246+
#define ZEND_ACC_USE_GUARDS (1 << 10) /* X | | | */
244247
/* | | | */
245248
/* Class constants updated | | | */
246-
#define ZEND_ACC_CONSTANTS_UPDATED (1 << 10) /* X | | | */
249+
#define ZEND_ACC_CONSTANTS_UPDATED (1 << 11) /* X | | | */
247250
/* | | | */
248251
/* Class extends another class | | | */
249-
#define ZEND_ACC_INHERITED (1 << 11) /* X | | | */
252+
#define ZEND_ACC_INHERITED (1 << 12) /* X | | | */
250253
/* | | | */
251254
/* Class implements interface(s) | | | */
252-
#define ZEND_ACC_IMPLEMENT_INTERFACES (1 << 12) /* X | | | */
255+
#define ZEND_ACC_IMPLEMENT_INTERFACES (1 << 13) /* X | | | */
253256
/* | | | */
254257
/* Class uses trait(s) | | | */
255-
#define ZEND_ACC_IMPLEMENT_TRAITS (1 << 13) /* X | | | */
258+
#define ZEND_ACC_IMPLEMENT_TRAITS (1 << 14) /* X | | | */
256259
/* | | | */
257260
/* User class has methods with static variables | | | */
258-
#define ZEND_HAS_STATIC_IN_METHODS (1 << 14) /* X | | | */
259-
/* | | | */
260-
/* Top-level class declaration | | | */
261-
#define ZEND_ACC_TOP_LEVEL (1 << 15) /* X | | | */
261+
#define ZEND_HAS_STATIC_IN_METHODS (1 << 15) /* X | | | */
262262
/* | | | */
263-
/* Function Flags (unused: 25...30) | | | */
263+
/* Function Flags (unused: 26...30) | | | */
264264
/* ============== | | | */
265265
/* | | | */
266266
/* deprecation flag | | | */
267-
#define ZEND_ACC_DEPRECATED (1 << 9) /* | X | | */
267+
#define ZEND_ACC_DEPRECATED (1 << 10) /* | X | | */
268268
/* | | | */
269269
/* Function returning by reference | | | */
270-
#define ZEND_ACC_RETURN_REFERENCE (1 << 10) /* | X | | */
270+
#define ZEND_ACC_RETURN_REFERENCE (1 << 11) /* | X | | */
271271
/* | | | */
272272
/* Function has a return type | | | */
273-
#define ZEND_ACC_HAS_RETURN_TYPE (1 << 11) /* | X | | */
273+
#define ZEND_ACC_HAS_RETURN_TYPE (1 << 12) /* | X | | */
274274
/* | | | */
275275
/* Function with variable number of arguments | | | */
276-
#define ZEND_ACC_VARIADIC (1 << 12) /* | X | | */
276+
#define ZEND_ACC_VARIADIC (1 << 13) /* | X | | */
277277
/* | | | */
278278
/* op_array has finally blocks (user only) | | | */
279-
#define ZEND_ACC_HAS_FINALLY_BLOCK (1 << 13) /* | X | | */
279+
#define ZEND_ACC_HAS_FINALLY_BLOCK (1 << 14) /* | X | | */
280280
/* | | | */
281281
/* "main" op_array with | | | */
282282
/* ZEND_DECLARE_INHERITED_CLASS_DELAYED opcodes | | | */
283-
#define ZEND_ACC_EARLY_BINDING (1 << 14) /* | X | | */
283+
#define ZEND_ACC_EARLY_BINDING (1 << 15) /* | X | | */
284284
/* | | | */
285285
/* method flag (bc only), any method that has this | | | */
286286
/* flag can be used statically and non statically. | | | */
287-
#define ZEND_ACC_ALLOW_STATIC (1 << 15) /* | X | | */
287+
#define ZEND_ACC_ALLOW_STATIC (1 << 16) /* | X | | */
288288
/* | | | */
289289
/* call through user function trampoline. e.g. | | | */
290290
/* __call, __callstatic | | | */
291-
#define ZEND_ACC_CALL_VIA_TRAMPOLINE (1 << 16) /* | X | | */
291+
#define ZEND_ACC_CALL_VIA_TRAMPOLINE (1 << 17) /* | X | | */
292292
/* | | | */
293293
/* disable inline caching | | | */
294-
#define ZEND_ACC_NEVER_CACHE (1 << 17) /* | X | | */
294+
#define ZEND_ACC_NEVER_CACHE (1 << 18) /* | X | | */
295295
/* | | | */
296296
/* Closure related | | | */
297-
#define ZEND_ACC_CLOSURE (1 << 18) /* | X | | */
298-
#define ZEND_ACC_FAKE_CLOSURE (1 << 19) /* | X | | */
297+
#define ZEND_ACC_CLOSURE (1 << 19) /* | X | | */
298+
#define ZEND_ACC_FAKE_CLOSURE (1 << 20) /* | X | | */
299299
/* | | | */
300300
/* run_time_cache allocated on heap (user only) | | | */
301-
#define ZEND_ACC_HEAP_RT_CACHE (1 << 20) /* | X | | */
301+
#define ZEND_ACC_HEAP_RT_CACHE (1 << 21) /* | X | | */
302302
/* | | | */
303303
/* method flag used by Closure::__invoke() | | | */
304-
#define ZEND_ACC_USER_ARG_INFO (1 << 21) /* | X | | */
304+
#define ZEND_ACC_USER_ARG_INFO (1 << 22) /* | X | | */
305305
/* | | | */
306-
#define ZEND_ACC_GENERATOR (1 << 22) /* | X | | */
306+
#define ZEND_ACC_GENERATOR (1 << 23) /* | X | | */
307307
/* | | | */
308-
#define ZEND_ACC_DONE_PASS_TWO (1 << 23) /* | X | | */
308+
#define ZEND_ACC_DONE_PASS_TWO (1 << 24) /* | X | | */
309309
/* | | | */
310310
/* internal function is allocated at arena (int only) | | | */
311-
#define ZEND_ACC_ARENA_ALLOCATED (1 << 24) /* | X | | */
311+
#define ZEND_ACC_ARENA_ALLOCATED (1 << 25) /* | X | | */
312312
/* | | | */
313313
/* op_array uses strict mode types | | | */
314314
#define ZEND_ACC_STRICT_TYPES (1 << 31) /* | X | | */

0 commit comments

Comments
 (0)