diff --git a/Python/compile.c b/Python/compile.c index 69de0ec2996e009..c305e93f2db6f79 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -295,51 +295,50 @@ static int codegen_addop_i(instr_sequence *seq, int opcode, Py_ssize_t oparg, lo static void compiler_free(struct compiler *); static int compiler_error(struct compiler *, location loc, const char *, ...); static int compiler_warn(struct compiler *, location loc, const char *, ...); -static int compiler_nameop(struct compiler *, location, identifier, expr_context_ty); +static int codegen_nameop(struct compiler *, location, identifier, expr_context_ty); static PyCodeObject *compiler_mod(struct compiler *, mod_ty); -static int compiler_visit_stmt(struct compiler *, stmt_ty); -static int compiler_visit_keyword(struct compiler *, keyword_ty); -static int compiler_visit_expr(struct compiler *, expr_ty); -static int compiler_augassign(struct compiler *, stmt_ty); -static int compiler_annassign(struct compiler *, stmt_ty); -static int compiler_subscript(struct compiler *, expr_ty); -static int compiler_slice(struct compiler *, expr_ty); +static int codegen_visit_stmt(struct compiler *, stmt_ty); +static int codegen_visit_keyword(struct compiler *, keyword_ty); +static int codegen_visit_expr(struct compiler *, expr_ty); +static int codegen_augassign(struct compiler *, stmt_ty); +static int codegen_annassign(struct compiler *, stmt_ty); +static int codegen_subscript(struct compiler *, expr_ty); +static int codegen_slice(struct compiler *, expr_ty); static bool are_all_items_const(asdl_expr_seq *, Py_ssize_t, Py_ssize_t); -static int compiler_with(struct compiler *, stmt_ty, int); -static int compiler_async_with(struct compiler *, stmt_ty, int); -static int compiler_async_for(struct compiler *, stmt_ty); -static int compiler_call_simple_kw_helper(struct compiler *c, - location loc, - asdl_keyword_seq *keywords, - Py_ssize_t nkwelts); -static int compiler_call_helper(struct compiler *c, location loc, - int n, asdl_expr_seq *args, - asdl_keyword_seq *keywords); -static int compiler_try_except(struct compiler *, stmt_ty); -static int compiler_try_star_except(struct compiler *, stmt_ty); -static int compiler_set_qualname(struct compiler *); - -static int compiler_sync_comprehension_generator( +static int codegen_with(struct compiler *, stmt_ty, int); +static int codegen_async_with(struct compiler *, stmt_ty, int); +static int codegen_async_for(struct compiler *, stmt_ty); +static int codegen_call_simple_kw_helper(struct compiler *c, + location loc, + asdl_keyword_seq *keywords, + Py_ssize_t nkwelts); +static int codegen_call_helper(struct compiler *c, location loc, + int n, asdl_expr_seq *args, + asdl_keyword_seq *keywords); +static int codegen_try_except(struct compiler *, stmt_ty); +static int codegen_try_star_except(struct compiler *, stmt_ty); + +static int codegen_sync_comprehension_generator( struct compiler *c, location loc, asdl_comprehension_seq *generators, int gen_index, int depth, expr_ty elt, expr_ty val, int type, int iter_on_stack); -static int compiler_async_comprehension_generator( +static int codegen_async_comprehension_generator( struct compiler *c, location loc, asdl_comprehension_seq *generators, int gen_index, int depth, expr_ty elt, expr_ty val, int type, int iter_on_stack); -static int compiler_pattern(struct compiler *, pattern_ty, pattern_context *); -static int compiler_match(struct compiler *, stmt_ty); -static int compiler_pattern_subpattern(struct compiler *, +static int codegen_pattern(struct compiler *, pattern_ty, pattern_context *); +static int codegen_match(struct compiler *, stmt_ty); +static int codegen_pattern_subpattern(struct compiler *, pattern_ty, pattern_context *); static int compiler_make_closure(struct compiler *c, location loc, PyCodeObject *co, Py_ssize_t flags); @@ -579,7 +578,7 @@ get_class_compiler_unit(struct compiler *c) } static int -compiler_set_qualname(struct compiler *c) +codegen_set_qualname(struct compiler *c) { Py_ssize_t stack_size; struct compiler_unit *u = c->u; @@ -1010,7 +1009,7 @@ codegen_addop_j(instr_sequence *seq, location loc, RETURN_IF_ERROR(codegen_addop_j(INSTR_SEQUENCE(C), (LOC), (OP), (O))) #define ADDOP_COMPARE(C, LOC, CMP) \ - RETURN_IF_ERROR(compiler_addcompare((C), (LOC), (cmpop_ty)(CMP))) + RETURN_IF_ERROR(codegen_addcompare((C), (LOC), (cmpop_ty)(CMP))) #define ADDOP_BINARY(C, LOC, BINOP) \ RETURN_IF_ERROR(addop_binary((C), (LOC), (BINOP), false)) @@ -1019,10 +1018,10 @@ codegen_addop_j(instr_sequence *seq, location loc, RETURN_IF_ERROR(addop_binary((C), (LOC), (BINOP), true)) #define ADD_YIELD_FROM(C, LOC, await) \ - RETURN_IF_ERROR(compiler_add_yield_from((C), (LOC), (await))) + RETURN_IF_ERROR(codegen_add_yield_from((C), (LOC), (await))) #define POP_EXCEPT_AND_RERAISE(C, LOC) \ - RETURN_IF_ERROR(compiler_pop_except_and_reraise((C), (LOC))) + RETURN_IF_ERROR(codegen_pop_except_and_reraise((C), (LOC))) #define ADDOP_YIELD(C, LOC) \ RETURN_IF_ERROR(addop_yield((C), (LOC))) @@ -1032,17 +1031,17 @@ codegen_addop_j(instr_sequence *seq, location loc, */ #define VISIT(C, TYPE, V) \ - RETURN_IF_ERROR(compiler_visit_ ## TYPE((C), (V))); + RETURN_IF_ERROR(codegen_visit_ ## TYPE((C), (V))); #define VISIT_IN_SCOPE(C, TYPE, V) \ - RETURN_IF_ERROR_IN_SCOPE((C), compiler_visit_ ## TYPE((C), (V))) + RETURN_IF_ERROR_IN_SCOPE((C), codegen_visit_ ## TYPE((C), (V))) #define VISIT_SEQ(C, TYPE, SEQ) { \ int _i; \ asdl_ ## TYPE ## _seq *seq = (SEQ); /* avoid variable capture */ \ for (_i = 0; _i < asdl_seq_LEN(seq); _i++) { \ TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, _i); \ - RETURN_IF_ERROR(compiler_visit_ ## TYPE((C), elt)); \ + RETURN_IF_ERROR(codegen_visit_ ## TYPE((C), elt)); \ } \ } @@ -1051,7 +1050,7 @@ codegen_addop_j(instr_sequence *seq, location loc, asdl_ ## TYPE ## _seq *seq = (SEQ); /* avoid variable capture */ \ for (_i = 0; _i < asdl_seq_LEN(seq); _i++) { \ TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, _i); \ - if (compiler_visit_ ## TYPE((C), elt) < 0) { \ + if (codegen_visit_ ## TYPE((C), elt) < 0) { \ compiler_exit_scope(C); \ return ERROR; \ } \ @@ -1174,7 +1173,7 @@ compiler_enter_scope(struct compiler *c, identifier name, loc.lineno = 0; } else { - RETURN_IF_ERROR(compiler_set_qualname(c)); + RETURN_IF_ERROR(codegen_set_qualname(c)); } ADDOP_I(c, loc, RESUME, RESUME_AT_FUNC_START); @@ -1256,7 +1255,7 @@ compiler_pop_fblock(struct compiler *c, enum fblocktype t, jump_target_label blo } static int -compiler_call_exit_with_nones(struct compiler *c, location loc) +codegen_call_exit_with_nones(struct compiler *c, location loc) { ADDOP_LOAD_CONST(c, loc, Py_None); ADDOP_LOAD_CONST(c, loc, Py_None); @@ -1266,7 +1265,7 @@ compiler_call_exit_with_nones(struct compiler *c, location loc) } static int -compiler_add_yield_from(struct compiler *c, location loc, int await) +codegen_add_yield_from(struct compiler *c, location loc, int await) { NEW_JUMP_TARGET_LABEL(c, send); NEW_JUMP_TARGET_LABEL(c, fail); @@ -1291,7 +1290,7 @@ compiler_add_yield_from(struct compiler *c, location loc, int await) } static int -compiler_pop_except_and_reraise(struct compiler *c, location loc) +codegen_pop_except_and_reraise(struct compiler *c, location loc) { /* Stack contents * [exc_info, lasti, exc] COPY 3 @@ -1373,7 +1372,7 @@ compiler_unwind_fblock(struct compiler *c, location *ploc, ADDOP_I(c, *ploc, SWAP, 3); ADDOP_I(c, *ploc, SWAP, 2); } - RETURN_IF_ERROR(compiler_call_exit_with_nones(c, *ploc)); + RETURN_IF_ERROR(codegen_call_exit_with_nones(c, *ploc)); if (info->fb_type == ASYNC_WITH) { ADDOP_I(c, *ploc, GET_AWAITABLE, 2); ADDOP_LOAD_CONST(c, *ploc, Py_None); @@ -1397,8 +1396,8 @@ compiler_unwind_fblock(struct compiler *c, location *ploc, ADDOP(c, *ploc, POP_EXCEPT); if (info->fb_datum) { ADDOP_LOAD_CONST(c, *ploc, Py_None); - RETURN_IF_ERROR(compiler_nameop(c, *ploc, info->fb_datum, Store)); - RETURN_IF_ERROR(compiler_nameop(c, *ploc, info->fb_datum, Del)); + RETURN_IF_ERROR(codegen_nameop(c, *ploc, info->fb_datum, Store)); + RETURN_IF_ERROR(codegen_nameop(c, *ploc, info->fb_datum, Del)); } return SUCCESS; } @@ -1462,8 +1461,8 @@ compiler_setup_annotations_scope(struct compiler *c, location loc, } static int -compiler_leave_annotations_scope(struct compiler *c, location loc, - Py_ssize_t annotations_len) +codegen_leave_annotations_scope(struct compiler *c, location loc, + Py_ssize_t annotations_len) { ADDOP_I(c, loc, BUILD_MAP, annotations_len); ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); @@ -1484,7 +1483,7 @@ compiler_leave_annotations_scope(struct compiler *c, location loc, and for annotations. */ static int -compiler_body(struct compiler *c, location loc, asdl_stmt_seq *stmts) +codegen_body(struct compiler *c, location loc, asdl_stmt_seq *stmts) { /* Set current line number to the line number of first statement. @@ -1520,7 +1519,7 @@ compiler_body(struct compiler *c, location loc, asdl_stmt_seq *stmts) location loc = LOC(st->v.Expr.value); ADDOP_LOAD_CONST(c, loc, cleandoc); Py_DECREF(cleandoc); - RETURN_IF_ERROR(compiler_nameop(c, NO_LOCATION, &_Py_ID(__doc__), Store)); + RETURN_IF_ERROR(codegen_nameop(c, NO_LOCATION, &_Py_ID(__doc__), Store)); } } } @@ -1562,10 +1561,10 @@ compiler_body(struct compiler *c, location loc, asdl_stmt_seq *stmts) Py_DECREF(deferred_anno); RETURN_IF_ERROR( - compiler_leave_annotations_scope(c, loc, annotations_len) + codegen_leave_annotations_scope(c, loc, annotations_len) ); RETURN_IF_ERROR( - compiler_nameop(c, loc, &_Py_ID(__annotate__), Store) + codegen_nameop(c, loc, &_Py_ID(__annotate__), Store) ); } return SUCCESS; @@ -1577,13 +1576,13 @@ compiler_codegen(struct compiler *c, mod_ty mod) location loc = LOCATION(1, 1, 0, 0); switch (mod->kind) { case Module_kind: - if (compiler_body(c, loc, mod->v.Module.body) < 0) { + if (codegen_body(c, loc, mod->v.Module.body) < 0) { return ERROR; } break; case Interactive_kind: c->c_interactive = 1; - if (compiler_body(c, loc, mod->v.Interactive.body) < 0) { + if (codegen_body(c, loc, mod->v.Interactive.body) < 0) { return ERROR; } break; @@ -1737,7 +1736,7 @@ compiler_make_closure(struct compiler *c, location loc, } static int -compiler_decorators(struct compiler *c, asdl_expr_seq* decos) +codegen_decorators(struct compiler *c, asdl_expr_seq* decos) { if (!decos) { return SUCCESS; @@ -1750,7 +1749,7 @@ compiler_decorators(struct compiler *c, asdl_expr_seq* decos) } static int -compiler_apply_decorators(struct compiler *c, asdl_expr_seq* decos) +codegen_apply_decorators(struct compiler *c, asdl_expr_seq* decos) { if (!decos) { return SUCCESS; @@ -1764,8 +1763,8 @@ compiler_apply_decorators(struct compiler *c, asdl_expr_seq* decos) } static int -compiler_kwonlydefaults(struct compiler *c, location loc, - asdl_arg_seq *kwonlyargs, asdl_expr_seq *kw_defaults) +codegen_kwonlydefaults(struct compiler *c, location loc, + asdl_arg_seq *kwonlyargs, asdl_expr_seq *kw_defaults) { /* Push a dict of keyword-only default values. @@ -1797,7 +1796,7 @@ compiler_kwonlydefaults(struct compiler *c, location loc, goto error; } } - if (compiler_visit_expr(c, default_) < 0) { + if (codegen_visit_expr(c, default_) < 0) { goto error; } } @@ -1821,7 +1820,7 @@ compiler_kwonlydefaults(struct compiler *c, location loc, } static int -compiler_visit_annexpr(struct compiler *c, expr_ty annotation) +codegen_visit_annexpr(struct compiler *c, expr_ty annotation) { location loc = LOC(annotation); ADDOP_LOAD_CONST_NEW(c, loc, _PyAST_ExprAsUnicode(annotation)); @@ -1829,7 +1828,7 @@ compiler_visit_annexpr(struct compiler *c, expr_ty annotation) } static int -compiler_argannotation(struct compiler *c, identifier id, +codegen_argannotation(struct compiler *c, identifier id, expr_ty annotation, Py_ssize_t *annotations_len, location loc) { if (!annotation) { @@ -1863,14 +1862,14 @@ compiler_argannotation(struct compiler *c, identifier id, } static int -compiler_argannotations(struct compiler *c, asdl_arg_seq* args, +codegen_argannotations(struct compiler *c, asdl_arg_seq* args, Py_ssize_t *annotations_len, location loc) { int i; for (i = 0; i < asdl_seq_LEN(args); i++) { arg_ty arg = (arg_ty)asdl_seq_GET(args, i); RETURN_IF_ERROR( - compiler_argannotation( + codegen_argannotation( c, arg->arg, arg->annotation, @@ -1881,40 +1880,40 @@ compiler_argannotations(struct compiler *c, asdl_arg_seq* args, } static int -compiler_annotations_in_scope(struct compiler *c, location loc, +codegen_annotations_in_scope(struct compiler *c, location loc, arguments_ty args, expr_ty returns, Py_ssize_t *annotations_len) { RETURN_IF_ERROR( - compiler_argannotations(c, args->args, annotations_len, loc)); + codegen_argannotations(c, args->args, annotations_len, loc)); RETURN_IF_ERROR( - compiler_argannotations(c, args->posonlyargs, annotations_len, loc)); + codegen_argannotations(c, args->posonlyargs, annotations_len, loc)); if (args->vararg && args->vararg->annotation) { RETURN_IF_ERROR( - compiler_argannotation(c, args->vararg->arg, - args->vararg->annotation, annotations_len, loc)); + codegen_argannotation(c, args->vararg->arg, + args->vararg->annotation, annotations_len, loc)); } RETURN_IF_ERROR( - compiler_argannotations(c, args->kwonlyargs, annotations_len, loc)); + codegen_argannotations(c, args->kwonlyargs, annotations_len, loc)); if (args->kwarg && args->kwarg->annotation) { RETURN_IF_ERROR( - compiler_argannotation(c, args->kwarg->arg, - args->kwarg->annotation, annotations_len, loc)); + codegen_argannotation(c, args->kwarg->arg, + args->kwarg->annotation, annotations_len, loc)); } RETURN_IF_ERROR( - compiler_argannotation(c, &_Py_ID(return), returns, annotations_len, loc)); + codegen_argannotation(c, &_Py_ID(return), returns, annotations_len, loc)); return 0; } static int -compiler_annotations(struct compiler *c, location loc, - arguments_ty args, expr_ty returns) +codegen_annotations(struct compiler *c, location loc, + arguments_ty args, expr_ty returns) { /* Push arg annotation names and values. The expressions are evaluated separately from the rest of the source code. @@ -1939,7 +1938,7 @@ compiler_annotations(struct compiler *c, location loc, } Py_DECREF(ste); - if (compiler_annotations_in_scope(c, loc, args, returns, &annotations_len) < 0) { + if (codegen_annotations_in_scope(c, loc, args, returns, &annotations_len) < 0) { if (annotations_used) { compiler_exit_scope(c); } @@ -1948,7 +1947,7 @@ compiler_annotations(struct compiler *c, location loc, if (annotations_used) { RETURN_IF_ERROR( - compiler_leave_annotations_scope(c, loc, annotations_len) + codegen_leave_annotations_scope(c, loc, annotations_len) ); return MAKE_FUNCTION_ANNOTATE; } @@ -1957,8 +1956,8 @@ compiler_annotations(struct compiler *c, location loc, } static int -compiler_defaults(struct compiler *c, arguments_ty args, - location loc) +codegen_defaults(struct compiler *c, arguments_ty args, + location loc) { VISIT_SEQ(c, expr, args->defaults); ADDOP_I(c, loc, BUILD_TUPLE, asdl_seq_LEN(args->defaults)); @@ -1966,18 +1965,18 @@ compiler_defaults(struct compiler *c, arguments_ty args, } static Py_ssize_t -compiler_default_arguments(struct compiler *c, location loc, +codegen_default_arguments(struct compiler *c, location loc, arguments_ty args) { Py_ssize_t funcflags = 0; if (args->defaults && asdl_seq_LEN(args->defaults) > 0) { - RETURN_IF_ERROR(compiler_defaults(c, args, loc)); + RETURN_IF_ERROR(codegen_defaults(c, args, loc)); funcflags |= MAKE_FUNCTION_DEFAULTS; } if (args->kwonlyargs) { - int res = compiler_kwonlydefaults(c, loc, - args->kwonlyargs, - args->kw_defaults); + int res = codegen_kwonlydefaults(c, loc, + args->kwonlyargs, + args->kw_defaults); RETURN_IF_ERROR(res); if (res > 0) { funcflags |= MAKE_FUNCTION_KWDEFAULTS; @@ -2055,9 +2054,9 @@ wrap_in_stopiteration_handler(struct compiler *c) } static int -compiler_type_param_bound_or_default(struct compiler *c, expr_ty e, - identifier name, void *key, - bool allow_starred) +codegen_type_param_bound_or_default(struct compiler *c, expr_ty e, + identifier name, void *key, + bool allow_starred) { if (compiler_enter_scope(c, name, COMPILER_SCOPE_ANNOTATIONS, key, e->lineno) == -1) { @@ -2085,7 +2084,7 @@ compiler_type_param_bound_or_default(struct compiler *c, expr_ty e, } static int -compiler_type_params(struct compiler *c, asdl_type_param_seq *type_params) +codegen_type_params(struct compiler *c, asdl_type_param_seq *type_params) { if (!type_params) { return SUCCESS; @@ -2101,7 +2100,7 @@ compiler_type_params(struct compiler *c, asdl_type_param_seq *type_params) ADDOP_LOAD_CONST(c, loc, typeparam->v.TypeVar.name); if (typeparam->v.TypeVar.bound) { expr_ty bound = typeparam->v.TypeVar.bound; - if (compiler_type_param_bound_or_default(c, bound, typeparam->v.TypeVar.name, + if (codegen_type_param_bound_or_default(c, bound, typeparam->v.TypeVar.name, (void *)typeparam, false) < 0) { return ERROR; } @@ -2117,7 +2116,7 @@ compiler_type_params(struct compiler *c, asdl_type_param_seq *type_params) if (typeparam->v.TypeVar.default_value) { seen_default = true; expr_ty default_ = typeparam->v.TypeVar.default_value; - if (compiler_type_param_bound_or_default(c, default_, typeparam->v.TypeVar.name, + if (codegen_type_param_bound_or_default(c, default_, typeparam->v.TypeVar.name, (void *)((uintptr_t)typeparam + 1), false) < 0) { return ERROR; } @@ -2129,15 +2128,15 @@ compiler_type_params(struct compiler *c, asdl_type_param_seq *type_params) typeparam->v.TypeVar.name); } ADDOP_I(c, loc, COPY, 1); - RETURN_IF_ERROR(compiler_nameop(c, loc, typeparam->v.TypeVar.name, Store)); + RETURN_IF_ERROR(codegen_nameop(c, loc, typeparam->v.TypeVar.name, Store)); break; case TypeVarTuple_kind: ADDOP_LOAD_CONST(c, loc, typeparam->v.TypeVarTuple.name); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVARTUPLE); if (typeparam->v.TypeVarTuple.default_value) { expr_ty default_ = typeparam->v.TypeVarTuple.default_value; - if (compiler_type_param_bound_or_default(c, default_, typeparam->v.TypeVarTuple.name, - (void *)typeparam, true) < 0) { + if (codegen_type_param_bound_or_default(c, default_, typeparam->v.TypeVarTuple.name, + (void *)typeparam, true) < 0) { return ERROR; } ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_TYPEPARAM_DEFAULT); @@ -2149,15 +2148,15 @@ compiler_type_params(struct compiler *c, asdl_type_param_seq *type_params) typeparam->v.TypeVarTuple.name); } ADDOP_I(c, loc, COPY, 1); - RETURN_IF_ERROR(compiler_nameop(c, loc, typeparam->v.TypeVarTuple.name, Store)); + RETURN_IF_ERROR(codegen_nameop(c, loc, typeparam->v.TypeVarTuple.name, Store)); break; case ParamSpec_kind: ADDOP_LOAD_CONST(c, loc, typeparam->v.ParamSpec.name); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_PARAMSPEC); if (typeparam->v.ParamSpec.default_value) { expr_ty default_ = typeparam->v.ParamSpec.default_value; - if (compiler_type_param_bound_or_default(c, default_, typeparam->v.ParamSpec.name, - (void *)typeparam, false) < 0) { + if (codegen_type_param_bound_or_default(c, default_, typeparam->v.ParamSpec.name, + (void *)typeparam, false) < 0) { return ERROR; } ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_TYPEPARAM_DEFAULT); @@ -2169,7 +2168,7 @@ compiler_type_params(struct compiler *c, asdl_type_param_seq *type_params) typeparam->v.ParamSpec.name); } ADDOP_I(c, loc, COPY, 1); - RETURN_IF_ERROR(compiler_nameop(c, loc, typeparam->v.ParamSpec.name, Store)); + RETURN_IF_ERROR(codegen_nameop(c, loc, typeparam->v.ParamSpec.name, Store)); break; } } @@ -2178,8 +2177,8 @@ compiler_type_params(struct compiler *c, asdl_type_param_seq *type_params) } static int -compiler_function_body(struct compiler *c, stmt_ty s, int is_async, Py_ssize_t funcflags, - int firstlineno) +codegen_function_body(struct compiler *c, stmt_ty s, int is_async, Py_ssize_t funcflags, + int firstlineno) { arguments_ty args; identifier name; @@ -2270,7 +2269,7 @@ compiler_function_body(struct compiler *c, stmt_ty s, int is_async, Py_ssize_t f } static int -compiler_function(struct compiler *c, stmt_ty s, int is_async) +codegen_function(struct compiler *c, stmt_ty s, int is_async) { arguments_ty args; expr_ty returns; @@ -2299,7 +2298,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } RETURN_IF_ERROR(compiler_check_debug_args(c, args)); - RETURN_IF_ERROR(compiler_decorators(c, decos)); + RETURN_IF_ERROR(codegen_decorators(c, decos)); firstlineno = s->lineno; if (asdl_seq_LEN(decos)) { @@ -2310,7 +2309,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) int is_generic = asdl_seq_LEN(type_params) > 0; - funcflags = compiler_default_arguments(c, loc, args); + funcflags = codegen_default_arguments(c, loc, args); if (funcflags == -1) { return ERROR; } @@ -2337,13 +2336,13 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(type_params_name); - RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, type_params)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_type_params(c, type_params)); for (int i = 0; i < num_typeparam_args; i++) { RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, i, loc)); } } - int annotations_flag = compiler_annotations(c, loc, args, returns); + int annotations_flag = codegen_annotations(c, loc, args, returns); if (annotations_flag < 0) { if (is_generic) { compiler_exit_scope(c); @@ -2352,7 +2351,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } funcflags |= annotations_flag; - if (compiler_function_body(c, s, is_async, funcflags, firstlineno) < 0) { + if (codegen_function_body(c, s, is_async, funcflags, firstlineno) < 0) { if (is_generic) { compiler_exit_scope(c); } @@ -2386,21 +2385,21 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } } - RETURN_IF_ERROR(compiler_apply_decorators(c, decos)); - return compiler_nameop(c, loc, name, Store); + RETURN_IF_ERROR(codegen_apply_decorators(c, decos)); + return codegen_nameop(c, loc, name, Store); } static int -compiler_set_type_params_in_class(struct compiler *c, location loc) +codegen_set_type_params_in_class(struct compiler *c, location loc) { _Py_DECLARE_STR(type_params, ".type_params"); - RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); - RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_ID(__type_params__), Store)); + RETURN_IF_ERROR(codegen_nameop(c, loc, &_Py_STR(type_params), Load)); + RETURN_IF_ERROR(codegen_nameop(c, loc, &_Py_ID(__type_params__), Store)); return 1; } static int -compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) +codegen_class_body(struct compiler *c, stmt_ty s, int firstlineno) { /* ultimately generate code for: = __build_class__(, , *, **) @@ -2422,29 +2421,29 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) /* use the class name for name mangling */ Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name)); /* load (global) __name__ ... */ - if (compiler_nameop(c, loc, &_Py_ID(__name__), Load) < 0) { + if (codegen_nameop(c, loc, &_Py_ID(__name__), Load) < 0) { compiler_exit_scope(c); return ERROR; } /* ... and store it as __module__ */ - if (compiler_nameop(c, loc, &_Py_ID(__module__), Store) < 0) { + if (codegen_nameop(c, loc, &_Py_ID(__module__), Store) < 0) { compiler_exit_scope(c); return ERROR; } assert(c->u->u_metadata.u_qualname); ADDOP_LOAD_CONST(c, loc, c->u->u_metadata.u_qualname); - if (compiler_nameop(c, loc, &_Py_ID(__qualname__), Store) < 0) { + if (codegen_nameop(c, loc, &_Py_ID(__qualname__), Store) < 0) { compiler_exit_scope(c); return ERROR; } ADDOP_LOAD_CONST_NEW(c, loc, PyLong_FromLong(c->u->u_metadata.u_firstlineno)); - if (compiler_nameop(c, loc, &_Py_ID(__firstlineno__), Store) < 0) { + if (codegen_nameop(c, loc, &_Py_ID(__firstlineno__), Store) < 0) { compiler_exit_scope(c); return ERROR; } asdl_type_param_seq *type_params = s->v.ClassDef.type_params; if (asdl_seq_LEN(type_params) > 0) { - if (!compiler_set_type_params_in_class(c, loc)) { + if (!codegen_set_type_params_in_class(c, loc)) { compiler_exit_scope(c); return ERROR; } @@ -2452,8 +2451,8 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) if (c->u->u_ste->ste_needs_classdict) { ADDOP(c, loc, LOAD_LOCALS); - // We can't use compiler_nameop here because we need to generate a - // STORE_DEREF in a class namespace, and compiler_nameop() won't do + // We can't use codegen_nameop here because we need to generate a + // STORE_DEREF in a class namespace, and codegen_nameop() won't do // that by default. PyObject *cellvars = c->u->u_metadata.u_cellvars; if (compiler_addop_o(c->u, loc, STORE_DEREF, cellvars, @@ -2463,7 +2462,7 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) } } /* compile the body proper */ - if (compiler_body(c, loc, s->v.ClassDef.body) < 0) { + if (codegen_body(c, loc, s->v.ClassDef.body) < 0) { compiler_exit_scope(c); return ERROR; } @@ -2475,7 +2474,7 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) } ADDOP_LOAD_CONST(c, NO_LOCATION, static_attributes); Py_CLEAR(static_attributes); - if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__static_attributes__), Store) < 0) { + if (codegen_nameop(c, NO_LOCATION, &_Py_ID(__static_attributes__), Store) < 0) { compiler_exit_scope(c); return ERROR; } @@ -2489,7 +2488,7 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) return ERROR; } ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); - if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__classdictcell__), Store) < 0) { + if (codegen_nameop(c, NO_LOCATION, &_Py_ID(__classdictcell__), Store) < 0) { compiler_exit_scope(c); return ERROR; } @@ -2504,7 +2503,7 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) } ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); ADDOP_I(c, NO_LOCATION, COPY, 1); - if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__classcell__), Store) < 0) { + if (codegen_nameop(c, NO_LOCATION, &_Py_ID(__classcell__), Store) < 0) { compiler_exit_scope(c); return ERROR; } @@ -2545,11 +2544,11 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) } static int -compiler_class(struct compiler *c, stmt_ty s) +codegen_class(struct compiler *c, stmt_ty s) { asdl_expr_seq *decos = s->v.ClassDef.decorator_list; - RETURN_IF_ERROR(compiler_decorators(c, decos)); + RETURN_IF_ERROR(codegen_decorators(c, decos)); int firstlineno = s->lineno; if (asdl_seq_LEN(decos)) { @@ -2572,12 +2571,12 @@ compiler_class(struct compiler *c, stmt_ty s) } Py_DECREF(type_params_name); Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name)); - RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, type_params)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_type_params(c, type_params)); _Py_DECLARE_STR(type_params, ".type_params"); - RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Store)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_STR(type_params), Store)); } - if (compiler_class_body(c, s, firstlineno) < 0) { + if (codegen_class_body(c, s, firstlineno) < 0) { if (is_generic) { compiler_exit_scope(c); } @@ -2589,11 +2588,11 @@ compiler_class(struct compiler *c, stmt_ty s) if (is_generic) { _Py_DECLARE_STR(type_params, ".type_params"); _Py_DECLARE_STR(generic_base, ".generic_base"); - RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Load)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_STR(type_params), Load)); RETURN_IF_ERROR_IN_SCOPE( c, codegen_addop_i(INSTR_SEQUENCE(c), CALL_INTRINSIC_1, INTRINSIC_SUBSCRIPT_GENERIC, loc) ) - RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(generic_base), Store)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_nameop(c, loc, &_Py_STR(generic_base), Store)); Py_ssize_t original_len = asdl_seq_LEN(s->v.ClassDef.bases); asdl_expr_seq *bases = _Py_asdl_expr_seq_new( @@ -2614,9 +2613,9 @@ compiler_class(struct compiler *c, stmt_ty s) return ERROR; } asdl_seq_SET(bases, original_len, name_node); - RETURN_IF_ERROR_IN_SCOPE(c, compiler_call_helper(c, loc, 2, - bases, - s->v.ClassDef.keywords)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_call_helper(c, loc, 2, + bases, + s->v.ClassDef.keywords)); PyCodeObject *co = optimize_and_assemble(c, 0); @@ -2632,21 +2631,21 @@ compiler_class(struct compiler *c, stmt_ty s) ADDOP(c, loc, PUSH_NULL); ADDOP_I(c, loc, CALL, 0); } else { - RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, + RETURN_IF_ERROR(codegen_call_helper(c, loc, 2, s->v.ClassDef.bases, s->v.ClassDef.keywords)); } /* 6. apply decorators */ - RETURN_IF_ERROR(compiler_apply_decorators(c, decos)); + RETURN_IF_ERROR(codegen_apply_decorators(c, decos)); /* 7. store into */ - RETURN_IF_ERROR(compiler_nameop(c, loc, s->v.ClassDef.name, Store)); + RETURN_IF_ERROR(codegen_nameop(c, loc, s->v.ClassDef.name, Store)); return SUCCESS; } static int -compiler_typealias_body(struct compiler *c, stmt_ty s) +codegen_typealias_body(struct compiler *c, stmt_ty s) { location loc = LOC(s); PyObject *name = s->v.TypeAlias.name->v.Name.id; @@ -2673,7 +2672,7 @@ compiler_typealias_body(struct compiler *c, stmt_ty s) } static int -compiler_typealias(struct compiler *c, stmt_ty s) +codegen_typealias(struct compiler *c, stmt_ty s) { location loc = LOC(s); asdl_type_param_seq *type_params = s->v.TypeAlias.type_params; @@ -2694,14 +2693,14 @@ compiler_typealias(struct compiler *c, stmt_ty s) RETURN_IF_ERROR_IN_SCOPE( c, compiler_addop_load_const(c->c_const_cache, c->u, loc, name) ); - RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, type_params)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_type_params(c, type_params)); } else { ADDOP_LOAD_CONST(c, loc, name); ADDOP_LOAD_CONST(c, loc, Py_None); } - if (compiler_typealias_body(c, s) < 0) { + if (codegen_typealias_body(c, s) < 0) { if (is_generic) { compiler_exit_scope(c); } @@ -2722,7 +2721,7 @@ compiler_typealias(struct compiler *c, stmt_ty s) ADDOP(c, loc, PUSH_NULL); ADDOP_I(c, loc, CALL, 0); } - RETURN_IF_ERROR(compiler_nameop(c, loc, name, Store)); + RETURN_IF_ERROR(codegen_nameop(c, loc, name, Store)); return SUCCESS; } @@ -2774,8 +2773,8 @@ check_compare(struct compiler *c, expr_ty e) return SUCCESS; } -static int compiler_addcompare(struct compiler *c, location loc, - cmpop_ty op) +static int codegen_addcompare(struct compiler *c, location loc, + cmpop_ty op) { int cmp; switch (op) { @@ -2823,13 +2822,13 @@ static int compiler_addcompare(struct compiler *c, location loc, static int -compiler_jump_if(struct compiler *c, location loc, +codegen_jump_if(struct compiler *c, location loc, expr_ty e, jump_target_label next, int cond) { switch (e->kind) { case UnaryOp_kind: if (e->v.UnaryOp.op == Not) { - return compiler_jump_if(c, loc, e->v.UnaryOp.operand, next, !cond); + return codegen_jump_if(c, loc, e->v.UnaryOp.operand, next, !cond); } /* fallback to general implementation */ break; @@ -2845,10 +2844,10 @@ compiler_jump_if(struct compiler *c, location loc, } for (i = 0; i < n; ++i) { RETURN_IF_ERROR( - compiler_jump_if(c, loc, (expr_ty)asdl_seq_GET(s, i), next2, cond2)); + codegen_jump_if(c, loc, (expr_ty)asdl_seq_GET(s, i), next2, cond2)); } RETURN_IF_ERROR( - compiler_jump_if(c, loc, (expr_ty)asdl_seq_GET(s, n), next, cond)); + codegen_jump_if(c, loc, (expr_ty)asdl_seq_GET(s, n), next, cond)); if (!SAME_LABEL(next2, next)) { USE_LABEL(c, next2); } @@ -2858,14 +2857,14 @@ compiler_jump_if(struct compiler *c, location loc, NEW_JUMP_TARGET_LABEL(c, end); NEW_JUMP_TARGET_LABEL(c, next2); RETURN_IF_ERROR( - compiler_jump_if(c, loc, e->v.IfExp.test, next2, 0)); + codegen_jump_if(c, loc, e->v.IfExp.test, next2, 0)); RETURN_IF_ERROR( - compiler_jump_if(c, loc, e->v.IfExp.body, next, cond)); + codegen_jump_if(c, loc, e->v.IfExp.body, next, cond)); ADDOP_JUMP(c, NO_LOCATION, JUMP_NO_INTERRUPT, end); USE_LABEL(c, next2); RETURN_IF_ERROR( - compiler_jump_if(c, loc, e->v.IfExp.orelse, next, cond)); + codegen_jump_if(c, loc, e->v.IfExp.orelse, next, cond)); USE_LABEL(c, end); return SUCCESS; @@ -2917,14 +2916,14 @@ compiler_jump_if(struct compiler *c, location loc, } static int -compiler_ifexp(struct compiler *c, expr_ty e) +codegen_ifexp(struct compiler *c, expr_ty e) { assert(e->kind == IfExp_kind); NEW_JUMP_TARGET_LABEL(c, end); NEW_JUMP_TARGET_LABEL(c, next); RETURN_IF_ERROR( - compiler_jump_if(c, LOC(e), e->v.IfExp.test, next, 0)); + codegen_jump_if(c, LOC(e), e->v.IfExp.test, next, 0)); VISIT(c, expr, e->v.IfExp.body); ADDOP_JUMP(c, NO_LOCATION, JUMP_NO_INTERRUPT, end); @@ -2937,7 +2936,7 @@ compiler_ifexp(struct compiler *c, expr_ty e) } static int -compiler_lambda(struct compiler *c, expr_ty e) +codegen_lambda(struct compiler *c, expr_ty e) { PyCodeObject *co; Py_ssize_t funcflags; @@ -2947,7 +2946,7 @@ compiler_lambda(struct compiler *c, expr_ty e) RETURN_IF_ERROR(compiler_check_debug_args(c, args)); location loc = LOC(e); - funcflags = compiler_default_arguments(c, loc, args); + funcflags = codegen_default_arguments(c, loc, args); if (funcflags == -1) { return ERROR; } @@ -2988,7 +2987,7 @@ compiler_lambda(struct compiler *c, expr_ty e) } static int -compiler_if(struct compiler *c, stmt_ty s) +codegen_if(struct compiler *c, stmt_ty s) { jump_target_label next; assert(s->kind == If_kind); @@ -3001,7 +3000,7 @@ compiler_if(struct compiler *c, stmt_ty s) next = end; } RETURN_IF_ERROR( - compiler_jump_if(c, LOC(s), s->v.If.test, next, 0)); + codegen_jump_if(c, LOC(s), s->v.If.test, next, 0)); VISIT_SEQ(c, stmt, s->v.If.body); if (asdl_seq_LEN(s->v.If.orelse)) { @@ -3016,7 +3015,7 @@ compiler_if(struct compiler *c, stmt_ty s) } static int -compiler_for(struct compiler *c, stmt_ty s) +codegen_for(struct compiler *c, stmt_ty s) { location loc = LOC(s); NEW_JUMP_TARGET_LABEL(c, start); @@ -3063,7 +3062,7 @@ compiler_for(struct compiler *c, stmt_ty s) static int -compiler_async_for(struct compiler *c, stmt_ty s) +codegen_async_for(struct compiler *c, stmt_ty s) { location loc = LOC(s); if (IS_TOP_LEVEL_AWAIT(c)){ @@ -3113,7 +3112,7 @@ compiler_async_for(struct compiler *c, stmt_ty s) } static int -compiler_while(struct compiler *c, stmt_ty s) +codegen_while(struct compiler *c, stmt_ty s) { NEW_JUMP_TARGET_LABEL(c, loop); NEW_JUMP_TARGET_LABEL(c, body); @@ -3123,11 +3122,11 @@ compiler_while(struct compiler *c, stmt_ty s) USE_LABEL(c, loop); RETURN_IF_ERROR(compiler_push_fblock(c, LOC(s), WHILE_LOOP, loop, end, NULL)); - RETURN_IF_ERROR(compiler_jump_if(c, LOC(s), s->v.While.test, anchor, 0)); + RETURN_IF_ERROR(codegen_jump_if(c, LOC(s), s->v.While.test, anchor, 0)); USE_LABEL(c, body); VISIT_SEQ(c, stmt, s->v.While.body); - RETURN_IF_ERROR(compiler_jump_if(c, LOC(s), s->v.While.test, body, 1)); + RETURN_IF_ERROR(codegen_jump_if(c, LOC(s), s->v.While.test, body, 1)); compiler_pop_fblock(c, WHILE_LOOP, loop); @@ -3141,7 +3140,7 @@ compiler_while(struct compiler *c, stmt_ty s) } static int -compiler_return(struct compiler *c, stmt_ty s) +codegen_return(struct compiler *c, stmt_ty s) { location loc = LOC(s); int preserve_tos = ((s->v.Return.value != NULL) && @@ -3182,7 +3181,7 @@ compiler_return(struct compiler *c, stmt_ty s) } static int -compiler_break(struct compiler *c, location loc) +codegen_break(struct compiler *c, location loc) { struct fblockinfo *loop = NULL; location origin_loc = loc; @@ -3198,7 +3197,7 @@ compiler_break(struct compiler *c, location loc) } static int -compiler_continue(struct compiler *c, location loc) +codegen_continue(struct compiler *c, location loc) { struct fblockinfo *loop = NULL; location origin_loc = loc; @@ -3243,7 +3242,7 @@ compiler_continue(struct compiler *c, location loc) */ static int -compiler_try_finally(struct compiler *c, stmt_ty s) +codegen_try_finally(struct compiler *c, stmt_ty s) { location loc = LOC(s); @@ -3261,7 +3260,7 @@ compiler_try_finally(struct compiler *c, stmt_ty s) s->v.Try.finalbody)); if (s->v.Try.handlers && asdl_seq_LEN(s->v.Try.handlers)) { - RETURN_IF_ERROR(compiler_try_except(c, s)); + RETURN_IF_ERROR(codegen_try_except(c, s)); } else { VISIT_SEQ(c, stmt, s->v.Try.body); @@ -3294,7 +3293,7 @@ compiler_try_finally(struct compiler *c, stmt_ty s) } static int -compiler_try_star_finally(struct compiler *c, stmt_ty s) +codegen_try_star_finally(struct compiler *c, stmt_ty s) { location loc = LOC(s); @@ -3311,7 +3310,7 @@ compiler_try_star_finally(struct compiler *c, stmt_ty s) s->v.TryStar.finalbody)); if (s->v.TryStar.handlers && asdl_seq_LEN(s->v.TryStar.handlers)) { - RETURN_IF_ERROR(compiler_try_star_except(c, s)); + RETURN_IF_ERROR(codegen_try_star_except(c, s)); } else { VISIT_SEQ(c, stmt, s->v.TryStar.body); @@ -3374,7 +3373,7 @@ compiler_try_star_finally(struct compiler *c, stmt_ty s) Of course, parts are not generated if Vi or Ei is not present. */ static int -compiler_try_except(struct compiler *c, stmt_ty s) +codegen_try_except(struct compiler *c, stmt_ty s) { location loc = LOC(s); Py_ssize_t i, n; @@ -3426,7 +3425,7 @@ compiler_try_except(struct compiler *c, stmt_ty s) NEW_JUMP_TARGET_LABEL(c, cleanup_body); RETURN_IF_ERROR( - compiler_nameop(c, loc, handler->v.ExceptHandler.name, Store)); + codegen_nameop(c, loc, handler->v.ExceptHandler.name, Store)); /* try: @@ -3456,9 +3455,9 @@ compiler_try_except(struct compiler *c, stmt_ty s) ADDOP(c, NO_LOCATION, POP_EXCEPT); ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None); RETURN_IF_ERROR( - compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store)); + codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store)); RETURN_IF_ERROR( - compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del)); + codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del)); ADDOP_JUMP(c, NO_LOCATION, JUMP_NO_INTERRUPT, end); /* except: */ @@ -3467,9 +3466,9 @@ compiler_try_except(struct compiler *c, stmt_ty s) /* name = None; del name; # artificial */ ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None); RETURN_IF_ERROR( - compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store)); + codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store)); RETURN_IF_ERROR( - compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del)); + codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del)); ADDOP_I(c, NO_LOCATION, RERAISE, 1); } @@ -3556,7 +3555,7 @@ compiler_try_except(struct compiler *c, stmt_ty s) [] L0: */ static int -compiler_try_star_except(struct compiler *c, stmt_ty s) +codegen_try_star_except(struct compiler *c, stmt_ty s) { location loc = LOC(s); @@ -3621,7 +3620,7 @@ compiler_try_star_except(struct compiler *c, stmt_ty s) if (handler->v.ExceptHandler.name) { RETURN_IF_ERROR( - compiler_nameop(c, loc, handler->v.ExceptHandler.name, Store)); + codegen_nameop(c, loc, handler->v.ExceptHandler.name, Store)); } else { ADDOP(c, loc, POP_TOP); // match @@ -3653,9 +3652,9 @@ compiler_try_star_except(struct compiler *c, stmt_ty s) if (handler->v.ExceptHandler.name) { ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None); RETURN_IF_ERROR( - compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store)); + codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store)); RETURN_IF_ERROR( - compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del)); + codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del)); } ADDOP_JUMP(c, NO_LOCATION, JUMP_NO_INTERRUPT, except); @@ -3666,9 +3665,9 @@ compiler_try_star_except(struct compiler *c, stmt_ty s) if (handler->v.ExceptHandler.name) { ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None); RETURN_IF_ERROR( - compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store)); + codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Store)); RETURN_IF_ERROR( - compiler_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del)); + codegen_nameop(c, NO_LOCATION, handler->v.ExceptHandler.name, Del)); } /* add exception raised to the res list */ @@ -3723,26 +3722,26 @@ compiler_try_star_except(struct compiler *c, stmt_ty s) } static int -compiler_try(struct compiler *c, stmt_ty s) { +codegen_try(struct compiler *c, stmt_ty s) { if (s->v.Try.finalbody && asdl_seq_LEN(s->v.Try.finalbody)) - return compiler_try_finally(c, s); + return codegen_try_finally(c, s); else - return compiler_try_except(c, s); + return codegen_try_except(c, s); } static int -compiler_try_star(struct compiler *c, stmt_ty s) +codegen_try_star(struct compiler *c, stmt_ty s) { if (s->v.TryStar.finalbody && asdl_seq_LEN(s->v.TryStar.finalbody)) { - return compiler_try_star_finally(c, s); + return codegen_try_star_finally(c, s); } else { - return compiler_try_star_except(c, s); + return codegen_try_star_except(c, s); } } static int -compiler_import_as(struct compiler *c, location loc, +codegen_import_as(struct compiler *c, location loc, identifier name, identifier asname) { /* The IMPORT_NAME opcode was already generated. This function @@ -3776,15 +3775,15 @@ compiler_import_as(struct compiler *c, location loc, ADDOP_I(c, loc, SWAP, 2); ADDOP(c, loc, POP_TOP); } - RETURN_IF_ERROR(compiler_nameop(c, loc, asname, Store)); + RETURN_IF_ERROR(codegen_nameop(c, loc, asname, Store)); ADDOP(c, loc, POP_TOP); return SUCCESS; } - return compiler_nameop(c, loc, asname, Store); + return codegen_nameop(c, loc, asname, Store); } static int -compiler_import(struct compiler *c, stmt_ty s) +codegen_import(struct compiler *c, stmt_ty s) { location loc = LOC(s); /* The Import node stores a module name like a.b.c as a single @@ -3806,7 +3805,7 @@ compiler_import(struct compiler *c, stmt_ty s) ADDOP_NAME(c, loc, IMPORT_NAME, alias->name, names); if (alias->asname) { - r = compiler_import_as(c, loc, alias->name, alias->asname); + r = codegen_import_as(c, loc, alias->name, alias->asname); RETURN_IF_ERROR(r); } else { @@ -3819,7 +3818,7 @@ compiler_import(struct compiler *c, stmt_ty s) return ERROR; } } - r = compiler_nameop(c, loc, tmp, Store); + r = codegen_nameop(c, loc, tmp, Store); if (dot != -1) { Py_DECREF(tmp); } @@ -3830,7 +3829,7 @@ compiler_import(struct compiler *c, stmt_ty s) } static int -compiler_from_import(struct compiler *c, stmt_ty s) +codegen_from_import(struct compiler *c, stmt_ty s) { Py_ssize_t n = asdl_seq_LEN(s->v.ImportFrom.names); @@ -3881,7 +3880,7 @@ compiler_from_import(struct compiler *c, stmt_ty s) store_name = alias->asname; } - RETURN_IF_ERROR(compiler_nameop(c, LOC(s), store_name, Store)); + RETURN_IF_ERROR(codegen_nameop(c, LOC(s), store_name, Store)); } /* remove imported module */ ADDOP(c, LOC(s), POP_TOP); @@ -3889,7 +3888,7 @@ compiler_from_import(struct compiler *c, stmt_ty s) } static int -compiler_assert(struct compiler *c, stmt_ty s) +codegen_assert(struct compiler *c, stmt_ty s) { /* Always emit a warning if the test is a non-zero length tuple */ if ((s->v.Assert.test->kind == Tuple_kind && @@ -3906,7 +3905,7 @@ compiler_assert(struct compiler *c, stmt_ty s) return SUCCESS; } NEW_JUMP_TARGET_LABEL(c, end); - RETURN_IF_ERROR(compiler_jump_if(c, LOC(s), s->v.Assert.test, end, 1)); + RETURN_IF_ERROR(codegen_jump_if(c, LOC(s), s->v.Assert.test, end, 1)); ADDOP_I(c, LOC(s), LOAD_COMMON_CONSTANT, CONSTANT_ASSERTIONERROR); if (s->v.Assert.msg) { VISIT(c, expr, s->v.Assert.msg); @@ -3919,7 +3918,7 @@ compiler_assert(struct compiler *c, stmt_ty s) } static int -compiler_stmt_expr(struct compiler *c, location loc, expr_ty value) +codegen_stmt_expr(struct compiler *c, location loc, expr_ty value) { if (c->c_interactive && c->c_nestlevel <= 1) { VISIT(c, expr, value); @@ -3940,18 +3939,18 @@ compiler_stmt_expr(struct compiler *c, location loc, expr_ty value) } static int -compiler_visit_stmt(struct compiler *c, stmt_ty s) +codegen_visit_stmt(struct compiler *c, stmt_ty s) { switch (s->kind) { case FunctionDef_kind: - return compiler_function(c, s, 0); + return codegen_function(c, s, 0); case ClassDef_kind: - return compiler_class(c, s); + return codegen_class(c, s); case TypeAlias_kind: - return compiler_typealias(c, s); + return codegen_typealias(c, s); case Return_kind: - return compiler_return(c, s); + return codegen_return(c, s); case Delete_kind: VISIT_SEQ(c, expr, s->v.Delete.targets) break; @@ -3969,17 +3968,17 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s) break; } case AugAssign_kind: - return compiler_augassign(c, s); + return codegen_augassign(c, s); case AnnAssign_kind: - return compiler_annassign(c, s); + return codegen_annassign(c, s); case For_kind: - return compiler_for(c, s); + return codegen_for(c, s); case While_kind: - return compiler_while(c, s); + return codegen_while(c, s); case If_kind: - return compiler_if(c, s); + return codegen_if(c, s); case Match_kind: - return compiler_match(c, s); + return codegen_match(c, s); case Raise_kind: { Py_ssize_t n = 0; @@ -3995,21 +3994,21 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s) break; } case Try_kind: - return compiler_try(c, s); + return codegen_try(c, s); case TryStar_kind: - return compiler_try_star(c, s); + return codegen_try_star(c, s); case Assert_kind: - return compiler_assert(c, s); + return codegen_assert(c, s); case Import_kind: - return compiler_import(c, s); + return codegen_import(c, s); case ImportFrom_kind: - return compiler_from_import(c, s); + return codegen_from_import(c, s); case Global_kind: case Nonlocal_kind: break; case Expr_kind: { - return compiler_stmt_expr(c, LOC(s), s->v.Expr.value); + return codegen_stmt_expr(c, LOC(s), s->v.Expr.value); } case Pass_kind: { @@ -4018,20 +4017,20 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s) } case Break_kind: { - return compiler_break(c, LOC(s)); + return codegen_break(c, LOC(s)); } case Continue_kind: { - return compiler_continue(c, LOC(s)); + return codegen_continue(c, LOC(s)); } case With_kind: - return compiler_with(c, s, 0); + return codegen_with(c, s, 0); case AsyncFunctionDef_kind: - return compiler_function(c, s, 1); + return codegen_function(c, s, 1); case AsyncWith_kind: - return compiler_async_with(c, s, 0); + return codegen_async_with(c, s, 0); case AsyncFor_kind: - return compiler_async_for(c, s); + return codegen_async_for(c, s); } return SUCCESS; @@ -4118,8 +4117,8 @@ addop_yield(struct compiler *c, location loc) { } static int -compiler_nameop(struct compiler *c, location loc, - identifier name, expr_context_ty ctx) +codegen_nameop(struct compiler *c, location loc, + identifier name, expr_context_ty ctx) { int op, scope; Py_ssize_t arg; @@ -4268,7 +4267,7 @@ compiler_nameop(struct compiler *c, location loc, } static int -compiler_boolop(struct compiler *c, expr_ty e) +codegen_boolop(struct compiler *c, expr_ty e) { int jumpi; Py_ssize_t i, n; @@ -4423,7 +4422,7 @@ assignment_helper(struct compiler *c, location loc, asdl_expr_seq *elts) } static int -compiler_list(struct compiler *c, expr_ty e) +codegen_list(struct compiler *c, expr_ty e) { location loc = LOC(e); asdl_expr_seq *elts = e->v.List.elts; @@ -4441,7 +4440,7 @@ compiler_list(struct compiler *c, expr_ty e) } static int -compiler_tuple(struct compiler *c, expr_ty e) +codegen_tuple(struct compiler *c, expr_ty e) { location loc = LOC(e); asdl_expr_seq *elts = e->v.Tuple.elts; @@ -4459,7 +4458,7 @@ compiler_tuple(struct compiler *c, expr_ty e) } static int -compiler_set(struct compiler *c, expr_ty e) +codegen_set(struct compiler *c, expr_ty e) { location loc = LOC(e); return starunpack_helper(c, loc, e->v.Set.elts, 0, @@ -4479,7 +4478,7 @@ are_all_items_const(asdl_expr_seq *seq, Py_ssize_t begin, Py_ssize_t end) } static int -compiler_subdict(struct compiler *c, expr_ty e, Py_ssize_t begin, Py_ssize_t end) +codegen_subdict(struct compiler *c, expr_ty e, Py_ssize_t begin, Py_ssize_t end) { Py_ssize_t i, n = end - begin; PyObject *keys, *key; @@ -4518,7 +4517,7 @@ compiler_subdict(struct compiler *c, expr_ty e, Py_ssize_t begin, Py_ssize_t end } static int -compiler_dict(struct compiler *c, expr_ty e) +codegen_dict(struct compiler *c, expr_ty e) { location loc = LOC(e); Py_ssize_t i, n, elements; @@ -4531,7 +4530,7 @@ compiler_dict(struct compiler *c, expr_ty e) is_unpacking = (expr_ty)asdl_seq_GET(e->v.Dict.keys, i) == NULL; if (is_unpacking) { if (elements) { - RETURN_IF_ERROR(compiler_subdict(c, e, i - elements, i)); + RETURN_IF_ERROR(codegen_subdict(c, e, i - elements, i)); if (have_dict) { ADDOP_I(c, loc, DICT_UPDATE, 1); } @@ -4547,7 +4546,7 @@ compiler_dict(struct compiler *c, expr_ty e) } else { if (elements*2 > STACK_USE_GUIDELINE) { - RETURN_IF_ERROR(compiler_subdict(c, e, i - elements, i + 1)); + RETURN_IF_ERROR(codegen_subdict(c, e, i - elements, i + 1)); if (have_dict) { ADDOP_I(c, loc, DICT_UPDATE, 1); } @@ -4560,7 +4559,7 @@ compiler_dict(struct compiler *c, expr_ty e) } } if (elements) { - RETURN_IF_ERROR(compiler_subdict(c, e, n - elements, n)); + RETURN_IF_ERROR(codegen_subdict(c, e, n - elements, n)); if (have_dict) { ADDOP_I(c, loc, DICT_UPDATE, 1); } @@ -4573,7 +4572,7 @@ compiler_dict(struct compiler *c, expr_ty e) } static int -compiler_compare(struct compiler *c, expr_ty e) +codegen_compare(struct compiler *c, expr_ty e) { location loc = LOC(e); Py_ssize_t i, n; @@ -4808,7 +4807,7 @@ load_args_for_super(struct compiler *c, expr_ty e) { // load super() global PyObject *super_name = e->v.Call.func->v.Name.id; - RETURN_IF_ERROR(compiler_nameop(c, LOC(e->v.Call.func), super_name, Load)); + RETURN_IF_ERROR(codegen_nameop(c, LOC(e->v.Call.func), super_name, Load)); if (asdl_seq_LEN(e->v.Call.args) == 2) { VISIT(c, expr, asdl_seq_GET(e->v.Call.args, 0)); @@ -4819,7 +4818,7 @@ load_args_for_super(struct compiler *c, expr_ty e) { // load __class__ cell PyObject *name = &_Py_ID(__class__); assert(get_ref_type(c, name) == FREE); - RETURN_IF_ERROR(compiler_nameop(c, loc, name, Load)); + RETURN_IF_ERROR(codegen_nameop(c, loc, name, Load)); // load self (first argument) Py_ssize_t i = 0; @@ -4827,7 +4826,7 @@ load_args_for_super(struct compiler *c, expr_ty e) { if (!PyDict_Next(c->u->u_metadata.u_varnames, &i, &key, &value)) { return ERROR; } - RETURN_IF_ERROR(compiler_nameop(c, loc, key, Load)); + RETURN_IF_ERROR(codegen_nameop(c, loc, key, Load)); return SUCCESS; } @@ -4921,7 +4920,7 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e) if (kwdsl) { VISIT_SEQ(c, keyword, kwds); RETURN_IF_ERROR( - compiler_call_simple_kw_helper(c, loc, kwds, kwdsl)); + codegen_call_simple_kw_helper(c, loc, kwds, kwdsl)); loc = update_start_location_to_match_attr(c, LOC(e), meth); ADDOP_I(c, loc, CALL_KW, argsl + kwdsl); } @@ -4957,7 +4956,7 @@ validate_keywords(struct compiler *c, asdl_keyword_seq *keywords) } static int -compiler_call(struct compiler *c, expr_ty e) +codegen_call(struct compiler *c, expr_ty e) { RETURN_IF_ERROR(validate_keywords(c, e->v.Call.keywords)); int ret = maybe_optimize_method_call(c, e); @@ -4972,13 +4971,13 @@ compiler_call(struct compiler *c, expr_ty e) location loc = LOC(e->v.Call.func); ADDOP(c, loc, PUSH_NULL); loc = LOC(e); - return compiler_call_helper(c, loc, 0, - e->v.Call.args, - e->v.Call.keywords); + return codegen_call_helper(c, loc, 0, + e->v.Call.args, + e->v.Call.keywords); } static int -compiler_joined_str(struct compiler *c, expr_ty e) +codegen_joined_str(struct compiler *c, expr_ty e) { location loc = LOC(e); Py_ssize_t value_count = asdl_seq_LEN(e->v.JoinedStr.values); @@ -5008,7 +5007,7 @@ compiler_joined_str(struct compiler *c, expr_ty e) /* Used to implement f-strings. Format a single value. */ static int -compiler_formatted_value(struct compiler *c, expr_ty e) +codegen_formatted_value(struct compiler *c, expr_ty e) { /* Our oparg encodes 2 pieces of information: the conversion character, and whether or not a format_spec was provided. @@ -5054,9 +5053,9 @@ compiler_formatted_value(struct compiler *c, expr_ty e) } static int -compiler_subkwargs(struct compiler *c, location loc, - asdl_keyword_seq *keywords, - Py_ssize_t begin, Py_ssize_t end) +codegen_subkwargs(struct compiler *c, location loc, + asdl_keyword_seq *keywords, + Py_ssize_t begin, Py_ssize_t end) { Py_ssize_t i, n = end - begin; keyword_ty kw; @@ -5097,11 +5096,11 @@ compiler_subkwargs(struct compiler *c, location loc, return SUCCESS; } -/* Used by compiler_call_helper and maybe_optimize_method_call to emit +/* Used by codegen_call_helper and maybe_optimize_method_call to emit * a tuple of keyword names before CALL. */ static int -compiler_call_simple_kw_helper(struct compiler *c, location loc, +codegen_call_simple_kw_helper(struct compiler *c, location loc, asdl_keyword_seq *keywords, Py_ssize_t nkwelts) { PyObject *names; @@ -5118,12 +5117,12 @@ compiler_call_simple_kw_helper(struct compiler *c, location loc, } -/* shared code between compiler_call and compiler_class */ +/* shared code between compiler_call and codegen_class */ static int -compiler_call_helper(struct compiler *c, location loc, - int n, /* Args already pushed */ - asdl_expr_seq *args, - asdl_keyword_seq *keywords) +codegen_call_helper(struct compiler *c, location loc, + int n, /* Args already pushed */ + asdl_expr_seq *args, + asdl_keyword_seq *keywords) { Py_ssize_t i, nseen, nelts, nkwelts; @@ -5157,7 +5156,7 @@ compiler_call_helper(struct compiler *c, location loc, if (nkwelts) { VISIT_SEQ(c, keyword, keywords); RETURN_IF_ERROR( - compiler_call_simple_kw_helper(c, loc, keywords, nkwelts)); + codegen_call_simple_kw_helper(c, loc, keywords, nkwelts)); ADDOP_I(c, loc, CALL_KW, n + nelts + nkwelts); } else { @@ -5186,7 +5185,7 @@ compiler_call_helper(struct compiler *c, location loc, if (kw->arg == NULL) { /* A keyword argument unpacking. */ if (nseen) { - RETURN_IF_ERROR(compiler_subkwargs(c, loc, keywords, i - nseen, i)); + RETURN_IF_ERROR(codegen_subkwargs(c, loc, keywords, i - nseen, i)); if (have_dict) { ADDOP_I(c, loc, DICT_MERGE, 1); } @@ -5206,7 +5205,7 @@ compiler_call_helper(struct compiler *c, location loc, } if (nseen) { /* Pack up any trailing keyword arguments. */ - RETURN_IF_ERROR(compiler_subkwargs(c, loc, keywords, nkwelts - nseen, nkwelts)); + RETURN_IF_ERROR(codegen_subkwargs(c, loc, keywords, nkwelts - nseen, nkwelts)); if (have_dict) { ADDOP_I(c, loc, DICT_MERGE, 1); } @@ -5234,31 +5233,31 @@ compiler_call_helper(struct compiler *c, location loc, static int -compiler_comprehension_generator(struct compiler *c, location loc, - asdl_comprehension_seq *generators, int gen_index, - int depth, - expr_ty elt, expr_ty val, int type, - int iter_on_stack) +codegen_comprehension_generator(struct compiler *c, location loc, + asdl_comprehension_seq *generators, int gen_index, + int depth, + expr_ty elt, expr_ty val, int type, + int iter_on_stack) { comprehension_ty gen; gen = (comprehension_ty)asdl_seq_GET(generators, gen_index); if (gen->is_async) { - return compiler_async_comprehension_generator( + return codegen_async_comprehension_generator( c, loc, generators, gen_index, depth, elt, val, type, iter_on_stack); } else { - return compiler_sync_comprehension_generator( + return codegen_sync_comprehension_generator( c, loc, generators, gen_index, depth, elt, val, type, iter_on_stack); } } static int -compiler_sync_comprehension_generator(struct compiler *c, location loc, - asdl_comprehension_seq *generators, - int gen_index, int depth, - expr_ty elt, expr_ty val, int type, - int iter_on_stack) +codegen_sync_comprehension_generator(struct compiler *c, location loc, + asdl_comprehension_seq *generators, + int gen_index, int depth, + expr_ty elt, expr_ty val, int type, + int iter_on_stack) { /* generate code for the iterator, then each of the ifs, and then write to the element */ @@ -5316,14 +5315,14 @@ compiler_sync_comprehension_generator(struct compiler *c, location loc, Py_ssize_t n = asdl_seq_LEN(gen->ifs); for (Py_ssize_t i = 0; i < n; i++) { expr_ty e = (expr_ty)asdl_seq_GET(gen->ifs, i); - RETURN_IF_ERROR(compiler_jump_if(c, loc, e, if_cleanup, 0)); + RETURN_IF_ERROR(codegen_jump_if(c, loc, e, if_cleanup, 0)); } if (++gen_index < asdl_seq_LEN(generators)) { RETURN_IF_ERROR( - compiler_comprehension_generator(c, loc, - generators, gen_index, depth, - elt, val, type, 0)); + codegen_comprehension_generator(c, loc, + generators, gen_index, depth, + elt, val, type, 0)); } location elt_loc = LOC(elt); @@ -5378,7 +5377,7 @@ compiler_sync_comprehension_generator(struct compiler *c, location loc, } static int -compiler_async_comprehension_generator(struct compiler *c, location loc, +codegen_async_comprehension_generator(struct compiler *c, location loc, asdl_comprehension_seq *generators, int gen_index, int depth, expr_ty elt, expr_ty val, int type, @@ -5420,13 +5419,13 @@ compiler_async_comprehension_generator(struct compiler *c, location loc, Py_ssize_t n = asdl_seq_LEN(gen->ifs); for (Py_ssize_t i = 0; i < n; i++) { expr_ty e = (expr_ty)asdl_seq_GET(gen->ifs, i); - RETURN_IF_ERROR(compiler_jump_if(c, loc, e, if_cleanup, 0)); + RETURN_IF_ERROR(codegen_jump_if(c, loc, e, if_cleanup, 0)); } depth++; if (++gen_index < asdl_seq_LEN(generators)) { RETURN_IF_ERROR( - compiler_comprehension_generator(c, loc, + codegen_comprehension_generator(c, loc, generators, gen_index, depth, elt, val, type, 0)); } @@ -5690,8 +5689,8 @@ pop_inlined_comprehension_state(struct compiler *c, location loc, } static inline int -compiler_comprehension_iter(struct compiler *c, location loc, - comprehension_ty comp) +codegen_comprehension_iter(struct compiler *c, location loc, + comprehension_ty comp) { VISIT(c, expr, comp->iter); if (comp->is_async) { @@ -5704,7 +5703,7 @@ compiler_comprehension_iter(struct compiler *c, location loc, } static int -compiler_comprehension(struct compiler *c, expr_ty e, int type, +codegen_comprehension(struct compiler *c, expr_ty e, int type, identifier name, asdl_comprehension_seq *generators, expr_ty elt, expr_ty val) { @@ -5724,7 +5723,7 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type, outermost = (comprehension_ty) asdl_seq_GET(generators, 0); if (is_inlined) { - if (compiler_comprehension_iter(c, loc, outermost)) { + if (codegen_comprehension_iter(c, loc, outermost)) { goto error; } if (push_inlined_comprehension_state(c, loc, entry, &inline_state)) { @@ -5774,7 +5773,7 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type, } } - if (compiler_comprehension_generator(c, loc, generators, 0, 0, + if (codegen_comprehension_generator(c, loc, generators, 0, 0, elt, val, type, is_inlined) < 0) { goto error_in_scope; } @@ -5810,7 +5809,7 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type, } Py_CLEAR(co); - if (compiler_comprehension_iter(c, loc, outermost)) { + if (codegen_comprehension_iter(c, loc, outermost)) { goto error; } @@ -5837,49 +5836,49 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type, } static int -compiler_genexp(struct compiler *c, expr_ty e) +codegen_genexp(struct compiler *c, expr_ty e) { assert(e->kind == GeneratorExp_kind); _Py_DECLARE_STR(anon_genexpr, ""); - return compiler_comprehension(c, e, COMP_GENEXP, &_Py_STR(anon_genexpr), + return codegen_comprehension(c, e, COMP_GENEXP, &_Py_STR(anon_genexpr), e->v.GeneratorExp.generators, e->v.GeneratorExp.elt, NULL); } static int -compiler_listcomp(struct compiler *c, expr_ty e) +codegen_listcomp(struct compiler *c, expr_ty e) { assert(e->kind == ListComp_kind); _Py_DECLARE_STR(anon_listcomp, ""); - return compiler_comprehension(c, e, COMP_LISTCOMP, &_Py_STR(anon_listcomp), + return codegen_comprehension(c, e, COMP_LISTCOMP, &_Py_STR(anon_listcomp), e->v.ListComp.generators, e->v.ListComp.elt, NULL); } static int -compiler_setcomp(struct compiler *c, expr_ty e) +codegen_setcomp(struct compiler *c, expr_ty e) { assert(e->kind == SetComp_kind); _Py_DECLARE_STR(anon_setcomp, ""); - return compiler_comprehension(c, e, COMP_SETCOMP, &_Py_STR(anon_setcomp), + return codegen_comprehension(c, e, COMP_SETCOMP, &_Py_STR(anon_setcomp), e->v.SetComp.generators, e->v.SetComp.elt, NULL); } static int -compiler_dictcomp(struct compiler *c, expr_ty e) +codegen_dictcomp(struct compiler *c, expr_ty e) { assert(e->kind == DictComp_kind); _Py_DECLARE_STR(anon_dictcomp, ""); - return compiler_comprehension(c, e, COMP_DICTCOMP, &_Py_STR(anon_dictcomp), + return codegen_comprehension(c, e, COMP_DICTCOMP, &_Py_STR(anon_dictcomp), e->v.DictComp.generators, e->v.DictComp.key, e->v.DictComp.value); } static int -compiler_visit_keyword(struct compiler *c, keyword_ty k) +codegen_visit_keyword(struct compiler *c, keyword_ty k) { VISIT(c, expr, k->value); return SUCCESS; @@ -5887,7 +5886,7 @@ compiler_visit_keyword(struct compiler *c, keyword_ty k) static int -compiler_with_except_finish(struct compiler *c, jump_target_label cleanup) { +codegen_with_except_finish(struct compiler *c, jump_target_label cleanup) { NEW_JUMP_TARGET_LABEL(c, suppress); ADDOP(c, NO_LOCATION, TO_BOOL); ADDOP_JUMP(c, NO_LOCATION, POP_JUMP_IF_TRUE, suppress); @@ -5935,7 +5934,7 @@ compiler_with_except_finish(struct compiler *c, jump_target_label cleanup) { raise */ static int -compiler_async_with(struct compiler *c, stmt_ty s, int pos) +codegen_async_with(struct compiler *c, stmt_ty s, int pos) { location loc = LOC(s); withitem_ty item = asdl_seq_GET(s->v.AsyncWith.items, pos); @@ -5985,7 +5984,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos) VISIT_SEQ(c, stmt, s->v.AsyncWith.body) } else { - RETURN_IF_ERROR(compiler_async_with(c, s, pos)); + RETURN_IF_ERROR(codegen_async_with(c, s, pos)); } compiler_pop_fblock(c, ASYNC_WITH, block); @@ -5996,7 +5995,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos) /* For successful outcome: * call __exit__(None, None, None) */ - RETURN_IF_ERROR(compiler_call_exit_with_nones(c, loc)); + RETURN_IF_ERROR(codegen_call_exit_with_nones(c, loc)); ADDOP_I(c, loc, GET_AWAITABLE, 2); ADDOP_LOAD_CONST(c, loc, Py_None); ADD_YIELD_FROM(c, loc, 1); @@ -6014,7 +6013,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos) ADDOP_I(c, loc, GET_AWAITABLE, 2); ADDOP_LOAD_CONST(c, loc, Py_None); ADD_YIELD_FROM(c, loc, 1); - RETURN_IF_ERROR(compiler_with_except_finish(c, cleanup)); + RETURN_IF_ERROR(codegen_with_except_finish(c, cleanup)); USE_LABEL(c, exit); return SUCCESS; @@ -6043,7 +6042,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos) */ static int -compiler_with(struct compiler *c, stmt_ty s, int pos) +codegen_with(struct compiler *c, stmt_ty s, int pos) { withitem_ty item = asdl_seq_GET(s->v.With.items, pos); @@ -6084,7 +6083,7 @@ compiler_with(struct compiler *c, stmt_ty s, int pos) VISIT_SEQ(c, stmt, s->v.With.body) } else { - RETURN_IF_ERROR(compiler_with(c, s, pos)); + RETURN_IF_ERROR(codegen_with(c, s, pos)); } ADDOP(c, NO_LOCATION, POP_BLOCK); @@ -6095,7 +6094,7 @@ compiler_with(struct compiler *c, stmt_ty s, int pos) /* For successful outcome: * call __exit__(None, None, None) */ - RETURN_IF_ERROR(compiler_call_exit_with_nones(c, loc)); + RETURN_IF_ERROR(codegen_call_exit_with_nones(c, loc)); ADDOP(c, loc, POP_TOP); ADDOP_JUMP(c, loc, JUMP, exit); @@ -6105,14 +6104,14 @@ compiler_with(struct compiler *c, stmt_ty s, int pos) ADDOP_JUMP(c, loc, SETUP_CLEANUP, cleanup); ADDOP(c, loc, PUSH_EXC_INFO); ADDOP(c, loc, WITH_EXCEPT_START); - RETURN_IF_ERROR(compiler_with_except_finish(c, cleanup)); + RETURN_IF_ERROR(codegen_with_except_finish(c, cleanup)); USE_LABEL(c, exit); return SUCCESS; } static int -compiler_visit_expr(struct compiler *c, expr_ty e) +codegen_visit_expr(struct compiler *c, expr_ty e) { location loc = LOC(e); switch (e->kind) { @@ -6122,7 +6121,7 @@ compiler_visit_expr(struct compiler *c, expr_ty e) VISIT(c, expr, e->v.NamedExpr.target); break; case BoolOp_kind: - return compiler_boolop(c, e); + return codegen_boolop(c, e); case BinOp_kind: VISIT(c, expr, e->v.BinOp.left); VISIT(c, expr, e->v.BinOp.right); @@ -6142,21 +6141,21 @@ compiler_visit_expr(struct compiler *c, expr_ty e) } break; case Lambda_kind: - return compiler_lambda(c, e); + return codegen_lambda(c, e); case IfExp_kind: - return compiler_ifexp(c, e); + return codegen_ifexp(c, e); case Dict_kind: - return compiler_dict(c, e); + return codegen_dict(c, e); case Set_kind: - return compiler_set(c, e); + return codegen_set(c, e); case GeneratorExp_kind: - return compiler_genexp(c, e); + return codegen_genexp(c, e); case ListComp_kind: - return compiler_listcomp(c, e); + return codegen_listcomp(c, e); case SetComp_kind: - return compiler_setcomp(c, e); + return codegen_setcomp(c, e); case DictComp_kind: - return compiler_dictcomp(c, e); + return codegen_dictcomp(c, e); case Yield_kind: if (!_PyST_IsFunctionLike(c->u->u_ste)) { return compiler_error(c, loc, "'yield' outside function"); @@ -6199,16 +6198,16 @@ compiler_visit_expr(struct compiler *c, expr_ty e) ADD_YIELD_FROM(c, loc, 1); break; case Compare_kind: - return compiler_compare(c, e); + return codegen_compare(c, e); case Call_kind: - return compiler_call(c, e); + return codegen_call(c, e); case Constant_kind: ADDOP_LOAD_CONST(c, loc, e->v.Constant.value); break; case JoinedStr_kind: - return compiler_joined_str(c, e); + return codegen_joined_str(c, e); case FormattedValue_kind: - return compiler_formatted_value(c, e); + return codegen_formatted_value(c, e); /* The following exprs can be assignment targets. */ case Attribute_kind: if (e->v.Attribute.ctx == Load && can_optimize_super_call(c, e)) { @@ -6250,12 +6249,12 @@ compiler_visit_expr(struct compiler *c, expr_ty e) } break; case Subscript_kind: - return compiler_subscript(c, e); + return codegen_subscript(c, e); case Starred_kind: switch (e->v.Starred.ctx) { case Store: /* In all legitimate cases, the Starred node was already replaced - * by compiler_list/compiler_tuple. XXX: is that okay? */ + * by codegen_list/codegen_tuple. XXX: is that okay? */ return compiler_error(c, loc, "starred assignment target must be in a list or tuple"); default: @@ -6265,18 +6264,18 @@ compiler_visit_expr(struct compiler *c, expr_ty e) break; case Slice_kind: { - int n = compiler_slice(c, e); + int n = codegen_slice(c, e); RETURN_IF_ERROR(n); ADDOP_I(c, loc, BUILD_SLICE, n); break; } case Name_kind: - return compiler_nameop(c, loc, e->v.Name.id, e->v.Name.ctx); + return codegen_nameop(c, loc, e->v.Name.id, e->v.Name.ctx); /* child nodes of List and Tuple will have expr_context set */ case List_kind: - return compiler_list(c, e); + return codegen_list(c, e); case Tuple_kind: - return compiler_tuple(c, e); + return codegen_tuple(c, e); } return SUCCESS; } @@ -6289,7 +6288,7 @@ is_two_element_slice(expr_ty s) } static int -compiler_augassign(struct compiler *c, stmt_ty s) +codegen_augassign(struct compiler *c, stmt_ty s) { assert(s->kind == AugAssign_kind); expr_ty e = s->v.AugAssign.target; @@ -6306,7 +6305,7 @@ compiler_augassign(struct compiler *c, stmt_ty s) case Subscript_kind: VISIT(c, expr, e->v.Subscript.value); if (is_two_element_slice(e->v.Subscript.slice)) { - RETURN_IF_ERROR(compiler_slice(c, e->v.Subscript.slice)); + RETURN_IF_ERROR(codegen_slice(c, e->v.Subscript.slice)); ADDOP_I(c, loc, COPY, 3); ADDOP_I(c, loc, COPY, 3); ADDOP_I(c, loc, COPY, 3); @@ -6320,7 +6319,7 @@ compiler_augassign(struct compiler *c, stmt_ty s) } break; case Name_kind: - RETURN_IF_ERROR(compiler_nameop(c, loc, e->v.Name.id, Load)); + RETURN_IF_ERROR(codegen_nameop(c, loc, e->v.Name.id, Load)); break; default: PyErr_Format(PyExc_SystemError, @@ -6356,7 +6355,7 @@ compiler_augassign(struct compiler *c, stmt_ty s) } break; case Name_kind: - return compiler_nameop(c, loc, e->v.Name.id, Store); + return codegen_nameop(c, loc, e->v.Name.id, Store); default: Py_UNREACHABLE(); } @@ -6419,7 +6418,7 @@ check_ann_subscr(struct compiler *c, expr_ty e) } static int -compiler_annassign(struct compiler *c, stmt_ty s) +codegen_annassign(struct compiler *c, stmt_ty s) { location loc = LOC(s); expr_ty targ = s->v.AnnAssign.target; @@ -6563,7 +6562,7 @@ compiler_warn(struct compiler *c, location loc, } static int -compiler_subscript(struct compiler *c, expr_ty e) +codegen_subscript(struct compiler *c, expr_ty e) { location loc = LOC(e); expr_context_ty ctx = e->v.Subscript.ctx; @@ -6576,7 +6575,7 @@ compiler_subscript(struct compiler *c, expr_ty e) VISIT(c, expr, e->v.Subscript.value); if (is_two_element_slice(e->v.Subscript.slice) && ctx != Del) { - RETURN_IF_ERROR(compiler_slice(c, e->v.Subscript.slice)); + RETURN_IF_ERROR(codegen_slice(c, e->v.Subscript.slice)); if (ctx == Load) { ADDOP(c, loc, BINARY_SLICE); } @@ -6601,7 +6600,7 @@ compiler_subscript(struct compiler *c, expr_ty e) /* Returns the number of the values emitted, * thus are needed to build the slice, or -1 if there is an error. */ static int -compiler_slice(struct compiler *c, expr_ty s) +codegen_slice(struct compiler *c, expr_ty s) { int n = 2; assert(s->kind == Slice_kind); @@ -6631,7 +6630,7 @@ compiler_slice(struct compiler *c, expr_ty s) // PEP 634: Structural Pattern Matching -// To keep things simple, all compiler_pattern_* and pattern_helper_* routines +// To keep things simple, all codegen_pattern_* and pattern_helper_* routines // follow the convention of consuming TOS (the subject for the given pattern) // and calling jump_to_fail_pop on failure (no match). @@ -6711,7 +6710,7 @@ emit_and_reset_fail_pop(struct compiler *c, location loc, } static int -compiler_error_duplicate_store(struct compiler *c, location loc, identifier n) +codegen_error_duplicate_store(struct compiler *c, location loc, identifier n) { return compiler_error(c, loc, "multiple assignments to name %R in pattern", n); @@ -6742,7 +6741,7 @@ pattern_helper_store_name(struct compiler *c, location loc, int duplicate = PySequence_Contains(pc->stores, n); RETURN_IF_ERROR(duplicate); if (duplicate) { - return compiler_error_duplicate_store(c, loc, n); + return codegen_error_duplicate_store(c, loc, n); } // Rotate this object underneath any items we need to preserve: Py_ssize_t rotations = pc->on_top + PyList_GET_SIZE(pc->stores) + 1; @@ -6795,7 +6794,7 @@ pattern_helper_sequence_unpack(struct compiler *c, location loc, // One less item to keep track of each time we loop through: pc->on_top--; pattern_ty pattern = asdl_seq_GET(patterns, i); - RETURN_IF_ERROR(compiler_pattern_subpattern(c, pattern, pc)); + RETURN_IF_ERROR(codegen_pattern_subpattern(c, pattern, pc)); } return SUCCESS; } @@ -6832,7 +6831,7 @@ pattern_helper_sequence_subscr(struct compiler *c, location loc, ADDOP_BINARY(c, loc, Sub); } ADDOP(c, loc, BINARY_SUBSCR); - RETURN_IF_ERROR(compiler_pattern_subpattern(c, pattern, pc)); + RETURN_IF_ERROR(codegen_pattern_subpattern(c, pattern, pc)); } // Pop the subject, we're done with it: pc->on_top--; @@ -6840,20 +6839,20 @@ pattern_helper_sequence_subscr(struct compiler *c, location loc, return SUCCESS; } -// Like compiler_pattern, but turn off checks for irrefutability. +// Like codegen_pattern, but turn off checks for irrefutability. static int -compiler_pattern_subpattern(struct compiler *c, +codegen_pattern_subpattern(struct compiler *c, pattern_ty p, pattern_context *pc) { int allow_irrefutable = pc->allow_irrefutable; pc->allow_irrefutable = 1; - RETURN_IF_ERROR(compiler_pattern(c, p, pc)); + RETURN_IF_ERROR(codegen_pattern(c, p, pc)); pc->allow_irrefutable = allow_irrefutable; return SUCCESS; } static int -compiler_pattern_as(struct compiler *c, pattern_ty p, pattern_context *pc) +codegen_pattern_as(struct compiler *c, pattern_ty p, pattern_context *pc) { assert(p->kind == MatchAs_kind); if (p->v.MatchAs.pattern == NULL) { @@ -6871,7 +6870,7 @@ compiler_pattern_as(struct compiler *c, pattern_ty p, pattern_context *pc) // Need to make a copy for (possibly) storing later: pc->on_top++; ADDOP_I(c, LOC(p), COPY, 1); - RETURN_IF_ERROR(compiler_pattern(c, p->v.MatchAs.pattern, pc)); + RETURN_IF_ERROR(codegen_pattern(c, p->v.MatchAs.pattern, pc)); // Success! Store it: pc->on_top--; RETURN_IF_ERROR(pattern_helper_store_name(c, LOC(p), p->v.MatchAs.name, pc)); @@ -6879,7 +6878,7 @@ compiler_pattern_as(struct compiler *c, pattern_ty p, pattern_context *pc) } static int -compiler_pattern_star(struct compiler *c, pattern_ty p, pattern_context *pc) +codegen_pattern_star(struct compiler *c, pattern_ty p, pattern_context *pc) { assert(p->kind == MatchStar_kind); RETURN_IF_ERROR( @@ -6912,7 +6911,7 @@ validate_kwd_attrs(struct compiler *c, asdl_identifier_seq *attrs, asdl_pattern_ } static int -compiler_pattern_class(struct compiler *c, pattern_ty p, pattern_context *pc) +codegen_pattern_class(struct compiler *c, pattern_ty p, pattern_context *pc) { assert(p->kind == MatchClass_kind); asdl_pattern_seq *patterns = p->v.MatchClass.patterns; @@ -6969,14 +6968,14 @@ compiler_pattern_class(struct compiler *c, pattern_ty p, pattern_context *pc) ADDOP(c, LOC(p), POP_TOP); continue; } - RETURN_IF_ERROR(compiler_pattern_subpattern(c, pattern, pc)); + RETURN_IF_ERROR(codegen_pattern_subpattern(c, pattern, pc)); } // Success! Pop the tuple of attributes: return SUCCESS; } static int -compiler_pattern_mapping(struct compiler *c, pattern_ty p, +codegen_pattern_mapping(struct compiler *c, pattern_ty p, pattern_context *pc) { assert(p->kind == MatchMapping_kind); @@ -7053,7 +7052,7 @@ compiler_pattern_mapping(struct compiler *c, pattern_ty p, compiler_error(c, LOC(p), e); goto error; } - if (compiler_visit_expr(c, key) < 0) { + if (codegen_visit_expr(c, key) < 0) { goto error; } } @@ -7076,7 +7075,7 @@ compiler_pattern_mapping(struct compiler *c, pattern_ty p, for (Py_ssize_t i = 0; i < size; i++) { pc->on_top--; pattern_ty pattern = asdl_seq_GET(patterns, i); - RETURN_IF_ERROR(compiler_pattern_subpattern(c, pattern, pc)); + RETURN_IF_ERROR(codegen_pattern_subpattern(c, pattern, pc)); } // If we get this far, it's a match! Whatever happens next should consume // the tuple of keys and the subject: @@ -7111,7 +7110,7 @@ compiler_pattern_mapping(struct compiler *c, pattern_ty p, } static int -compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc) +codegen_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc) { assert(p->kind == MatchOr_kind); NEW_JUMP_TARGET_LABEL(c, end); @@ -7138,7 +7137,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc) pc->fail_pop_size = 0; pc->on_top = 0; if (codegen_addop_i(INSTR_SEQUENCE(c), COPY, 1, LOC(alt)) < 0 || - compiler_pattern(c, alt, pc) < 0) { + codegen_pattern(c, alt, pc) < 0) { goto error; } // Success! @@ -7239,7 +7238,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc) goto error; } if (dupe) { - compiler_error_duplicate_store(c, LOC(p), name); + codegen_error_duplicate_store(c, LOC(p), name); goto error; } if (PyList_Append(pc->stores, name)) { @@ -7263,7 +7262,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc) static int -compiler_pattern_sequence(struct compiler *c, pattern_ty p, +codegen_pattern_sequence(struct compiler *c, pattern_ty p, pattern_context *pc) { assert(p->kind == MatchSequence_kind); @@ -7321,7 +7320,7 @@ compiler_pattern_sequence(struct compiler *c, pattern_ty p, } static int -compiler_pattern_value(struct compiler *c, pattern_ty p, pattern_context *pc) +codegen_pattern_value(struct compiler *c, pattern_ty p, pattern_context *pc) { assert(p->kind == MatchValue_kind); expr_ty value = p->v.MatchValue.value; @@ -7337,7 +7336,7 @@ compiler_pattern_value(struct compiler *c, pattern_ty p, pattern_context *pc) } static int -compiler_pattern_singleton(struct compiler *c, pattern_ty p, pattern_context *pc) +codegen_pattern_singleton(struct compiler *c, pattern_ty p, pattern_context *pc) { assert(p->kind == MatchSingleton_kind); ADDOP_LOAD_CONST(c, LOC(p), p->v.MatchSingleton.value); @@ -7347,25 +7346,25 @@ compiler_pattern_singleton(struct compiler *c, pattern_ty p, pattern_context *pc } static int -compiler_pattern(struct compiler *c, pattern_ty p, pattern_context *pc) +codegen_pattern(struct compiler *c, pattern_ty p, pattern_context *pc) { switch (p->kind) { case MatchValue_kind: - return compiler_pattern_value(c, p, pc); + return codegen_pattern_value(c, p, pc); case MatchSingleton_kind: - return compiler_pattern_singleton(c, p, pc); + return codegen_pattern_singleton(c, p, pc); case MatchSequence_kind: - return compiler_pattern_sequence(c, p, pc); + return codegen_pattern_sequence(c, p, pc); case MatchMapping_kind: - return compiler_pattern_mapping(c, p, pc); + return codegen_pattern_mapping(c, p, pc); case MatchClass_kind: - return compiler_pattern_class(c, p, pc); + return codegen_pattern_class(c, p, pc); case MatchStar_kind: - return compiler_pattern_star(c, p, pc); + return codegen_pattern_star(c, p, pc); case MatchAs_kind: - return compiler_pattern_as(c, p, pc); + return codegen_pattern_as(c, p, pc); case MatchOr_kind: - return compiler_pattern_or(c, p, pc); + return codegen_pattern_or(c, p, pc); } // AST validator shouldn't let this happen, but if it does, // just fail, don't crash out of the interpreter @@ -7374,7 +7373,7 @@ compiler_pattern(struct compiler *c, pattern_ty p, pattern_context *pc) } static int -compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc) +codegen_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc) { VISIT(c, expr, s->v.Match.subject); NEW_JUMP_TARGET_LABEL(c, end); @@ -7398,7 +7397,7 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc) pc->fail_pop_size = 0; pc->on_top = 0; // NOTE: Can't use returning macros here (they'll leak pc->stores)! - if (compiler_pattern(c, m->pattern, pc) < 0) { + if (codegen_pattern(c, m->pattern, pc) < 0) { Py_DECREF(pc->stores); return ERROR; } @@ -7407,7 +7406,7 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc) Py_ssize_t nstores = PyList_GET_SIZE(pc->stores); for (Py_ssize_t n = 0; n < nstores; n++) { PyObject *name = PyList_GET_ITEM(pc->stores, n); - if (compiler_nameop(c, LOC(m->pattern), name, Store) < 0) { + if (codegen_nameop(c, LOC(m->pattern), name, Store) < 0) { Py_DECREF(pc->stores); return ERROR; } @@ -7416,7 +7415,7 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc) // NOTE: Returning macros are safe again. if (m->guard) { RETURN_IF_ERROR(ensure_fail_pop(c, pc, 0)); - RETURN_IF_ERROR(compiler_jump_if(c, LOC(m->pattern), m->guard, pc->fail_pop[0], 0)); + RETURN_IF_ERROR(codegen_jump_if(c, LOC(m->pattern), m->guard, pc->fail_pop[0], 0)); } // Success! Pop the subject off, we're done with it: if (i != cases - has_default - 1) { @@ -7442,7 +7441,7 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc) ADDOP(c, LOC(m->pattern), NOP); } if (m->guard) { - RETURN_IF_ERROR(compiler_jump_if(c, LOC(m->pattern), m->guard, end, 0)); + RETURN_IF_ERROR(codegen_jump_if(c, LOC(m->pattern), m->guard, end, 0)); } VISIT_SEQ(c, stmt, m->body); } @@ -7451,11 +7450,11 @@ compiler_match_inner(struct compiler *c, stmt_ty s, pattern_context *pc) } static int -compiler_match(struct compiler *c, stmt_ty s) +codegen_match(struct compiler *c, stmt_ty s) { pattern_context pc; pc.fail_pop = NULL; - int result = compiler_match_inner(c, s, &pc); + int result = codegen_match_inner(c, s, &pc); PyMem_Free(pc.fail_pop); return result; }