Return true if `op` is the Switch for a conditional.
(op)
| 110 | |
| 111 | |
| 112 | def IsCondSwitch(op): |
| 113 | """Return true if `op` is the Switch for a conditional.""" |
| 114 | if not IsSwitch(op): |
| 115 | return False |
| 116 | if not op.outputs: |
| 117 | return False |
| 118 | # Switch nodes are not part of the cond control flow context that they |
| 119 | # represent, so consider the consumers of its outputs to determine if it is |
| 120 | # cond switch or not. A switch is a cond switch iff all its consumers are in |
| 121 | # cond contexts. |
| 122 | is_cond_switch = True |
| 123 | for o in op.outputs: |
| 124 | for c in o.consumers(): |
| 125 | ctxt = c._get_control_flow_context() # pylint: disable=protected-access |
| 126 | if IsLoopEnter(c): |
| 127 | ctxt = ctxt.outer_context |
| 128 | is_cond_switch = is_cond_switch and (ctxt is not None and |
| 129 | ctxt.IsCondContext()) |
| 130 | return is_cond_switch |
| 131 | |
| 132 | |
| 133 | def IsCondMerge(op): |
no test coverage detected