§
    ¹³ÙgÝ  ã                  óŠ   — d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
 ej        rddlmZ ddlmZ  G d	„ d
ee¦  «        ZdS )z5Container to encapsulate all control flow operations.é    )ÚannotationsN)ÚABCÚabstractmethod)ÚInstruction)ÚCircuitError)ÚQuantumCircuit)Úexprc                  ój   ‡ — e Zd ZdZˆ fd„Zeedd„¦   «         ¦   «         Zedd„¦   «         Zdd
„Z	ˆ xZ
S )ÚControlFlowOpa  Abstract class to encapsulate all control flow operations.

    All subclasses of :class:`ControlFlowOp` have an internal attribute,
    :attr:`~ControlFlowOp.blocks`, which exposes the inner subcircuits used in the different blocks
    of the control flow.
    c                óz   •—  t          ¦   «         j        |i |¤Ž | j        D ]}|j        rt	          d¦  «        ‚Œd S )Nz2control-flow blocks cannot contain input variables)ÚsuperÚ__init__ÚblocksÚnum_input_varsr   )ÚselfÚargsÚkwargsÚblockÚ	__class__s       €ú]/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/controlflow/control_flow.pyr   zControlFlowOp.__init__$   s_   ø€ Ø�‰ŒÔ˜$Ð) &Ð)Ð)Ð)Ø”[ð 	Yð 	YˆEØÔ#ð YÝ"Ð#WÑXÔXÐXðYð	Yð 	Yó    Úreturnútuple[QuantumCircuit, ...]c                ó   — dS )z{Tuple of :class:`.QuantumCircuit`\ s which may be executed as part of the
        execution of this :class:`ControlFlowOp`.N© )r   s    r   r   zControlFlowOp.blocks*   ó   € € € r   r   útyping.Iterable[QuantumCircuit]c                ó   — dS )a—  Return a new version of this control-flow operations with the :attr:`blocks` mapped to
        the given new ones.

        Typically this is used in a workflow such as::

            existing_op = ...

            def map_block(block: QuantumCircuit) -> QuantumCircuit:
                new_block = block.copy_empty_like()
                # ... do something to `new_block` ...
                return new_block

            new_op = existing_op.replace_blocks(
                map_block(block) for block in existing_op.blocks
            )

        It is the caller's responsibility to ensure that the mapped blocks are defined over a
        unified set of circuit resources, much like constructing a :class:`ControlFlowOp` using its
        default constructor.

        Args:
            blocks: the new subcircuit blocks to use.

        Returns:
            New :class:`ControlFlowOp` with replaced blocks.
        Nr   )r   r   s     r   Úreplace_blockszControlFlowOp.replace_blocks0   r   r   útyping.Iterable[expr.Var]c              #  ó¢   K  — t          ¦   «         }| j        D ]6}|                     ¦   «         D ]}||vr|                     |¦  «         |V — Œ Œ7dS )zSGet an iterator over the unique captured variables in all blocks of this construct.N)Úsetr   Úiter_captured_varsÚadd)r   Úseenr   Úvars       r   r#   z ControlFlowOp.iter_captured_varsM   sl   è è € å‰uŒuˆØ”[ð 	ð 	ˆEØ×/Ò/Ñ1Ô1ð ð �Ø˜d�?�?Ø—H’H˜S‘M”M�MØ�I�I�Iøðð	ð 	r   )r   r   )r   r   r   r   )r   r    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r#   Ú__classcell__)r   s   @r   r   r      s¥   ø€ € € € € ðð ðYð Yð Yð Yð Yð Øð5ð 5ð 5ñ „^ñ „Xð5ð ðð ð ñ „^ðð8ð ð ð ð ð ð ð r   r   )r*   Ú
__future__r   ÚtypingÚabcr   r   Úqiskit.circuit.instructionr   Úqiskit.circuit.exceptionsr   ÚTYPE_CHECKINGÚqiskit.circuitr   Úqiskit.circuit.classicalr	   r   r   r   r   ú<module>r5      sÉ   ðð 8Ð 7à "Ð "Ð "Ð "Ð "Ð "à €€€Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #à 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2à	Ôð .Ø-Ð-Ð-Ð-Ð-Ð-Ø-Ð-Ð-Ð-Ð-Ð-ð8ð 8ð 8ð 8ð 8�K ñ 8ô 8ð 8ð 8ð 8r   