Skip to content

Commit 1de997b

Browse files
committed
Revert kind change
1 parent 0627487 commit 1de997b

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

Zend/zend_compile.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ void zend_stop_lexing(void)
710710
}
711711

712712
static inline void zend_begin_loop(
713-
uint8_t free_opcode, const znode *loop_var, zend_brk_cont_kind kind) /* {{{ */
713+
uint8_t free_opcode, const znode *loop_var, bool is_switch) /* {{{ */
714714
{
715715
zend_brk_cont_element *brk_cont_element;
716716
int parent = CG(context).current_brk_cont;
@@ -719,7 +719,7 @@ static inline void zend_begin_loop(
719719
CG(context).current_brk_cont = CG(context).last_brk_cont;
720720
brk_cont_element = get_next_brk_cont_element();
721721
brk_cont_element->parent = parent;
722-
brk_cont_element->kind = kind;
722+
brk_cont_element->is_switch = is_switch;
723723

724724
uint32_t start = get_next_op_number();
725725
info.opcode_start = start;
@@ -5828,8 +5828,7 @@ static void zend_compile_break_continue(zend_ast *ast) /* {{{ */
58285828
ZEND_ASSERT(cur != -1);
58295829
}
58305830

5831-
if (CG(context).brk_cont_array[cur].kind == ZEND_BRK_CONT_KIND_SWITCH_MATCH_STMT
5832-
|| CG(context).brk_cont_array[cur].kind == ZEND_BRK_CONT_KIND_MATCH_EXPR) {
5831+
if (CG(context).brk_cont_array[cur].is_switch) {
58335832
if (depth == 1) {
58345833
if (CG(context).brk_cont_array[cur].parent == -1) {
58355834
zend_error(E_WARNING,
@@ -5967,7 +5966,7 @@ static void zend_compile_while(zend_ast *ast) /* {{{ */
59675966

59685967
opnum_jmp = zend_emit_jump(0);
59695968

5970-
zend_begin_loop(ZEND_NOP, NULL, ZEND_BRK_CONT_KIND_LOOP);
5969+
zend_begin_loop(ZEND_NOP, NULL, 0);
59715970

59725971
opnum_start = get_next_op_number();
59735972
zend_compile_stmt(stmt_ast);
@@ -5990,7 +5989,7 @@ static void zend_compile_do_while(zend_ast *ast) /* {{{ */
59905989
znode cond_node;
59915990
uint32_t opnum_start, opnum_cond;
59925991

5993-
zend_begin_loop(ZEND_NOP, NULL, ZEND_BRK_CONT_KIND_LOOP);
5992+
zend_begin_loop(ZEND_NOP, NULL, 0);
59945993

59955994
opnum_start = get_next_op_number();
59965995
zend_compile_stmt(stmt_ast);
@@ -6041,7 +6040,7 @@ static void zend_compile_for(zend_ast *ast) /* {{{ */
60416040

60426041
opnum_jmp = zend_emit_jump(0);
60436042

6044-
zend_begin_loop(ZEND_NOP, NULL, ZEND_BRK_CONT_KIND_LOOP);
6043+
zend_begin_loop(ZEND_NOP, NULL, 0);
60456044

60466045
opnum_start = get_next_op_number();
60476046
zend_compile_stmt(stmt_ast);
@@ -6103,7 +6102,7 @@ static void zend_compile_foreach(zend_ast *ast) /* {{{ */
61036102
opnum_reset = get_next_op_number();
61046103
opline = zend_emit_op(&reset_node, by_ref ? ZEND_FE_RESET_RW : ZEND_FE_RESET_R, &expr_node, NULL);
61056104

6106-
zend_begin_loop(ZEND_FE_FREE, &reset_node, ZEND_BRK_CONT_KIND_LOOP);
6105+
zend_begin_loop(ZEND_FE_FREE, &reset_node, 0);
61076106

61086107
opnum_fetch = get_next_op_number();
61096108
opline = zend_emit_op(NULL, by_ref ? ZEND_FE_FETCH_RW : ZEND_FE_FETCH_R, &reset_node, NULL);
@@ -6276,7 +6275,7 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */
62766275

62776276
zend_compile_expr(&expr_node, expr_ast);
62786277

6279-
zend_begin_loop(ZEND_FREE, &expr_node, ZEND_BRK_CONT_KIND_SWITCH_MATCH_STMT);
6278+
zend_begin_loop(ZEND_FREE, &expr_node, 1);
62806279

62816280
case_node.op_type = IS_TMP_VAR;
62826281
case_node.u.op.var = get_temporary_variable();
@@ -6460,7 +6459,7 @@ static void zend_compile_match(znode *result, zend_ast *ast)
64606459
zend_stack_push(&CG(loop_var_stack), &info);
64616460
}
64626461

6463-
zend_begin_loop(ZEND_FREE, &expr_node, result ? ZEND_BRK_CONT_KIND_MATCH_EXPR : ZEND_BRK_CONT_KIND_SWITCH_MATCH_STMT);
6462+
zend_begin_loop(ZEND_FREE, &expr_node, /* is_switch */ true);
64646463

64656464
znode case_node;
64666465
case_node.op_type = IS_TMP_VAR;

Zend/zend_compile.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,12 @@ struct _zend_op {
155155
#endif
156156
};
157157

158-
typedef enum {
159-
ZEND_BRK_CONT_KIND_LOOP,
160-
/* switch or match with unused result. */
161-
ZEND_BRK_CONT_KIND_SWITCH_MATCH_STMT,
162-
/* match with used result. */
163-
ZEND_BRK_CONT_KIND_MATCH_EXPR,
164-
} zend_brk_cont_kind;
165-
166158
typedef struct _zend_brk_cont_element {
167159
int start;
168160
int cont;
169161
int brk;
170162
int parent;
171-
zend_brk_cont_kind kind;
163+
bool is_switch;
172164
} zend_brk_cont_element;
173165

174166
typedef struct _zend_label {

0 commit comments

Comments
 (0)