Skip to content

Commit a7e7e43

Browse files
committed
Zend/zend_compile: convert memoize_mode macros to enum
1 parent f5287ae commit a7e7e43

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
@@ -378,7 +378,7 @@ void zend_init_compiler_data_structures(void) /* {{{ */
378378

379379
CG(encoding_declared) = 0;
380380
CG(memoized_exprs) = NULL;
381-
CG(memoize_mode) = 0;
381+
CG(memoize_mode) = ZEND_MEMOIZE_NONE;
382382
}
383383
/* }}} */
384384

@@ -2377,13 +2377,9 @@ static void zend_emit_jmp_null(znode *obj_node, uint32_t bp_type)
23772377
zend_stack_push(&CG(short_circuiting_opnums), &jmp_null_opnum);
23782378
}
23792379

2380-
#define ZEND_MEMOIZE_NONE 0
2381-
#define ZEND_MEMOIZE_COMPILE 1
2382-
#define ZEND_MEMOIZE_FETCH 2
2383-
23842380
static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */
23852381
{
2386-
int memoize_mode = CG(memoize_mode);
2382+
const zend_memoize_mode memoize_mode = CG(memoize_mode);
23872383
if (memoize_mode == ZEND_MEMOIZE_COMPILE) {
23882384
znode memoized_result;
23892385

@@ -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
@@ -67,6 +67,12 @@ typedef struct _zend_ini_entry zend_ini_entry;
6767
typedef struct _zend_fiber_context zend_fiber_context;
6868
typedef struct _zend_fiber zend_fiber;
6969

70+
typedef enum {
71+
ZEND_MEMOIZE_NONE,
72+
ZEND_MEMOIZE_COMPILE,
73+
ZEND_MEMOIZE_FETCH,
74+
} zend_memoize_mode;
75+
7076
struct _zend_compiler_globals {
7177
zend_stack loop_var_stack;
7278

@@ -126,7 +132,7 @@ struct _zend_compiler_globals {
126132

127133
zend_stack delayed_oplines_stack;
128134
HashTable *memoized_exprs;
129-
int memoize_mode;
135+
zend_memoize_mode memoize_mode;
130136

131137
void *map_ptr_real_base;
132138
void *map_ptr_base;

0 commit comments

Comments
 (0)