diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index eb74893886ab4..cb8df3f7d3b5a 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -379,7 +379,7 @@ void zend_init_compiler_data_structures(void) /* {{{ */ CG(encoding_declared) = 0; CG(memoized_exprs) = NULL; - CG(memoize_mode) = 0; + CG(memoize_mode) = ZEND_MEMOIZE_NONE; } /* }}} */ @@ -2426,13 +2426,9 @@ static void zend_emit_jmp_null(znode *obj_node, uint32_t bp_type) zend_stack_push(&CG(short_circuiting_opnums), &jmp_null_opnum); } -#define ZEND_MEMOIZE_NONE 0 -#define ZEND_MEMOIZE_COMPILE 1 -#define ZEND_MEMOIZE_FETCH 2 - static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */ { - int memoize_mode = CG(memoize_mode); + const zend_memoize_mode memoize_mode = CG(memoize_mode); if (memoize_mode == ZEND_MEMOIZE_COMPILE) { znode memoized_result; @@ -9184,7 +9180,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */ /* Remember expressions compiled during the initial BP_VAR_IS lookup, * to avoid double-evaluation when we compile again with BP_VAR_W. */ HashTable *orig_memoized_exprs = CG(memoized_exprs); - int orig_memoize_mode = CG(memoize_mode); + const zend_memoize_mode orig_memoize_mode = CG(memoize_mode); zend_ensure_writable_variable(var_ast); if (is_this_fetch(var_ast)) { diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index a2439b80eabcb..0e86187021746 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -70,6 +70,12 @@ typedef struct _zend_ini_entry zend_ini_entry; typedef struct _zend_fiber_context zend_fiber_context; typedef struct _zend_fiber zend_fiber; +typedef enum { + ZEND_MEMOIZE_NONE, + ZEND_MEMOIZE_COMPILE, + ZEND_MEMOIZE_FETCH, +} zend_memoize_mode; + struct _zend_compiler_globals { zend_stack loop_var_stack; @@ -129,7 +135,7 @@ struct _zend_compiler_globals { zend_stack delayed_oplines_stack; HashTable *memoized_exprs; - int memoize_mode; + zend_memoize_mode memoize_mode; void *map_ptr_real_base; void *map_ptr_base; diff --git a/Zend/zend_stack.c b/Zend/zend_stack.c index f587452bb7d59..5d9cc166367e7 100644 --- a/Zend/zend_stack.c +++ b/Zend/zend_stack.c @@ -119,7 +119,7 @@ ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function } -ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg) +ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, zend_stack_apply_direction type, int (*apply_function)(void *element, void *arg), void *arg) { int i; diff --git a/Zend/zend_stack.h b/Zend/zend_stack.h index c0a325b778870..68c3621533f92 100644 --- a/Zend/zend_stack.h +++ b/Zend/zend_stack.h @@ -28,6 +28,11 @@ typedef struct _zend_stack { #define STACK_BLOCK_SIZE 16 +typedef enum { + ZEND_STACK_APPLY_TOPDOWN, + ZEND_STACK_APPLY_BOTTOMUP, +} zend_stack_apply_direction; + BEGIN_EXTERN_C() ZEND_API void zend_stack_init(zend_stack *stack, int size); ZEND_API int zend_stack_push(zend_stack *stack, const void *element); @@ -39,11 +44,8 @@ ZEND_API void zend_stack_destroy(zend_stack *stack); ZEND_API void *zend_stack_base(const zend_stack *stack); ZEND_API int zend_stack_count(const zend_stack *stack); ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element)); -ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg); +ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, zend_stack_apply_direction type, int (*apply_function)(void *element, void *arg), void *arg); ZEND_API void zend_stack_clean(zend_stack *stack, void (*func)(void *), bool free_elements); END_EXTERN_C() -#define ZEND_STACK_APPLY_TOPDOWN 1 -#define ZEND_STACK_APPLY_BOTTOMUP 2 - #endif /* ZEND_STACK_H */