mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
GH-131498: Cases generator: Parse down to C statement level. (GH-131948)
* Parse down to statement level in the cases generator * Add handling for #if macros, treating them much like normal ifs.
This commit is contained in:
parent
6e91d1f9aa
commit
ad053d8d6a
16 changed files with 795 additions and 959 deletions
|
@ -367,34 +367,39 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_TO_BOOL, (value -- res)) {
|
||||
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
|
||||
if (!already_bool) {
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
}
|
||||
}
|
||||
|
||||
op(_TO_BOOL_BOOL, (value -- res)) {
|
||||
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
|
||||
if (!already_bool) {
|
||||
sym_set_type(value, &PyBool_Type);
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
}
|
||||
}
|
||||
|
||||
op(_TO_BOOL_INT, (value -- res)) {
|
||||
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
|
||||
if (!already_bool) {
|
||||
sym_set_type(value, &PyLong_Type);
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
}
|
||||
}
|
||||
|
||||
op(_TO_BOOL_LIST, (value -- res)) {
|
||||
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
|
||||
if (!already_bool) {
|
||||
sym_set_type(value, &PyList_Type);
|
||||
res = sym_new_type(ctx, &PyBool_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_TO_BOOL_NONE, (value -- res)) {
|
||||
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
|
||||
if (!already_bool) {
|
||||
sym_set_const(value, Py_None);
|
||||
res = sym_new_const(ctx, Py_False);
|
||||
}
|
||||
|
@ -415,7 +420,8 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_TO_BOOL_STR, (value -- res)) {
|
||||
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
||||
int already_bool = optimize_to_bool(this_instr, ctx, value, &res);
|
||||
if (!already_bool) {
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue