Skip to content

Commit b8f4acf

Browse files
committed
INSTR_STREAM --> INSTR_SEQUENCE
1 parent cd0225d commit b8f4acf

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

Python/compile.c

+23-23
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ static struct jump_target_label_ NO_LABEL = {-1};
175175
#define IS_LABEL(L) (!SAME_LABEL((L), (NO_LABEL)))
176176

177177
#define NEW_JUMP_TARGET_LABEL(C, NAME) \
178-
jump_target_label NAME = instr_sequence_new_label(INSTR_STREAM(C)); \
178+
jump_target_label NAME = instr_sequence_new_label(INSTR_SEQUENCE(C)); \
179179
if (!IS_LABEL(NAME)) { \
180180
return ERROR; \
181181
}
182182

183183
#define USE_LABEL(C, LBL) \
184-
RETURN_IF_ERROR(instr_sequence_use_label(INSTR_STREAM(C), (LBL).id))
184+
RETURN_IF_ERROR(instr_sequence_use_label(INSTR_SEQUENCE(C), (LBL).id))
185185

186186
struct cfg_instr {
187187
int i_opcode;
@@ -428,20 +428,20 @@ typedef struct instr_sequence_ {
428428
int s_next_free_label; /* next free label id */
429429
} instr_sequence;
430430

431-
#define INITIAL_INSTR_STREAM_SIZE 100
432-
#define INITIAL_INSTR_STREAM_LABELS_MAP_SIZE 10
431+
#define INITIAL_INSTR_SEQUENCE_SIZE 100
432+
#define INITIAL_INSTR_SEQUENCE_LABELS_MAP_SIZE 10
433433

434434
static int
435435
instr_sequence_next_inst(instr_sequence *seq) {
436436
if (seq->s_instrs == NULL) {
437437
assert(seq->s_allocated == 0);
438438
assert(seq->s_used == 0);
439439
seq->s_instrs = (instruction *)PyObject_Calloc(
440-
INITIAL_INSTR_STREAM_SIZE, sizeof(instruction));
440+
INITIAL_INSTR_SEQUENCE_SIZE, sizeof(instruction));
441441
if (seq->s_instrs == NULL) {
442442
return ERROR;
443443
}
444-
seq->s_allocated = INITIAL_INSTR_STREAM_SIZE;
444+
seq->s_allocated = INITIAL_INSTR_SEQUENCE_SIZE;
445445
}
446446
if (seq->s_used == seq->s_allocated) {
447447
instruction *tmp = (instruction *)PyObject_Realloc(
@@ -470,7 +470,7 @@ instr_sequence_use_label(instr_sequence *seq, int lbl) {
470470
int *tmp = NULL;
471471
if (seq->s_labelmap == NULL) {
472472
old_size = 0;
473-
new_size = INITIAL_INSTR_STREAM_LABELS_MAP_SIZE;
473+
new_size = INITIAL_INSTR_SEQUENCE_LABELS_MAP_SIZE;
474474
if (new_size < 2 * lbl) {
475475
new_size = 2 * lbl;
476476
}
@@ -645,7 +645,7 @@ struct compiler {
645645
PyArena *c_arena; /* pointer to memory allocation arena */
646646
};
647647

648-
#define INSTR_STREAM(C) (&((C)->u->u_instr_sequence))
648+
#define INSTR_SEQUENCE(C) (&((C)->u->u_instr_sequence))
649649

650650

651651
typedef struct {
@@ -1513,7 +1513,7 @@ compiler_addop_load_const(struct compiler *c, location loc, PyObject *o)
15131513
if (arg < 0) {
15141514
return ERROR;
15151515
}
1516-
return codegen_addop_i(INSTR_STREAM(c), LOAD_CONST, arg, loc);
1516+
return codegen_addop_i(INSTR_SEQUENCE(c), LOAD_CONST, arg, loc);
15171517
}
15181518

15191519
static int
@@ -1524,7 +1524,7 @@ compiler_addop_o(struct compiler *c, location loc,
15241524
if (arg < 0) {
15251525
return ERROR;
15261526
}
1527-
return codegen_addop_i(INSTR_STREAM(c), opcode, arg, loc);
1527+
return codegen_addop_i(INSTR_SEQUENCE(c), opcode, arg, loc);
15281528
}
15291529

15301530
static int
@@ -1550,7 +1550,7 @@ compiler_addop_name(struct compiler *c, location loc,
15501550
arg <<= 1;
15511551
arg |= 1;
15521552
}
1553-
return codegen_addop_i(INSTR_STREAM(c), opcode, arg, loc);
1553+
return codegen_addop_i(INSTR_SEQUENCE(c), opcode, arg, loc);
15541554
}
15551555

15561556
/* Add an opcode with an integer argument */
@@ -1579,10 +1579,10 @@ codegen_addop_j(instr_sequence *seq, location loc,
15791579
}
15801580

15811581
#define ADDOP(C, LOC, OP) \
1582-
RETURN_IF_ERROR(codegen_addop_noarg(INSTR_STREAM(C), (OP), (LOC)))
1582+
RETURN_IF_ERROR(codegen_addop_noarg(INSTR_SEQUENCE(C), (OP), (LOC)))
15831583

15841584
#define ADDOP_IN_SCOPE(C, LOC, OP) { \
1585-
if (codegen_addop_noarg(INSTR_STREAM(C), (OP), (LOC)) < 0) { \
1585+
if (codegen_addop_noarg(INSTR_SEQUENCE(C), (OP), (LOC)) < 0) { \
15861586
compiler_exit_scope(C); \
15871587
return ERROR; \
15881588
} \
@@ -1617,10 +1617,10 @@ codegen_addop_j(instr_sequence *seq, location loc,
16171617
RETURN_IF_ERROR(compiler_addop_name((C), (LOC), (OP), (C)->u->u_ ## TYPE, (O)))
16181618

16191619
#define ADDOP_I(C, LOC, OP, O) \
1620-
RETURN_IF_ERROR(codegen_addop_i(INSTR_STREAM(C), (OP), (O), (LOC)))
1620+
RETURN_IF_ERROR(codegen_addop_i(INSTR_SEQUENCE(C), (OP), (O), (LOC)))
16211621

16221622
#define ADDOP_JUMP(C, LOC, OP, O) \
1623-
RETURN_IF_ERROR(codegen_addop_j(INSTR_STREAM(C), (LOC), (OP), (O)))
1623+
RETURN_IF_ERROR(codegen_addop_j(INSTR_SEQUENCE(C), (LOC), (OP), (O)))
16241624

16251625
#define ADDOP_COMPARE(C, LOC, CMP) \
16261626
RETURN_IF_ERROR(compiler_addcompare((C), (LOC), (cmpop_ty)(CMP)))
@@ -2545,7 +2545,7 @@ wrap_in_stopiteration_handler(struct compiler *c)
25452545
/* Insert SETUP_CLEANUP at start */
25462546
RETURN_IF_ERROR(
25472547
instr_sequence_insert_instruction(
2548-
INSTR_STREAM(c), 0,
2548+
INSTR_SEQUENCE(c), 0,
25492549
SETUP_CLEANUP, handler.id, NO_LOCATION));
25502550

25512551
ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None);
@@ -4235,7 +4235,7 @@ compiler_nameop(struct compiler *c, location loc,
42354235
if (op == LOAD_GLOBAL) {
42364236
arg <<= 1;
42374237
}
4238-
return codegen_addop_i(INSTR_STREAM(c), op, arg, loc);
4238+
return codegen_addop_i(INSTR_SEQUENCE(c), op, arg, loc);
42394239
}
42404240

42414241
static int
@@ -6254,7 +6254,7 @@ emit_and_reset_fail_pop(struct compiler *c, location loc,
62546254
}
62556255
while (--pc->fail_pop_size) {
62566256
USE_LABEL(c, pc->fail_pop[pc->fail_pop_size]);
6257-
if (codegen_addop_noarg(INSTR_STREAM(c), POP_TOP, loc) < 0) {
6257+
if (codegen_addop_noarg(INSTR_SEQUENCE(c), POP_TOP, loc) < 0) {
62586258
pc->fail_pop_size = 0;
62596259
PyObject_Free(pc->fail_pop);
62606260
pc->fail_pop = NULL;
@@ -6694,7 +6694,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc)
66946694
pc->fail_pop = NULL;
66956695
pc->fail_pop_size = 0;
66966696
pc->on_top = 0;
6697-
if (codegen_addop_i(INSTR_STREAM(c), COPY, 1, LOC(alt)) < 0 ||
6697+
if (codegen_addop_i(INSTR_SEQUENCE(c), COPY, 1, LOC(alt)) < 0 ||
66986698
compiler_pattern(c, alt, pc) < 0) {
66996699
goto error;
67006700
}
@@ -6757,7 +6757,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc)
67576757
}
67586758
}
67596759
assert(control);
6760-
if (codegen_addop_j(INSTR_STREAM(c), LOC(alt), JUMP, end) < 0 ||
6760+
if (codegen_addop_j(INSTR_SEQUENCE(c), LOC(alt), JUMP, end) < 0 ||
67616761
emit_and_reset_fail_pop(c, LOC(alt), pc) < 0)
67626762
{
67636763
goto error;
@@ -6769,7 +6769,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc)
67696769
// Need to NULL this for the PyObject_Free call in the error block.
67706770
old_pc.fail_pop = NULL;
67716771
// No match. Pop the remaining copy of the subject and fail:
6772-
if (codegen_addop_noarg(INSTR_STREAM(c), POP_TOP, LOC(p)) < 0 ||
6772+
if (codegen_addop_noarg(INSTR_SEQUENCE(c), POP_TOP, LOC(p)) < 0 ||
67736773
jump_to_fail_pop(c, LOC(p), pc, JUMP) < 0) {
67746774
goto error;
67756775
}
@@ -8719,7 +8719,7 @@ assemble(struct compiler *c, int addNone)
87198719
}
87208720

87218721
/** Preprocessing **/
8722-
if (instr_sequence_to_cfg(INSTR_STREAM(c), g) < 0) {
8722+
if (instr_sequence_to_cfg(INSTR_SEQUENCE(c), g) < 0) {
87238723
goto error;
87248724
}
87258725
assert(cfg_builder_check(g));
@@ -9996,7 +9996,7 @@ _PyCompile_CodeGen(PyObject *ast, PyObject *filename, PyCompilerFlags *pflags,
99969996
}
99979997

99989998
cfg_builder g;
9999-
if (instr_sequence_to_cfg(INSTR_STREAM(c), &g) < 0) {
9999+
if (instr_sequence_to_cfg(INSTR_SEQUENCE(c), &g) < 0) {
1000010000
goto finally;
1000110001
}
1000210002
if (translate_jump_labels_to_targets(g.g_entryblock) < 0) {

0 commit comments

Comments
 (0)