Skip to content

Commit f4bfb9c

Browse files
committed
Zend/zend_compile: convert memoize_mode macros to enum
1 parent c279400 commit f4bfb9c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Zend/zend_compile.c

Lines changed: 3 additions & 7 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) = 0;
382+
CG(memoize_mode) = ZEND_MEMOIZE_NONE;
383383
}
384384
/* }}} */
385385

@@ -2426,13 +2426,9 @@ static void zend_emit_jmp_null(znode *obj_node, uint32_t bp_type)
24262426
zend_stack_push(&CG(short_circuiting_opnums), &jmp_null_opnum);
24272427
}
24282428

2429-
#define ZEND_MEMOIZE_NONE 0
2430-
#define ZEND_MEMOIZE_COMPILE 1
2431-
#define ZEND_MEMOIZE_FETCH 2
2432-
24332429
static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */
24342430
{
2435-
int memoize_mode = CG(memoize_mode);
2431+
const zend_memoize_mode memoize_mode = CG(memoize_mode);
24362432
if (memoize_mode == ZEND_MEMOIZE_COMPILE) {
24372433
znode memoized_result;
24382434

@@ -9184,7 +9180,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */
91849180
/* Remember expressions compiled during the initial BP_VAR_IS lookup,
91859181
* to avoid double-evaluation when we compile again with BP_VAR_W. */
91869182
HashTable *orig_memoized_exprs = CG(memoized_exprs);
9187-
int orig_memoize_mode = CG(memoize_mode);
9183+
const zend_memoize_mode orig_memoize_mode = CG(memoize_mode);
91889184

91899185
zend_ensure_writable_variable(var_ast);
91909186
if (is_this_fetch(var_ast)) {

Zend/zend_globals.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ typedef struct _zend_ini_entry zend_ini_entry;
7070
typedef struct _zend_fiber_context zend_fiber_context;
7171
typedef struct _zend_fiber zend_fiber;
7272

73+
typedef enum {
74+
ZEND_MEMOIZE_NONE,
75+
ZEND_MEMOIZE_COMPILE,
76+
ZEND_MEMOIZE_FETCH,
77+
} zend_memoize_mode;
78+
7379
struct _zend_compiler_globals {
7480
zend_stack loop_var_stack;
7581

@@ -129,7 +135,7 @@ struct _zend_compiler_globals {
129135

130136
zend_stack delayed_oplines_stack;
131137
HashTable *memoized_exprs;
132-
int memoize_mode;
138+
zend_memoize_mode memoize_mode;
133139

134140
void *map_ptr_real_base;
135141
void *map_ptr_base;

0 commit comments

Comments
 (0)