Skip to content

Commit 036088d

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Emit TO_BOOL in 3.14 static python code gen
Summary: The static compiler needs to emit `TO_BOOL` before instructions which need it. We just use the helpers that were added for non-static Python. Reviewed By: mpage Differential Revision: D83692711 fbshipit-source-id: 3f1e1a35e7b33c4b6279582d47e0cdbf48af48e1
1 parent eb299c2 commit 036088d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • cinderx/PythonLib/cinderx/compiler/static

cinderx/PythonLib/cinderx/compiler/static/types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,9 @@ def emit_jumpif(
11531153
def emit_jumpif_only(
11541154
self, next: Block, is_if_true: bool, code_gen: StaticCodeGenBase
11551155
) -> None:
1156-
code_gen.emit("POP_JUMP_IF_TRUE" if is_if_true else "POP_JUMP_IF_FALSE", next)
1156+
code_gen.emit_cond_jump(
1157+
"POP_JUMP_IF_TRUE" if is_if_true else "POP_JUMP_IF_FALSE", next
1158+
)
11571159

11581160
def emit_jumpif_pop(
11591161
self, test: AST, next: Block, is_if_true: bool, code_gen: StaticCodeGenBase
@@ -1164,7 +1166,7 @@ def emit_jumpif_pop(
11641166
def emit_jumpif_pop_only(
11651167
self, next: Block, is_if_true: bool, code_gen: StaticCodeGenBase
11661168
) -> None:
1167-
code_gen.emit(
1169+
code_gen.emit_cond_jump(
11681170
"JUMP_IF_TRUE_OR_POP" if is_if_true else "JUMP_IF_FALSE_OR_POP", next
11691171
)
11701172

0 commit comments

Comments
 (0)