
     h                        S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSK	J
r
Jr  SSKJrJr  SS jrSS	 jr\" S
SS5      r\" SS5      r\" SS5      r " S S5      r\\\   \\   4   r\\\4   rSS jrSS jrg)z!Bytecode analysis for coverage.py    )annotationsN)Iterator)CodeType)IterableOptional)TArcTOffsetc              #     #    U /nU(       aY  UR                  5       n U R                   H+  n[        U[        5      (       d  M  UR	                  U5        M-     U v   U(       a  MX  gg7f)z,Iterate over all the code objects in `code`.N)pop	co_consts
isinstancer   append)codestackcs      o/root/racknerd_01/codex-conversation/amazon-q-terraform/.venv/lib/python3.13/site-packages/coverage/bytecode.pycode_objectsr      sP     FE
 yy{A!X&&Q   
 %s   =A' A'%A'c                     U  Vs1 s H-  n[         R                  R                  U5      =n(       d  M+  UiM/     sn$ s  snf )zwMake a set of opcodes from instruction names.

The names might not exist in this version of Python, skip those if not.
)disopmapget)op_namesnameops      r   op_setr      s3    
 $C84ciimmD.A(A(AB8CCCs   *<<JUMP_BACKWARDJUMP_BACKWARD_NO_INTERRUPTJUMP_FORWARDRETURN_VALUERETURN_GENERATORNOP	NOT_TAKENc                  @    \ rS rSrSrS
S jrSSS.     SS jjrSrg	)InstructionWalker:   aI  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)`.
c                    Xl         0 U l        S n[        R                  " U5       H  nX R                  UR                  '   M     Uc   eUR                  U l        g N)r   instsr   get_instructionsoffset
max_offset)selfr   insts      r   __init__InstructionWalker.__init__C   sQ    	57
((.D&*JJt{{# / ++    r   Tstart_atfollow_jumpsc             #  H  #    [        5       nUnX@R                  S-   :  a  XC;   a  gUR                  U5        U R                  R	                  U5      =n(       a-  Uv   U(       a"  UR
                  [        ;   a  UR                  nMx  US-  nX@R                  S-   :  a  M  gg7f)ze
Yield instructions starting from `start_at`.  Follow unconditional
jumps if `follow_jumps` is true.
      N)setr+   addr(   r   opcodeALWAYS_JUMPSjump_target)r,   r2   r3   seenr*   r-   s         r   walkInstructionWalker.walkN   s      u**~HHVzz~~f--t-
DKK<$?!--FaKF **s   BB" B")r   r(   r+   N)r   r   returnNone)r2   r	   r3   boolr?   zIterable[dis.Instruction])__name__
__module____qualname____firstlineno____doc__r.   r=   __static_attributes__ r0   r   r$   r$   :   s5    	& &'T"6:	" r0   r$   c                  ^ ^^	 [         R                  " S 5      n[        T 5      m	T	R                  SS9 H  nUR                  (       d  M  UR
                  [        ;   a  M,  UR                  mTc  M=        SU UU	4S jjn[         R                  " [        5      nU" XBR                  S-   S9  U" XBR                  S9  XAUR                  '   UR                  5        H$  u  pVU H  nX   U   R                  U5        M     M&     M     U$ )av  
Calculate branch trails for `code`.

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                 6    [         R                  " [        5      $ r'   )collectionsdefaultdictr7   rH   r0   r   <lambda>branch_trails.<locals>.<lambda>w   s    @W@WX[@\r0   Fr3   c                  > [        5       nS nTR                  USS9 H  nUR                  UR                  5        UR                  (       a  UR                  T:w  a  UR                  n  ONUR
                  (       a  UR                  [        ;  a    O'UR                  [        ;   d  M  TR                  * n  O   Ub  U TU4   R                  U5        g [        5       U S '   g )NTr1   )r7   r=   r8   r*   line_numberr;   r9   r:   RETURNSco_firstlinenoupdate)trailsr2   inst_offsetsto_lineinst2r   	from_lineiwalkers        r   add_one_branch_trail+branch_trails.<locals>.add_one_branch_trail   s    
 *-LG xdK  .$$):):i)G#//G&&ELL,L\\W,#222G L "	7+,33LA"utr0   r6   )r2   )rU   TBranchTrailsOneSourcer2   r	   r?   r@   )rK   rL   r$   r=   r;   r9   r:   rQ   r7   r*   itemsrT   )
r   
the_trailsr-   r[   rU   arcoffsetsr*   rY   rZ   s
   `       @@r   branch_trailsrb   g   s     !, 7 78\ ]J%G%0;;,&$$		%*	%	% 	% 	%0 *5)@)@)EVkkAo>V.>.>?"(4;; #LLNLC!"3'..w7 " +[ 1b r0   c                
   0 n[        U 5      nUR                  SS9 Hb  nUR                  [        ;   a  UR                  XR
                  '   M1  UR                  [        ;   d  MG  UR
                  S-   XR
                  '   Md     U$ )z}Make a map of unconditional bytecodes jumping to others.

Only include bytecodes that do no work and go to another bytecode.
FrO   r6   )r$   r=   r9   r:   r;   r*   NOPS)r   jumpsrZ   r-   s       r   always_jumpsrf      sm    
 E%G%0;;,&!%!1!1E++[[D !%qE++	 1
 Lr0   )r   r   r?   zIterator[CodeType])r   strr?   zset[int])r   r   r?   TBranchTrails)r   r   r?   zdict[TOffset, TOffset])rF   
__future__r   rK   r   collections.abcr   typesr   typingr   r   coverage.typesr   r	   r   r   r:   rR   rd   r$   dictr7   r]   rh   rb   rf   rH   r0   r   <module>ro      s    ( "  
 $  % (
D    	& &R htnc'l:; W445CLr0   