§
    0›jü!  ã                  ó@  — d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	 ddl
mZ ddlmZmZmZ  G d„ d	¦  «        Zd"d„Zd#d„Z eddd¦  «        Z edd¦  «        Z edd¦  «        Z G d„ d¦  «        Zeee         ee         f         Zeeef         Zd$d„Zd%d!„ZdS )&z!Bytecode analysis for coverage.pyé    )ÚannotationsN)ÚIterableÚMapping)ÚCodeType)ÚOptional)ÚTArcÚTLineNoÚTOffsetc                  óD   — e Zd ZdZddddœdd„Zdd„Zdd„Zdd„Zdd„ZdS )Ú
ByteParserz3Parse bytecode to understand the structure of code.N)ÚcodeÚtextÚfilenamer   úCodeType | Noner   ú
str | Noner   ÚreturnÚNonec               óJ   — |€|€J ‚t          ||pddd¬¦  «        }|| _        d S )Nz<string>ÚexecT)Údont_inherit)Úcompiler   )Úselfr   r   r   s       úP/home/lighthouse/health/venv/lib64/python3.11/site-packages/coverage/bytecode.pyÚ__init__zByteParser.__init__   s;   € ð ˆ<ØÐ#Ð#Ð#Ý˜4 Ð!7¨Z¸ÈdÐSÑSÔSˆDØˆŒ	ˆ	ˆ	ó    úIterable[ByteParser]c                ó>   — d„ |                       ¦   «         D ¦   «         S )a|  Iterate over all the code objects nested within this one.

        The iteration includes `self` as its first value.

        We skip code objects named `__annotate__` since they are deferred
        annotations that usually are never run.  If there are errors in the
        annotations, they will be caught by type checkers or other tools that
        use annotations.

        c              3  óL   K  — | ]}|j         d k    ¯t          |¬¦  «        V — Œ dS )Ú__annotate__)r   N)Úco_namer   )Ú.0Úcs     r   ú	<genexpr>z,ByteParser._child_parsers.<locals>.<genexpr>+   s:   è è € Ð_Ð_ qÀ1Ä9ÐP^ÒC^ÐC^•
 Ð"Ñ"Ô"ÐC^ÐC^ÐC^ÐC^Ð_Ð_r   )Úcode_objects)r   s    r   Ú_child_parserszByteParser._child_parsers    s%   € ð `Ð_¨D×,=Ò,=Ñ,?Ô,?Ð_Ñ_Ô_Ð_r   úIterable[CodeType]c              #  ó¾   K  — | j         g}|rP|                     ¦   «         }|j        D ],}t          |t          ¦  «        r|                     |¦  «         Œ-|V — |°NdS dS )z,Iterate over all the code objects in `code`.N)r   ÚpopÚ	co_constsÚ
isinstancer   Úappend)r   Ústackr   r"   s       r   r$   zByteParser.code_objects-   s€   è è € à”�ˆØð 	ð —9’9‘;”;ˆDØ”^ð $ð $�Ý˜a¥Ñ*Ô*ð $Ø—L’L ‘O”O�OøØˆJˆJˆJð ð 	ð 	ð 	ð 	ð 	r   úIterable[TLineNo]c              #  óV   K  — | j                              ¦   «         D ]\  }}}|r|V — ŒdS )zyYield the line numbers possible in this code object.

        Uses co_lines() to produce a sequence: l0, l1, ...
        N)r   Úco_lines)r   Ú_Úlines      r   Ú_line_numberszByteParser._line_numbers9   sG   è è € ð
 œ)×,Ò,Ñ.Ô.ð 	ð 	‰JˆAˆq�$Øð Ø�
�
�
øð	ð 	r   c              #  ól   K  — |                       ¦   «         D ]}|                     ¦   «         E d{V —† ŒdS )z´Find the statements in `self.code`.

        Produce a sequence of line numbers that start statements.  Recurses
        into all code objects reachable from `self.code`.

        N)r%   r2   )r   Úbps     r   Úfind_statementszByteParser.find_statementsB   sT   è è € ð ×%Ò%Ñ'Ô'ð 	*ð 	*ˆBà×'Ò'Ñ)Ô)Ð)Ð)Ð)Ð)Ð)Ð)Ð)Ð)ð	*ð 	*r   )r   r   r   r   r   r   r   r   )r   r   )r   r&   )r   r-   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r%   r$   r2   r5   © r   r   r   r      s—   € € € € € Ø=Ð=ð
 !%ØØ#ð
ð 
ð 
ð 
ð 
ð 
ð`ð `ð `ð `ð
ð 
ð 
ð 
ðð ð ð ð	*ð 	*ð 	*ð 	*ð 	*ð 	*r   r   r   r   r   údict[TOffset, TLineNo]c                óv   — i }|                       ¦   «         D ]!\  }}}|�t          ||d¦  «        D ]}|||<   ŒŒ"|S )z6Make a dict mapping byte code offsets to line numbers.Né   )r/   Úrange)r   Úb2lÚbstartÚbendÚlinenoÚboffsets         r   Úbytes_to_linesrD   N   sW   € à
€CØ $§¢¡¤ð &ð &Ñˆ��fØÐÝ  ¨¨qÑ1Ô1ð &ð &�Ø%��G‘�øØ€Jr   Úop_namesÚstrúset[int]c                 óB   ‡— ˆfd„| D ¦   «         }|sJ d| › �¦   «         ‚|S )zMake a set of opcodes from instruction names.

    The names might not exist in this version of Python, skip those if not.
    c                óV   •— h | ]%}t           j                             |¦  «        xŠ¯#‰’Œ&S r:   )ÚdisÚopmapÚget)r!   ÚnameÚops     €r   ú	<setcomp>zop_set.<locals>.<setcomp>]   s1   ø€ Ð
BÐ
BÐ
B�$­S¬Y¯]ª]¸4Ñ-@Ô-@Ð'@ rÐ
Bˆ2Ð
BÐ
BÐ
Br   z At least one opcode must exist: r:   )rE   ÚopsrN   s     @r   Úop_setrQ   X   sA   ø€ ð
 CÐ
BÐ
BÐ
B˜(Ð
BÑ
BÔ
B€CØÐ=Ð=Ð=°8Ð=Ð=Ñ=Ô=Ð=Ø€Jr   ÚJUMP_BACKWARDÚJUMP_BACKWARD_NO_INTERRUPTÚJUMP_FORWARDÚRETURN_VALUEÚRETURN_GENERATORÚNOPÚ	NOT_TAKENc                  ó*   — e Zd ZdZdd„Zddd	œdd„ZdS )ÚInstructionWalkera]  Utility to step through trails of instructions.

    We have two reasons to need sequences of instructions from a code object:
    First, in strict sequence to visit all the instructions in the object.
    This is `walk(follow_jumps=False)`.  Second, we want to follow jumps to
    understand how execution will flow: `walk(follow_jumps=True)`.
    r   r   r   r   c                ó’   — || _         i | _        d }t          j        |¦  «        D ]}|| j        |j        <   Œ|€J ‚|j        | _        d S ©N)r   ÚinstsrJ   Úget_instructionsÚoffsetÚ
max_offset)r   r   Úinsts      r   r   zInstructionWalker.__init__   sY   € ØˆŒ	Ø57ˆŒ
àˆÝÔ(¨Ñ.Ô.ð 	+ð 	+ˆDØ&*ˆDŒJ�t”{Ñ#Ð#àÐÐÐØœ+ˆŒˆˆr   r   T©Ústart_atÚfollow_jumpsrc   r
   rd   ÚboolúIterable[dis.Instruction]c             #  ó  K  — t          ¦   «         }|}|| j        dz   k     rh||v rdS |                     |¦  «         | j                             |¦  «        x}r|V — |r|j        t          v r|j        }Œa|dz  }|| j        dz   k     °fdS dS )z}
        Yield instructions starting from `start_at`.  Follow unconditional
        jumps if `follow_jumps` is true.
        é   r=   N)Úsetr`   Úaddr]   rL   ÚopcodeÚALWAYS_JUMPSÚjump_target)r   rc   rd   Úseenr_   ra   s         r   ÚwalkzInstructionWalker.walkŠ   s´   è è € õ ‰uŒuˆØˆØ�t”¨Ñ*Ò*Ð*Ø˜ˆ~ˆ~Ø�Ø�HŠH�VÑÔÐØ”z—~’~ fÑ-Ô-Ð-ˆtð Ø�
�
�
Øð  D¤Kµ<Ð$?Ð$?Ø!Ô-�FØØ�a‰KˆFð �t”¨Ñ*Ò*Ð*Ð*Ð*Ð*Ð*r   N)r   r   r   r   )rc   r
   rd   re   r   rf   )r6   r7   r8   r9   r   ro   r:   r   r   rZ   rZ   v   sW   € € € € € ðð ð	&ð 	&ð 	&ð 	&ð &'¸Tðð ð ð ð ð ð ð r   rZ   Úmultiline_mapúMapping[TLineNo, TLineNo]ÚTBranchTrailsc                ó  ‡ ‡‡	‡
— t          j        d„ ¦  «        }t          ‰ ¦  «        Š
‰
                     d¬¦  «        D ]Ì}|j        sŒ
|j        t          v rŒ|j        Š	‰	€Œ#‰                     ‰	‰	¦  «        Š	dˆ ˆ	ˆ
ˆfd„}t          j        t          ¦  «        } |||j
        dz   ¬¦  «          |||j        ¬¦  «         |||j
        <   |                     ¦   «         D ]+\  }}|D ]#}||         |                              |¦  «         Œ$Œ,ŒÍ|S )a  
    Calculate branch trails for `code`.

    `multiline_map` maps line numbers to the first line number of a
    multi-line statement.

    Instructions can have a jump_target, where they might jump to next.  Some
    instructions with a jump_target are unconditional jumps (ALWAYS_JUMPS), so
    they aren't interesting to us, since they aren't the start of a branch
    possibility.

    Instructions that might or might not jump somewhere else are branch
    possibilities.  For each of those, we track a trail of instructions.  These
    are lists of instruction offsets, the next instructions that can execute.
    We follow the trail until we get to a new source line.  That gives us the
    arc from the original instruction's line to the new source line.

    c                 ó4   — t          j        t          ¦  «        S r\   )ÚcollectionsÚdefaultdictri   r:   r   r   ú<lambda>zbranch_trails.<locals>.<lambda>¹   s   € ÅÔ@WÕX[Ñ@\Ô@\€ r   F©rd   NÚtrailsÚTBranchTrailsOneSourcerc   r
   r   r   c                ó¨  •— t          ¦   «         }d }‰                     |d¬¦  «        D ]v}|                     |j        ¦  «         |j        }|�‰	                     ||¦  «        }|r
|‰k    r|} n0|j        r|j        t          vr n|j        t          v r
‰j
         } nŒw|�| ‰|f                              |¦  «         d S t          ¦   «         | d <   d S )NTrb   )ri   ro   rj   r_   Úline_numberrL   rm   rk   rl   ÚRETURNSÚco_firstlinenoÚupdate)
ry   rc   Úinst_offsetsÚto_lineÚinst2Úl2r   Ú	from_lineÚiwalkerrp   s
         €€€€r   Úadd_one_branch_trailz+branch_trails.<locals>.add_one_branch_trailÈ   sÿ   ø€ õ
 *-©¬ˆLØˆGØ Ÿš¨xÀd˜ÑKÔKð ð �Ø× Ò  ¤Ñ.Ô.Ð.ØÔ&�Ø�>Ø&×*Ò*¨2¨rÑ2Ô2�BØð ˜" 	š/˜/Ø �GØ�EØÔ&ð ¨E¬LÅÐ,LÐ,LØ�EØ”\¥WÐ,Ð,Ø#Ô2Ð2�GØ�Eð -ð Ð"Ø˜	 7Ð+Ô,×3Ò3°LÑAÔAÐAÐAÐAå"™uœu��t‘��r   r=   )rc   )ry   rz   rc   r
   r   r   )ru   rv   rZ   ro   rm   rk   rl   r|   rL   ri   r_   Úitemsr   )r   rp   Ú
the_trailsra   r†   ry   ÚarcÚoffsetsr_   r„   r…   s   ``       @@r   Úbranch_trailsr‹   £   si  øøøø€ õ, !,Ô 7Ð8\Ð8\Ñ ]Ô ]€JÝ Ñ%Ô%€GØ—’¨%�Ñ0Ô0ð 38ð 38ˆØÔð 	àØŒ;�,Ð&Ð&ààÔ$ˆ	ØÐØØ!×%Ò% i°Ñ;Ô;ˆ	ð	%ð 	%ð 	%ð 	%ð 	%ð 	%ð 	%ð 	%ð 	%õ6 *5Ô)@ÅÑ)EÔ)EˆØÐ˜V¨d¬k¸A©oÐ>Ñ>Ô>Ð>ØÐ˜V¨dÔ.>Ð?Ñ?Ô?Ð?Ø"(ˆ
�4”;Ñð #ŸLšL™NœNð 	8ð 	8‰LˆC�Ø!ð 8ð 8�Ø˜6Ô" 3Ô'×.Ò.¨wÑ7Ô7Ð7Ð7ð8ð	8ð Ðr   údict[TOffset, TOffset]c                óÖ   — i }t          | ¦  «        }|                     d¬¦  «        D ]@}|j        t          v r|j        ||j        <   Œ |j        t          v r|j        dz   ||j        <   ŒA|S )z…Make a map of unconditional bytecodes jumping to others.

    Only include bytecodes that do no work and go to another bytecode.
    Frx   r=   )rZ   ro   rk   rl   rm   r_   ÚNOPS)r   Újumpsr…   ra   s       r   Úalways_jumpsr�   ó   sw   € ð
 €EÝ Ñ%Ô%€GØ—’¨%�Ñ0Ô0ð 1ð 1ˆØŒ;�,Ð&Ð&Ø!%Ô!1ˆE�$”+ÑÐØŒ[�DÐ Ð Ø!%¤¨q¡ˆE�$”+ÑøØ€Lr   )r   r   r   r;   )rE   rF   r   rG   )r   r   rp   rq   r   rr   )r   r   r   rŒ   )r9   Ú
__future__r   ru   rJ   Úcollections.abcr   r   Útypesr   Útypingr   Úcoverage.typesr   r	   r
   r   rD   rQ   rl   r}   rŽ   rZ   Údictri   rz   rr   r‹   r�   r:   r   r   ú<module>r—      s·  ðð (Ð 'à "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø 
€
€
€
Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1ð:*ð :*ð :*ð :*ð :*ñ :*ô :*ð :*ðzð ð ð ðð ð ð ð ˆvØØ Øñô €ð ˆ&ØØñô €ð €vØ	Øñô €ð&ð &ð &ð &ð &ñ &ô &ð &ðR ˜h tœn¨c°'¬lÐ:Ô;Ð Ø�WÐ4Ð4Ô5€ðMð Mð Mð Mð`ð ð ð ð ð r   