Skip to content

Commit 41e77a8

Browse files
committed
Use the new truth symbols
1 parent dcb294c commit 41e77a8

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Python/optimizer_bytecodes.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ typedef struct _Py_UOpsAbstractFrame _Py_UOpsAbstractFrame;
3434
#define sym_tuple_getitem _Py_uop_sym_tuple_getitem
3535
#define sym_tuple_length _Py_uop_sym_tuple_length
3636
#define sym_is_immortal _Py_uop_sym_is_immortal
37+
#define sym_new_truth _Py_uop_sym_new_truth
3738

3839
extern int
3940
optimize_to_bool(
@@ -391,14 +392,14 @@ dummy_func(void) {
391392

392393
op(_TO_BOOL, (value -- res)) {
393394
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
394-
res = sym_new_type(ctx, &PyBool_Type);
395+
res = sym_new_truth(ctx, value, false);
395396
}
396397
}
397398

398399
op(_TO_BOOL_BOOL, (value -- res)) {
399400
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
400401
sym_set_type(value, &PyBool_Type);
401-
res = value;
402+
res = sym_new_truth(ctx, value, false);
402403
}
403404
}
404405

@@ -430,6 +431,11 @@ dummy_func(void) {
430431
}
431432
}
432433

434+
op(_UNARY_NOT, (value -- res)) {
435+
sym_set_type(value, &PyBool_Type);
436+
res = sym_new_truth(ctx, value, true);
437+
}
438+
433439
op(_COMPARE_OP, (left, right -- res)) {
434440
if (oparg & 16) {
435441
res = sym_new_type(ctx, &PyBool_Type);

Python/optimizer_cases.c.h

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)