Skip to content

Commit f6dae37

Browse files
committed
Zend/zend_compile: convert memoize_mode macros to enum
1 parent 613d6e7 commit f6dae37

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

@@ -2334,13 +2334,9 @@ static void zend_emit_jmp_null(znode *obj_node, uint32_t bp_type)
23342334
zend_stack_push(&CG(short_circuiting_opnums), &jmp_null_opnum);
23352335
}
23362336

2337-
#define ZEND_MEMOIZE_NONE 0
2338-
#define ZEND_MEMOIZE_COMPILE 1
2339-
#define ZEND_MEMOIZE_FETCH 2
2340-
23412337
static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */
23422338
{
2343-
int memoize_mode = CG(memoize_mode);
2339+
const zend_memoize_mode memoize_mode = CG(memoize_mode);
23442340
if (memoize_mode == ZEND_MEMOIZE_COMPILE) {
23452341
znode memoized_result;
23462342

@@ -9109,7 +9105,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */
91099105
/* Remember expressions compiled during the initial BP_VAR_IS lookup,
91109106
* to avoid double-evaluation when we compile again with BP_VAR_W. */
91119107
HashTable *orig_memoized_exprs = CG(memoized_exprs);
9112-
int orig_memoize_mode = CG(memoize_mode);
9108+
const zend_memoize_mode orig_memoize_mode = CG(memoize_mode);
91139109

91149110
zend_ensure_writable_variable(var_ast);
91159111
if (is_this_fetch(var_ast)) {

Zend/zend_globals.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ typedef struct _zend_ini_entry zend_ini_entry;
6565
typedef struct _zend_fiber_context zend_fiber_context;
6666
typedef struct _zend_fiber zend_fiber;
6767

68+
typedef enum {
69+
ZEND_MEMOIZE_NONE,
70+
ZEND_MEMOIZE_COMPILE,
71+
ZEND_MEMOIZE_FETCH,
72+
} zend_memoize_mode;
73+
6874
struct _zend_compiler_globals {
6975
zend_stack loop_var_stack;
7076

@@ -124,7 +130,7 @@ struct _zend_compiler_globals {
124130

125131
zend_stack delayed_oplines_stack;
126132
HashTable *memoized_exprs;
127-
int memoize_mode;
133+
zend_memoize_mode memoize_mode;
128134

129135
void *map_ptr_real_base;
130136
void *map_ptr_base;

0 commit comments

Comments
 (0)