@internal<EOL>def ternaryOpsToIf(statements):
stms = []<EOL>for st in statements:<EOL><INDENT>if isinstance(st, Assignment):<EOL><INDENT>try:<EOL><INDENT>if not isinstance(st.src, RtlSignalBase):<EOL><INDENT>raise DoesNotContainsTernary()<EOL><DEDENT>d = st.src.singleDriver()<EOL>if not isinstance(d, Operator) or d.operator != AllOps.TERNARY:<EOL><INDENT>raise DoesNotContainsTernary()<EOL><DEDENT>else:<EOL><INDENT>ops = d.operands<EOL>ifc = IfContainer(ops[<NUM_LIT:0>],<EOL>[Assignment(ops[<NUM_LIT:1>], st.dst)],<EOL>[Assignment(ops[<NUM_LIT:2>], st.dst)]<EOL>)<EOL>stms.append(ifc)<EOL>continue<EOL><DEDENT><DEDENT>except (MultipleDriversErr, DoesNotContainsTernary):<EOL><INDENT>pass<EOL><DEDENT>except NoDriverErr:<EOL><INDENT>assert (hasattr(st.src, "<STR_LIT>")<EOL>and st.src._interface is not None)or st.src.defVal.vldMask, st.src<EOL><DEDENT><DEDENT>stms.append(st)<EOL><DEDENT>return stms<EOL>
Convert all ternary operators to IfContainers