diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2025-05-30 21:14:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-30 21:14:52 +0000 |
commit | c75cf6fa89ba44e2fa74a15232593b2e8423ed3f (patch) | |
tree | a7f428153ad7b3109180af04a9c84af2b0ab2a16 /contrib/tools/cython/Cython/Compiler/FlowControl.py | |
parent | b21606bc4b50665ea3fdca703e13a4b4d7a44284 (diff) | |
parent | 8728b9da66674488bde07a092040097e46de9366 (diff) | |
download | ydb-c75cf6fa89ba44e2fa74a15232593b2e8423ed3f.tar.gz |
Library import 250529-1108 (#19003)
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler/FlowControl.py')
-rw-r--r-- | contrib/tools/cython/Cython/Compiler/FlowControl.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/FlowControl.py b/contrib/tools/cython/Cython/Compiler/FlowControl.py index c8575435738..a9965b76c69 100644 --- a/contrib/tools/cython/Cython/Compiler/FlowControl.py +++ b/contrib/tools/cython/Cython/Compiler/FlowControl.py @@ -1381,3 +1381,45 @@ class ControlFlowAnalysis(CythonTransform): self.mark_assignment(node.operand, fake_rhs_expr) self.visitchildren(node) return node + + def visit_BoolBinopNode(self, node): + # Note - I don't believe BoolBinopResultNode needs special handling beyond this + assert len(node.subexprs) == 2 # operand1 and operand2 only + + next_block = self.flow.newblock() + parent = self.flow.block + + self._visit(node.operand1) + + self.flow.nextblock() + self._visit(node.operand2) + if self.flow.block: + self.flow.block.add_child(next_block) + + parent.add_child(next_block) + + if next_block.parents: + self.flow.block = next_block + else: + self.flow.block = None + return node + + def visit_CondExprNode(self, node): + assert len(node.subexprs) == 3 + self._visit(node.test) + parent = self.flow.block + next_block = self.flow.newblock() + self.flow.nextblock() + self._visit(node.true_val) + if self.flow.block: + self.flow.block.add_child(next_block) + self.flow.nextblock(parent=parent) + self._visit(node.false_val) + if self.flow.block: + self.flow.block.add_child(next_block) + + if next_block.parents: + self.flow.block = next_block + else: + self.flow.block = None + return node |