Skip to content

Commit f720f05

Browse files
committed
Revert "Two enums instead of preprocessor macros (php#10617)"
This reverts commit bb07e20.
1 parent 1882c47 commit f720f05

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

Zend/zend_compile.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ void zend_init_compiler_data_structures(void) /* {{{ */
379379

380380
CG(encoding_declared) = 0;
381381
CG(memoized_exprs) = NULL;
382-
CG(memoize_mode) = ZEND_MEMOIZE_NONE;
382+
CG(memoize_mode) = 0;
383383
}
384384
/* }}} */
385385

@@ -2445,9 +2445,13 @@ static void zend_emit_jmp_null(znode *obj_node, uint32_t bp_type)
24452445
zend_stack_push(&CG(short_circuiting_opnums), &jmp_null_opnum);
24462446
}
24472447

2448+
#define ZEND_MEMOIZE_NONE 0
2449+
#define ZEND_MEMOIZE_COMPILE 1
2450+
#define ZEND_MEMOIZE_FETCH 2
2451+
24482452
static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */
24492453
{
2450-
const zend_memoize_mode memoize_mode = CG(memoize_mode);
2454+
int memoize_mode = CG(memoize_mode);
24512455
if (memoize_mode == ZEND_MEMOIZE_COMPILE) {
24522456
znode memoized_result;
24532457

@@ -9201,7 +9205,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */
92019205
/* Remember expressions compiled during the initial BP_VAR_IS lookup,
92029206
* to avoid double-evaluation when we compile again with BP_VAR_W. */
92039207
HashTable *orig_memoized_exprs = CG(memoized_exprs);
9204-
const zend_memoize_mode orig_memoize_mode = CG(memoize_mode);
9208+
int orig_memoize_mode = CG(memoize_mode);
92059209

92069210
zend_ensure_writable_variable(var_ast);
92079211
if (is_this_fetch(var_ast)) {

Zend/zend_globals.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ typedef struct _zend_ini_entry zend_ini_entry;
7373
typedef struct _zend_fiber_context zend_fiber_context;
7474
typedef struct _zend_fiber zend_fiber;
7575

76-
typedef enum {
77-
ZEND_MEMOIZE_NONE,
78-
ZEND_MEMOIZE_COMPILE,
79-
ZEND_MEMOIZE_FETCH,
80-
} zend_memoize_mode;
81-
8276
struct _zend_compiler_globals {
8377
zend_stack loop_var_stack;
8478

@@ -138,7 +132,7 @@ struct _zend_compiler_globals {
138132

139133
zend_stack delayed_oplines_stack;
140134
HashTable *memoized_exprs;
141-
zend_memoize_mode memoize_mode;
135+
int memoize_mode;
142136

143137
void *map_ptr_real_base;
144138
void *map_ptr_base;

Zend/zend_stack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function
119119
}
120120

121121

122-
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)
122+
ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg)
123123
{
124124
int i;
125125

Zend/zend_stack.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ typedef struct _zend_stack {
2828

2929
#define STACK_BLOCK_SIZE 16
3030

31-
typedef enum {
32-
ZEND_STACK_APPLY_TOPDOWN,
33-
ZEND_STACK_APPLY_BOTTOMUP,
34-
} zend_stack_apply_direction;
35-
3631
BEGIN_EXTERN_C()
3732
ZEND_API void zend_stack_init(zend_stack *stack, int size);
3833
ZEND_API int zend_stack_push(zend_stack *stack, const void *element);
@@ -44,8 +39,11 @@ ZEND_API void zend_stack_destroy(zend_stack *stack);
4439
ZEND_API void *zend_stack_base(const zend_stack *stack);
4540
ZEND_API int zend_stack_count(const zend_stack *stack);
4641
ZEND_API void zend_stack_apply(zend_stack *stack, int type, int (*apply_function)(void *element));
47-
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);
42+
ZEND_API void zend_stack_apply_with_argument(zend_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg);
4843
ZEND_API void zend_stack_clean(zend_stack *stack, void (*func)(void *), bool free_elements);
4944
END_EXTERN_C()
5045

46+
#define ZEND_STACK_APPLY_TOPDOWN 1
47+
#define ZEND_STACK_APPLY_BOTTOMUP 2
48+
5149
#endif /* ZEND_STACK_H */

0 commit comments

Comments
 (0)