MCPcopy Index your code
hub / github.com/python/mypy / process_conditional

Function process_conditional

mypyc/irbuild/ast_helpers.py:29–53  ·  view source on GitHub ↗
(
    self: IRBuilder, e: Expression, true: BasicBlock, false: BasicBlock
)

Source from the content-addressed store, hash-verified

27
28
29def process_conditional(
30 self: IRBuilder, e: Expression, true: BasicBlock, false: BasicBlock
31) -> None:
32 if isinstance(e, OpExpr) and e.op in ["and", "or"]:
33 if e.op == "and":
34 # Short circuit 'and' in a conditional context.
35 new = BasicBlock()
36 process_conditional(self, e.left, new, false)
37 self.activate_block(new)
38 process_conditional(self, e.right, true, false)
39 else:
40 # Short circuit 'or' in a conditional context.
41 new = BasicBlock()
42 process_conditional(self, e.left, true, new)
43 self.activate_block(new)
44 process_conditional(self, e.right, true, false)
45 elif isinstance(e, UnaryExpr) and e.op == "not":
46 process_conditional(self, e.expr, false, true)
47 else:
48 res = maybe_process_conditional_comparison(self, e, true, false)
49 if res:
50 return
51 # Catch-all for arbitrary expressions.
52 reg = self.accept(e)
53 self.add_bool_branch(reg, true, false)
54
55
56def maybe_process_conditional_comparison(

Callers 3

transform_if_stmtFunction · 0.90
transform_while_stmtFunction · 0.90

Calls 6

BasicBlockClass · 0.90
isinstanceFunction · 0.85
activate_blockMethod · 0.45
acceptMethod · 0.45
add_bool_branchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…