Skip to content

Commit 57e8da4

Browse files
committed
Zend/zend_compile: convert memoize_mode macros to enum
1 parent 27b8d7e commit 57e8da4

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

@@ -9124,7 +9120,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */
91249120
/* Remember expressions compiled during the initial BP_VAR_IS lookup,
91259121
* to avoid double-evaluation when we compile again with BP_VAR_W. */
91269122
HashTable *orig_memoized_exprs = CG(memoized_exprs);
9127-
int orig_memoize_mode = CG(memoize_mode);
9123+
const zend_memoize_mode orig_memoize_mode = CG(memoize_mode);
91289124

91299125
zend_ensure_writable_variable(var_ast);
91309126
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)