Skip to content

Commit 0fc800b

Browse files
committed
turn cfg_builder_addop_j into a macro
1 parent 93307ce commit 0fc800b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

Python/compile.c

+7-11
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,10 @@ cfg_builder_addop(cfg_builder *g, int opcode, int oparg, basicblock *target,
13011301
#define CFG_BUILDER_ADDOP_NOARG(G, OP, LOC) \
13021302
cfg_builder_addop(G, OP, NO_OPARG, NO_TARGET, LOC)
13031303

1304+
/* Add a jump instruction. Returns 0 on faiure, 1 on success. */
1305+
#define CFG_BUILDER_ADDOP_J(G, OP, T, LOC) \
1306+
cfg_builder_addop(G, OP, NO_OPARG, T, LOC)
1307+
13041308
static Py_ssize_t
13051309
dict_add_o(PyObject *dict, PyObject *o)
13061310
{
@@ -1513,14 +1517,6 @@ cfg_builder_addop_i(cfg_builder *g, int opcode, Py_ssize_t oparg, struct locatio
15131517
return cfg_builder_addop(g, opcode, oparg_, NULL, loc);
15141518
}
15151519

1516-
static int
1517-
cfg_builder_addop_j(cfg_builder *g, int opcode, basicblock *target, struct location loc)
1518-
{
1519-
assert(target != NO_TARGET);
1520-
assert(IS_JUMP_OPCODE(opcode) || IS_BLOCK_PUSH_OPCODE(opcode));
1521-
return cfg_builder_addop(g, opcode, NO_OPARG, target, loc);
1522-
}
1523-
15241520

15251521
#define ADDOP(C, OP) { \
15261522
if (!CFG_BUILDER_ADDOP_NOARG(CFG_BUILDER(C), (OP), COMPILER_LOC(C))) \
@@ -1583,7 +1579,7 @@ cfg_builder_addop_j(cfg_builder *g, int opcode, basicblock *target, struct locat
15831579

15841580
#define ADDOP_JUMP(C, OP, O) { \
15851581
assert(HAS_TARGET(OP) && (O) != NO_TARGET); \
1586-
if (!cfg_builder_addop_j(CFG_BUILDER(C), (OP), (O), COMPILER_LOC(C))) \
1582+
if (!CFG_BUILDER_ADDOP_J(CFG_BUILDER(C), (OP), (O), COMPILER_LOC(C))) \
15871583
return 0; \
15881584
}
15891585

@@ -1592,7 +1588,7 @@ cfg_builder_addop_j(cfg_builder *g, int opcode, basicblock *target, struct locat
15921588
* token in the source code. */
15931589
#define ADDOP_JUMP_NOLINE(C, OP, O) { \
15941590
assert(HAS_TARGET(OP) && (O) != NO_TARGET); \
1595-
if (!cfg_builder_addop_j(CFG_BUILDER(C), (OP), (O), NO_LOCATION)) \
1591+
if (!CFG_BUILDER_ADDOP_J(CFG_BUILDER(C), (OP), (O), NO_LOCATION)) \
15961592
return 0; \
15971593
}
15981594

@@ -6782,7 +6778,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc)
67826778
}
67836779
assert(control);
67846780
assert(end);
6785-
if (!cfg_builder_addop_j(CFG_BUILDER(c), JUMP, end, COMPILER_LOC(c)) ||
6781+
if (!CFG_BUILDER_ADDOP_J(CFG_BUILDER(c), JUMP, end, COMPILER_LOC(c)) ||
67866782
!emit_and_reset_fail_pop(c, pc))
67876783
{
67886784
goto error;

0 commit comments

Comments
 (0)