
    xKg                     R   d Z ddlZddlmZ ddlZddlmZmZmZ ddl	m
Z
 ddlmZmZmZ ddlmZmZ ddlmZ dd	lmZ  ej,                  e      Zd
ZeZ eh d      Zedv rddlmZ  G d de      ZeZ nedv rn e!e      e
 G d de"             Z# G d de"      Z$ G d de"      Z%d Z& G d de"      Z'e
 G d de"             Z( G d de(      Z)edk\  re)Z*nedk  re(Z*n e!e       edg d       Z+ G d! d"e"      Z, ed#g d$      Z-d% Z.d& Z/ G d' d(e"      Z0 G d) d*e"      Z1y)+z)
Implement python 3.8+ bytecode analysis
    N)pformat)
namedtupledefaultdictdeque)total_ordering)
UniqueDict	PYVERSIONALL_BINOPS_TO_OPERATORS)NEW_BLOCKERSCFGraph)Loc)UnsupportedError   >   NOPPRECALL
LOAD_CONST
LOAD_DEREF      )Enumc                       e Zd ZdZdZdZy)CALL_INTRINSIC_1_Operandr      r   N)__name__
__module____qualname__INTRINSIC_STOPITERATION_ERRORUNARY_POSITIVEINTRINSIC_LIST_TO_TUPLE     W/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/core/byteflow.pyr   r      s    ()%"#r#   r   r   	   r   
   r      c                   B    e Zd ZdZ eh d      Zd Zd Zd Zd Z	d Z
y)		BlockKindz?Kinds of block to make related code safer than just `str`.
    >   TRYLOOPWITHEXCEPTFINALLYWITH_FINALLYc                 2    || j                   v sJ || _        y N)_members_value)selfvalues     r$   __init__zBlockKind.__init__4   s    %%%r#   c                 B    t        t        |       | j                  f      S r5   )hashtyper7   r8   s    r$   __hash__zBlockKind.__hash__8   s    T$Z-..r#   c                     t        |t              r| j                  |j                  k  S t        dj	                  t        |                  Nzcannot compare to {!r}
isinstancer-   r7   	TypeErrorformatr=   r8   others     r$   __lt__zBlockKind.__lt__;   s:    eY';;--4;;DKHIIr#   c                     t        |t              r| j                  |j                  k(  S t        dj	                  t        |                  rA   rB   rF   s     r$   __eq__zBlockKind.__eq__A   s:    eY';;%,,..4;;DKHIIr#   c                 8    dj                  | j                        S )NzBlockKind({}))rE   r7   r>   s    r$   __repr__zBlockKind.__repr__G   s    %%dkk22r#   N)r   r   r   __doc__	frozensetr6   r:   r?   rH   rJ   rL   r"   r#   r$   r-   r-   *   s1      H/JJ3r#   r-   c                       e Zd Zd Zd Zy)_lazy_pformatc                      || _         || _        y r5   )argskwargs)r8   rR   rS   s      r$   r:   z_lazy_pformat.__init__L   s    	r#   c                 @    t        | j                  i | j                  S r5   )r   rR   rS   r>   s    r$   __str__z_lazy_pformat.__str__P   s    		1T[[11r#   N)r   r   r   r:   rU   r"   r#   r$   rP   rP   K   s    2r#   rP   c                   d    e Zd ZdZd Zd Zedv rd Znedv rd Zn ee      d Z	d	 Z
d
 Zd Zy)FlowziData+Control Flow analysis.

    Simulate execution to recover dataflow and controlflow information.
    c                 x    t         j                  d|j                                || _        t	               | _        y )Nzbytecode dump:
%s)_loggerdebugdump	_bytecoder   block_infos)r8   bytecodes     r$   r:   zFlow.__init__Y   s(    *HMMO<!%<r#   c                    t        | j                  ddd      }t        | j                  j                  j                        }|j
                  j                  |       t               }|j
                  rlt        j                  d|j
                         |j
                  j                         }||j                  vrt        j                  d|j                         t        j                  d|       |||j                  <   	 |j                  |       |j                         rnG| j!                  ||      rn4| j#                  |      r"| j%                  |       |j'                          nit        j                  d|j(                         |j                  j+                  |       |j-                         }|j
                  j/                  |       |j
                  rl| j1                  |j                         | j3                  |       t5        |j                  d	 
      D ]=  }t7        |      x| j8                  |j                  <   }t        j                  d||       ? y)a  Run a trace over the bytecode over all reachable path.

        The trace starts at bytecode offset 0 and gathers stack and control-
        flow information by partially interpreting each bytecode.
        Each ``State`` instance in the trace corresponds to a basic-block.
        The State instances forks when a jump instruction is encountered.
        A newly forked state is then added to the list of pending states.
        The trace ends when there are no more pending states.
        r   r"   )r^   pcnstack
blockstack)debug_filenamezpending: %sz	stack: %szstate.pc_initial: %szend state. edges=%sc                     | j                   S r5   )
pc_initial)xs    r$   <lambda>zFlow.run.<locals>.<lambda>   s    1<<r#   )keyzblock_infos %s:
%sN)Stater\   TraceRunnerfunc_idfilenamependingappendr   rY   rZ   popleftfinished_stackre   dispatchhas_terminated_run_handle_exception_is_implicit_new_block_guard_with_assplit_new_blockoutgoing_edgesaddget_outgoing_statesextend
_build_cfg_prune_phissortedadapt_state_infosr]   )r8   
firststaterunnerfirst_encounterstate
out_statessis          r$   runzFlow.run^   s    DNNq&(*
DNN,B,B,K,KLj)
 %, nnMM-8NN**,EFOO+k5<<84e<49 0 01OOE*++-55feD!66u= //6!113!  3U5I5IJ##E*"668
%%j15 nn: 	( FOO1GHE6G6NNDU--.MM/; Ir#   r*   r   c                    |j                         sl|j                         r\|j                         j                  t        vr<|j                  |j                         j                         |j                  |       y|j                          |j                         s|j                         rt        j                  d|j                         |j                         |j                         }|j                  d      }|r|d   |j                  k(  rd }y |j!                  d|j                        }|j"                  |d<   |j$                  |d<   |j&                  |d	<   |j                  |j                  |
       yy y )Nr`   Tz3.11 exception %s PC=%sr.   endr   
end_offsetstack_depth
push_lastir`   extra_block)in_withhas_active_tryget_instopname_NO_RAISE_OPSforknext_adjust_except_stack
advance_pcis_in_exceptionrY   rZ   get_exception_pcget_top_blocktarget
make_blockr   depthlasti)r8   r   r   eheh_topeh_blocks         r$   rt   zFlow._run_handle_exception   s3   ==?((*NN$++=@

enn.33
4++E2  " }}5+@+@+BMM";"'"5"5"7D,,.B"007F&-299"<#'#(#3#3Eryy#3#I13.24((/13.

eiiX
F# ,Cr#   r&   r(   c                    |j                         r|j                         j                  t        vr|j	                  |j                         j
                         |j                  d      }|j                  |       |j                  }i }||d   kD  r||d   z
  |d<   |d   }t        d      t        t        d      t        i|d      |d	<   ||d
<    |j                  dd|d   i| y|j                          y )Nr   r.   entry_stacknpophandlerr1   r2   kindnpushr   r`   r   Tr"   )r   r   r   r   r   r   r   pop_block_and_abover   r-   _EXCEPT_STACK_OFFSET_FINALLY_POPr   )r8   r   r   tryblkra   rS   r   s          r$   rt   zFlow._run_handle_exception   s    $$&NN$++=@

enn.33
4,,U3))&1**F=11%+f].C%CF6N +h')=i(,# &/##w )0}%

6fUm6v6  "r#   c                 .   t               }|D ]  }|j                  }|j                  |       ! |D ]:  }|j                  D ])  }|j	                  |j                  |j
                  d       + < |j                  d       |j                          || _        y )Nr   )	r   re   add_noderx   add_edger`   set_entry_pointprocesscfgraph)r8   
all_statesgraphr   bedges         r$   r|   zFlow._build_cfg   s    	E  ANN1    E,,u//!< -   	a r#   c                 N  	 t         j                  dj                  dd             fd}	fd}	fd}fd} |       \  }	t         j                  dt        |              |       \  }} ||        |||       t         j                  d	j                  dd             y )
Nz
Prune PHIs<   -c                      t        t              } t               }j                  D ]A  }t        |j                        }t        |j                        }| |xx   ||z  z  cc<   ||z  }C | |fS r5   )r   setrp   
_used_regs_phis)	used_phisphi_setr   usedphisr   s        r$   get_used_phis_per_statez1Flow._prune_phis.<locals>.get_used_phis_per_state   sj    #C(IeG5++,5;;'% D4K/ 4	 )
 g%%r#   c                  N   i } t        t              }j                  D ]C  }|j                  j	                         D ]$  \  }}|vr|| |<   ||   j                  ||f       & E t        j                  dt        |              t        j                  dt        |             | |fS )Nz
defmap: %szphismap: %s)	r   r   rp   _outgoing_phisitemsry   rY   rZ   rP   )defmapphismapr   phirhsr   r   s        r$   find_use_defsz'Flow._prune_phis.<locals>.find_use_defs   s    F!#&G % 4 4 : : <HC')&+sCL$$c5\2	 != ) MM,f(=>MM-w)?@7?"r#   c                 d   t        t              }	 d}t        t        | j	                                     D ]V  \  }}t        t        |            D ](  \  }}|v s|| |   z  }||   j                  ||f       * ||   }||z  sP||z  }d}X t        j                  dt        |              |sy)znAn iterative dataflow algorithm to find the definition
            (the source) of each PHI node.
            TFzchanging phismap: %sN)	r   r   r~   listr   ry   rY   rZ   rP   )	r   	blacklistchangingr   defsitesr   r   	to_remover   s	           r$   propagate_phi_mapz+Flow._prune_phis.<locals>.propagate_phi_map   s     $C(I %+D,A%BMC&,T(^&<
U'>$4H%cN..U|< '= !*#I 8+ I-#' &C 4mG6LM r#   c                    i }| j                         D ]  \  }}|D ]
  }||   ||<     t        j                  dt        |             t	        t
              }|D ]  }||   D ]  \  }}|||   |<     t        j                  dt        |             j                  D ]:  }|j                  j                          |j                  j                  ||          < y )Nzkeep phismap: %sznew_out: %s)
r   rY   rZ   rP   r   dictrp   r   clearupdate)	r   r   keepr   used_setr   new_outr   r   s	           r$   apply_changesz'Flow._prune_phis.<locals>.apply_changes  s    D#,??#4x#C 'DI $ $5 MM,mD.AB!$'G"&s)JC*-GEN3' #,  MM-w)?@$$**,$$++GEN; )r#   zUsed_phis: %szDONE Prune PHIs)rY   rZ   centerrP   )
r8   r   r   r   r   r   r   r   r   r   s
    `       @r$   r}   zFlow._prune_phis   s    l))"c23	&	#	,	<  56	7o}Y'?@'/'"i)'..r378r#   c                     |j                         }|j                  | j                  j                  v ry|j                  t
        v ryy)NTF)r   offsetr\   labelsr   r   r8   r   insts      r$   ru   zFlow._is_implicit_new_block&  s9    ~~;;$..///[[L(r#   c                     |j                         }|j                  dv r6| j                  |j                     j                  }|dk7  rd}t	        |      yy)zChecks if the next instruction after a SETUP_WITH is something other
        than a POP_TOP, if it is something else it'll be some sort of store
        which is not supported (this corresponds to `with CTXMGR as VAR(S)`).>   
SETUP_WITHBEFORE_WITHPOP_TOPzGThe 'with (context manager) as (variable):' construct is not supported.N)r   r   r\   r   r   )r8   r   current_instnext_opmsgs        r$   rv   zFlow._guard_with_as0  s`     ~~'"??nn\%6%67>>G)#$ 's++	 $ @r#   N)r   r   r   rM   r:   r   r	   rt   NotImplementedErrorr|   r}   ru   rv   r"   r#   r$   rW   rW   T   sU    (
8<t &&	$6 
'	'	#, "),,
K9Z,r#   rW   c                 $    | j                  d      S )Nz$null$)
startswith)regs    r$   _is_null_temp_regr   >  s    >>(##r#   c                   x   e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zedv rd Znedv rd Zn ee      d Zd Zd Zd Zd Zd Zedv reZeZnedv rn ee      d Zd Zd Zd Zd Z d  Z!d! Z"d" Z#d# Z$d$ Z%d% Z&d& Z'd' Z(d( Z)d) Z*d* Z+d+ Z,edv rd, Z-nedv rn ee      edv rd- Z.nedv rn ee      d. Z/e/Z0e/Z1edv re/Z2e/Z3nedv rn ee      d/ Z4e4Z5e4Z6d0 Z7d1 Z8d2 Z9d3 Z:d4 Z;d5 Z<d6 Z=d7 Z>d8 Z?d9 Z@d: ZAd; ZBd< ZCedv rd= ZDnedv rn ee      d> ZEedv rd? ZFnedv rd@ ZFn ee      dA ZGdB ZHedv rdC ZInedv rn ee      dD ZJdE ZKdF ZLdG ZMdH ZNdI ZOdJ ZPdK ZQdL ZRdM ZSdN ZTedv rdO ZUnedv rdP ZUn ee      dQ ZVdR ZWdS ZXdT ZYdU ZZdV Z[dW Z\dX Z]dY Z^dZ Z_edv rd[ Z`nedv rn ee      d\ Zad] Zbd^ Zcd_ Zdd` Zeda Zfdb Zgdc Zhdd Zide Zjdf Zkdg Zldh Zmdi Zndj Zodk Zpdl Zqdm Zrdn Zsdo Ztdp Zudq Zvdr Zwds Zxdt Zydu Zzdv Z{dw Z|e|Z}e|Z~e|Ze|Zdx ZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZddyZdz Zd{ Zd| Zd} Zd~ Zedv rd Znedv rd Zn ee      edv r	 d Zyedv rd Zd Zyedv rd Zd Zy ee      )rj   zLTrace runner contains the states for the trace and the opcode dispatch.
    c                 N    || _         t               | _        t               | _        y r5   )rc   r   rm   r   rp   )r8   rc   s     r$   r:   zTraceRunner.__init__E  s    ,wr#   c                 .    t        | j                  |      S r5   )r   rc   )r8   linenos     r$   get_debug_loczTraceRunner.get_debug_locJ  s    4&&//r#   c                    t         dv rg|j                  rs|j                  rg|j                  d   }|d   }|*||j                  k  r|j                  j                          nn&|j                  rNnt         dv rnt	        t               |j                         }|j                  dk7  rAt        j                  d|j                  |       t        j                  d|j                         t        | dj                  |j                        d       }|
 |||       y d	|j                  z  }t        || j                  |j                        
      )Nr   r   r   CACHEzdispatch pc=%s, inst=%szstack %szop_{}z$Use of unsupported opcode (%s) foundloc)r	   _blockstackre   popr   r   r   rY   rZ   r   rq   getattrrE   r   r   r   )r8   r   topblkblk_endr   fnr   s          r$   rr   zTraceRunner.dispatchM  s   **  ''"..r2F$UmG*w%:J:J/J))--/ '' ++%i00~~;;'!MM3UYYEMM*ell3T7>>$++6=>udO84;;FC"3D,>,>t{{,KLLr#   c                     |j                  d      }|j                  |       |j                  }i }|d   }||kD  r||z
  |d<   d}|d   r|dz  }||d<    |j                  d
d|d   i| y	)zo
        Adjust stack when entering an exception handler to match expectation
        by the bytecode.
        r.   r   r      r   r   r`   r   Nr"   )r   r   r   r   )r8   r   r   ra   rS   expected_depthextra_stacks          r$   r   z TraceRunner._adjust_except_stackg  s    
 $$U+!!&)"".N"#n4F6N,1K%w

.fUm.v.r#   c                 &    |j                  |       y r5   rn   r   s      r$   op_NOPzTraceRunner.op_NOP{      Tr#   c                 &    |j                  |       y r5   r  r   s      r$   	op_RESUMEzTraceRunner.op_RESUME~  r  r#   c                 &    |j                  |       y r5   r  r   s      r$   op_CACHEzTraceRunner.op_CACHE  r  r#   c                 &    |j                  |       y r5   r  r   s      r$   
op_PRECALLzTraceRunner.op_PRECALL  r  r#   c                 d    |j                  |j                                |j                  |       y r5   )push	make_nullrn   r   s      r$   op_PUSH_NULLzTraceRunner.op_PUSH_NULL  s!    

5??$%Tr#   c                 d    |j                  |j                                |j                  |       y r5   )r  	make_temprn   r   s      r$   op_RETURN_GENERATORzTraceRunner.op_RETURN_GENERATOR  s#     	

5??$%Tr#   c                    |j                   dk7  r(d}t        || j                  |j                              |j	                         }|j                         }|j                         }|j                  ||||       |j                  |       y)aF  
        FORMAT_VALUE(flags): flags argument specifies format spec which is
        not supported yet. Currently, we just call str() on the value.
        Pops a value from stack and pushes results back.
        Required for supporting f-strings.
        https://docs.python.org/3/library/dis.html#opcode-FORMAT_VALUE
        r   z*format spec in f-strings not supported yetr   )r9   resstrvarN)argr   r   r   r   r  rn   r  )r8   r   r   r   r9   r  r  s          r$   op_FORMAT_VALUEzTraceRunner.op_FORMAT_VALUE  sr     88q=>C"3D,>,>t{{,KLL		"ooTC?

3r#   c           	      r   |j                   }t        t        t        |      D cg c]  }|j	                          c}            }|dk(  r|j                         g}n)t        |dz
        D cg c]  }|j                          }}|j                  |||       |j                  |d          yc c}w c c}w )z
        BUILD_STRING(count): Concatenates count strings from the stack and
        pushes the resulting string onto the stack.
        Required for supporting f-strings.
        https://docs.python.org/3/library/dis.html#opcode-BUILD_STRING
        r   r   )stringstmpsr   Nr  r   reversedranger   r  rn   r  )r8   r   r   count_r  r  s          r$   op_BUILD_STRINGzTraceRunner.op_BUILD_STRING  s     xeEl Cll CDEA:OO%&D/4UQY/?@/?!EOO%/?D@T76

48 !D
 As   B/-B4c                 $    |j                          y r5   r   r   s      r$   
op_POP_TOPzTraceRunner.op_POP_TOP  s    		r#   r   c                     |j                         }|j                  dz	  }|j                  |||       |j                  dz  r|j                  |j	                                |j                  |       y )Nr   )idxr  )r  r  rn   r  r  )r8   r   r   r  r&  s        r$   op_LOAD_GLOBALzTraceRunner.op_LOAD_GLOBAL  sV    //#C((a-CLL3CL0xx!|

5??,-JJsOr#   r   c                 l    |j                         }|j                  ||       |j                  |       y Nr  r  rn   r  r8   r   r   r  s       r$   r'  zTraceRunner.op_LOAD_GLOBAL  s)    //#CLL3L'JJsOr#   c                 &    |j                  |       y r5   r  r   s      r$   op_COPY_FREE_VARSzTraceRunner.op_COPY_FREE_VARS  r  r#   c                 &    |j                  |       y r5   r  r   s      r$   op_MAKE_CELLzTraceRunner.op_MAKE_CELL  r  r#   c                 l    |j                         }|j                  ||       |j                  |       y r)  r+  r,  s       r$   op_LOAD_DEREFzTraceRunner.op_LOAD_DEREF  )    ooTs#

3r#   c                 n    |j                  d      }|j                  |       |j                  ||       y )Nconstr*  )r  r  rn   r,  s       r$   op_LOAD_CONSTzTraceRunner.op_LOAD_CONST  s+    oog&

3Ts#r#   c                 ,   |j                         }t        dv r/|j                  dz  r8|j                  |j	                                nt        dv rnt        t              |j                         }|j                  |||       |j                  |       y )Nr   r   r%   itemr  )r   r	   r  r  r  r   r  rn   )r8   r   r   r9  r  s        r$   op_LOAD_ATTRzTraceRunner.op_LOAD_ATTR  ss    yy{#xx!|

5??,-44%i00ooT#.

3r#   c                     |j                  |      }|j                  |      }|j                  ||       |j                  |       y r)  )get_varnamer  rn   r  )r8   r   r   namer  s        r$   op_LOAD_FASTzTraceRunner.op_LOAD_FAST  s;      &ood#Ts#

3r#   r   r%   c                 &    |j                  |       y r5   r  r   s      r$   op_DELETE_FASTzTraceRunner.op_DELETE_FAST  r  r#   c                 J    |j                         }|j                  ||       y )N)r   r   rn   )r8   r   r   r   s       r$   op_DELETE_ATTRzTraceRunner.op_DELETE_ATTR  s    T&)r#   c                 l    |j                         }|j                         }|j                  |||       y )N)r   r9   rB  )r8   r   r   r   r9   s        r$   op_STORE_ATTRzTraceRunner.op_STORE_ATTR   s*    		T&6r#   c                 J    |j                         }|j                  ||       y N)r9   rB  r8   r   r   r9   s       r$   op_STORE_DEREFzTraceRunner.op_STORE_DEREF      		T'r#   c                 J    |j                         }|j                  ||       y rG  rB  rH  s       r$   op_STORE_FASTzTraceRunner.op_STORE_FAST	  rJ  r#   c           	         |j                         }|j                         }|j                         }|j                         }|j                         }|j                         }|j                  |||||||       |j                  |       y)z"
        TOS = TOS1[TOS:]
        )basestartr  slicevarindexvarnonevarNr   r  rn   r  	r8   r   r   tostos1r  rP  rQ  rR  s	            r$   
op_SLICE_1zTraceRunner.op_SLICE_1  s}     iikyy{oo??$??$//# 	 	
 	

3r#   c           	         |j                         }|j                         }|j                         }|j                         }|j                         }|j                         }|j                  |||||||       |j                  |       y)z"
        TOS = TOS1[:TOS]
        )rN  stopr  rP  rQ  rR  NrS  rT  s	            r$   
op_SLICE_2zTraceRunner.op_SLICE_2"  s}     iikyy{oo??$??$//# 	 	
 	

3r#   c           	         |j                         }|j                         }|j                         }|j                         }|j                         }|j                         }|j                  |||||||       |j                  |       y)z&
        TOS = TOS2[TOS1:TOS]
        )rN  rO  rY  r  rP  rQ  NrS  )	r8   r   r   rU  rV  tos2r  rP  rQ  s	            r$   
op_SLICE_3zTraceRunner.op_SLICE_37  s|     iikyy{yy{oo??$??$ 	 	
 	

3r#   c                     |j                         }|j                         }|j                         }|j                         }|j                         }|j                  ||||||       y)z
        TOS[:] = TOS1
        )rN  r9   rP  rQ  rR  Nr   r  rn   )r8   r   r   rU  r9   rP  rQ  rR  s           r$   op_STORE_SLICE_0zTraceRunner.op_STORE_SLICE_0L  sa     iik		??$??$//# 	 	
r#   c           	          |j                         }|j                         }|j                         }|j                         }|j                         }|j                         }|j                  |||||||       y)z#
        TOS1[TOS:] = TOS2
        )rN  rO  rP  r9   rQ  rR  Nr_  	r8   r   r   rU  rV  r9   rP  rQ  rR  s	            r$   op_STORE_SLICE_1zTraceRunner.op_STORE_SLICE_1^  so     iikyy{		??$??$//# 	 	
r#   c           	          |j                         }|j                         }|j                         }|j                         }|j                         }|j                         }|j                  |||||||       y)z#
        TOS1[:TOS] = TOS2
        )rN  rY  r9   rP  rQ  rR  Nr_  rb  s	            r$   op_STORE_SLICE_2zTraceRunner.op_STORE_SLICE_2r  so     iikyy{		??$??$//# 	 	
r#   c           	          |j                         }|j                         }|j                         }|j                         }|j                         }|j                         }|j                  |||||||       y)z'
        TOS2[TOS1:TOS] = TOS3
        )rN  rO  rY  r9   rP  rQ  Nr_  )	r8   r   r   rU  rV  r\  r9   rP  rQ  s	            r$   op_STORE_SLICE_3zTraceRunner.op_STORE_SLICE_3  sn     iikyy{yy{		??$??$ 	 	
r#   c                     |j                         }|j                         }|j                         }|j                         }|j                  |||||       y)z
        del TOS[:]
        )rN  rP  rQ  rR  Nr_  )r8   r   r   rU  rP  rQ  rR  s          r$   op_DELETE_SLICE_0zTraceRunner.op_DELETE_SLICE_0  sP     iik??$??$//#sX 	 	
r#   c                     |j                         }|j                         }|j                         }|j                         }|j                         }|j                  ||||||       y)z 
        del TOS1[TOS:]
        )rN  rO  rP  rQ  rR  Nr_  r8   r   r   rU  rV  rP  rQ  rR  s           r$   op_DELETE_SLICE_1zTraceRunner.op_DELETE_SLICE_1  sa     iikyy{??$??$//# 	 	
r#   c                     |j                         }|j                         }|j                         }|j                         }|j                         }|j                  ||||||       y)z 
        del TOS1[:TOS]
        )rN  rY  rP  rQ  rR  Nr_  rk  s           r$   op_DELETE_SLICE_2zTraceRunner.op_DELETE_SLICE_2  sa     iikyy{??$??$//# 	 	
r#   c                     |j                         }|j                         }|j                         }|j                         }|j                         }|j                  ||||||       y)z$
        del TOS2[TOS1:TOS]
        )rN  rO  rY  rP  rQ  Nr_  )r8   r   r   rU  rV  r\  rP  rQ  s           r$   op_DELETE_SLICE_3zTraceRunner.op_DELETE_SLICE_3  s\     iikyy{yy{??$??$t4cH 	 	
r#   c                    |j                   }|dk(  r'|j                         }|j                         }|}|}d}nG|dk(  r7|j                         }|j                         }|j                         }	|	}|}|}nt        d      |j                         }
|j                         }|j	                  ||||||
       |j                  |       y)z<
        slice(TOS1, TOS) or slice(TOS2, TOS1, TOS)
           Nr   unreachable)rO  rY  stepr  rP  )r  r   	Exceptionr  rn   r  )r8   r   r   argcrU  rV  rO  rY  rt  r\  rP  r  s               r$   op_BUILD_SLICEzTraceRunner.op_BUILD_SLICE  s     xx19))+C99;DEDDQY))+C99;D99;DEDDM**??$ooDtx 	 	
 	

3r#   c           	         |j                         }|j                         }|j                         }|j                         }|j                         }|j                         }|j                  |||||||       |j                  |       y )N)rO  r   	containerr  rP  temp_resrS  )	r8   r   r   r   rO  ry  rz  r  rP  s	            r$   op_BINARY_SLICEzTraceRunner.op_BINARY_SLICE  su    ))+CIIKE		I(H//#C(HLLEsiS!H   JJsOr#   c           	          |j                         }|j                         }|j                         }|j                         }|j                         }|j                         }|j                  |||||||       y )N)rO  r   ry  r9   r  rP  r_  )	r8   r   r   r   rO  ry  r9   rP  r  s	            r$   op_STORE_SLICEzTraceRunner.op_STORE_SLICE  sg    ))+CIIKE		IIIKE(H//#CLLEsiu(  r#   c                     |j                         }|j                  ||       |j                         }|j                  }|j	                  |       ||k7  r|j	                  |       y y )Npredr   )r   rn   get_jump_targetr   r   )r8   r   r   r  target_inst	next_insts         r$   _op_POP_JUMP_IFzTraceRunner._op_POP_JUMP_IF  s_    yy{T%**,II	 	

i
 )#JJ+J& $r#   c                     |j                         }|j                  ||       |j                  |j                  d       |j                  |j	                                y )Nr  r   r`   r   r   )get_tosrn   r   r   r  )r8   r   r   r  s       r$   _op_JUMP_IF_OR_POPzTraceRunner._op_JUMP_IF_OR_POP/  sH    }}T%

diia
(

d**,
-r#   c                 (    | j                  ||       y r5   r  r   s      r$   op_POP_JUMP_FORWARD_IF_NONEz'TraceRunner.op_POP_JUMP_FORWARD_IF_NONE8      UD)r#   c                 (    | j                  ||       y r5   r  r   s      r$   op_POP_JUMP_FORWARD_IF_NOT_NONEz+TraceRunner.op_POP_JUMP_FORWARD_IF_NOT_NONE;  r  r#   c                 (    | j                  ||       y r5   r  r   s      r$   op_POP_JUMP_BACKWARD_IF_NONEz(TraceRunner.op_POP_JUMP_BACKWARD_IF_NONE>  r  r#   c                 (    | j                  ||       y r5   r  r   s      r$    op_POP_JUMP_BACKWARD_IF_NOT_NONEz,TraceRunner.op_POP_JUMP_BACKWARD_IF_NOT_NONEA  r  r#   c                 (    | j                  ||       y r5   r  r   s      r$   op_POP_JUMP_FORWARD_IF_FALSEz(TraceRunner.op_POP_JUMP_FORWARD_IF_FALSED  r  r#   c                 (    | j                  ||       y r5   r  r   s      r$   op_POP_JUMP_FORWARD_IF_TRUEz'TraceRunner.op_POP_JUMP_FORWARD_IF_TRUEG  r  r#   c                 (    | j                  ||       y r5   r  r   s      r$   op_POP_JUMP_BACKWARD_IF_FALSEz)TraceRunner.op_POP_JUMP_BACKWARD_IF_FALSEJ  r  r#   c                 (    | j                  ||       y r5   r  r   s      r$   op_POP_JUMP_BACKWARD_IF_TRUEz(TraceRunner.op_POP_JUMP_BACKWARD_IF_TRUEM  r  r#   c                 f    |j                  |       |j                  |j                                y Nr   rn   r   r  r   s      r$   op_JUMP_FORWARDzTraceRunner.op_JUMP_FORWARDP  %    T

d**,
-r#   c                 f    |j                  |       |j                  |j                                y r  r  r   s      r$   op_JUMP_BACKWARDzTraceRunner.op_JUMP_BACKWARDT  r  r#   c                 f    |j                  |       |j                  |j                                y r  r  r   s      r$   op_JUMP_ABSOLUTEzTraceRunner.op_JUMP_ABSOLUTEX  r  r#   c                     |j                  d      d   }|j                  ||       |j                          |j                  |       y )Nr/   r   r   r   )r   rn   	pop_blockr   )r8   r   r   r   s       r$   op_BREAK_LOOPzTraceRunner.op_BREAK_LOOP\  s?    !!&)%0Ts#

c
r#   c                     |j                  ||j                         |j                                |j                          y )Nretvalcastval)rn   r   r  	terminater   s      r$   op_RETURN_VALUEzTraceRunner.op_RETURN_VALUEc  s+    T%))+u7HIr#   c                     |j                  d      }|j                  |||j                                |j                          y )Nr5  r  )r  rn   r  r,  s       r$   op_RETURN_CONSTzTraceRunner.op_RETURN_CONSTh  s3    //'*CLLc5??3DLEOOr#   c                     |j                         }|j                         }|j                  |||       |j                  |       y N)r9   r  rS  r8   r   r   valr  s        r$   op_YIELD_VALUEzTraceRunner.op_YIELD_VALUEq  6    iikooT#.

3r#   c                 r   |j                   dk(  r8d }|j                         rQt        d| j                  |j                              |j                   dk(  r|j                         }nt        d      |j                  ||       |j                         r| j                  |       y |j                          y )Nr   4The re-raising of an exception is not yet supported.r   r   )Multiple argument raise is not supported.exc)
r  r   r   r   r   r   
ValueErrorrn   r   r  r8   r   r   r  s       r$   op_RAISE_VARARGSzTraceRunner.op_RAISE_VARARGSx  s    xx1} '')*N ..t{{;  Qiik !LMMLL3L'##%))%0!r#   c                 p   t        |j                  d      d u|j                  d      d ug      }|j                  dk(  r*d }|rQt        d| j	                  |j
                              |j                  dk(  r|j                         }nt        d      |j                  ||       |j                          y )	Nr1   r2   r   r  r   r   r  r  )
anyr   r  r   r   r   r   r  rn   r  )r8   r   r   in_exc_blockr  s        r$   r  zTraceRunner.op_RAISE_VARARGS  s    ##H-T9##I.d:  L xx1}*N ..t{{;  Qiik !LMMLL3L'OOr#   c                     g }t        t              D ]4  }|j                         }|j                  |       |j	                  |       6 |j                  ||       y )N)temps)r  r   r  rn   r  )r8   r   r   r  itmps         r$   op_BEGIN_FINALLYzTraceRunner.op_BEGIN_FINALLY  sL    +,A//#CLLJJsO - 	T'r#   c                 L    |j                         }|j                  |d          y )Nr   )r  reset_stackr8   r   r   blks       r$   op_END_FINALLYzTraceRunner.op_END_FINALLY  s!    oo#m,-r#   c                 D    |j                          |j                          y r5   r#  r   s      r$   
op_END_FORzTraceRunner.op_END_FOR  s    IIKIIKr#   c                 r    |j                   dk7  r(d}t        || j                  |j                              y )Nr   zGUnsupported use of a bytecode related to try..finally or a with-contextr   )r  r   r   r   )r8   r   r   r   s       r$   op_POP_FINALLYzTraceRunner.op_POP_FINALLY  s5    88q=(C"3D,>,>t{{,KLL r#   c                      y r5   r"   r   s      r$   op_CALL_FINALLYzTraceRunner.op_CALL_FINALLY  s    r#   c                 $    |j                          y r5   )r  r   s      r$   op_WITH_EXCEPT_STARTz TraceRunner.op_WITH_EXCEPT_START  s    r#   c                 &    |j                  |       y r5   r  r   s      r$   op_WITH_CLEANUP_STARTz!TraceRunner.op_WITH_CLEANUP_START      Tr#   c                 &    |j                  |       y r5   r  r   s      r$   op_WITH_CLEANUP_FINISHz"TraceRunner.op_WITH_CLEANUP_FINISH  r  r#   c                 d    |j                  |j                  d|j                                      y )Nr/   r   r   )
push_blockr   r  r   s      r$   op_SETUP_LOOPzTraceRunner.op_SETUP_LOOP  s2    ((*  	
r#   c                 B   |j                         }|j                         }|j                  d      }|j                  |       |j                  |       |j                  }|j	                  |j
                        }|g}|j                  D ]-  }	|	j                  |j                  k(  s|j                  |	       / t        d |D              }
|j                  ||||
       |j                  |j                  d|
             |j                  |j
                         y )Nsetup_with_exitfnprefixc              3   4   K   | ]  }|j                     y wr5   r   ).0r   s     r$   	<genexpr>z-TraceRunner.op_BEFORE_WITH.<locals>.<genexpr>  s     -9R"&&9s   )contextmanagerexitfnr   r0   r  r   )r   r  r  r\   find_exception_entryr   exception_entriesr   rn   maxr  r   r   )r8   r   r   cmyieldedr  bcehhead	ehrelatedr   r   s              r$   op_BEFORE_WITHzTraceRunner.op_BEFORE_WITH  s    YY[//#(;<

6

7 __((3H	&&ByyFMM)  $ ' -9--T"VE  	
 	

dii
 r#   c                    |j                         }|j                         }|j                  d      }|j                  |||       t        dk  r0|j	                  |j                  d|j                                      |j                  |       |j                  |       |j	                  |j                  d|j                                      |j                  |j                         y )	Nr  r  )r  r  r&   r3   r  r0   r   )
r   r  rn   r	   r  r   r  r  r   r   )r8   r   r   r  r  r  s         r$   op_SETUP_WITHzTraceRunner.op_SETUP_WITH  s    YY[//#(;<T"V< v  ',,. !  	

6

7((*  	
 	

dii
 r#   c           	      x    |j                  |d d      }|j                  ||j                  d|d|             y )NF)r   r   r  r.   )r   r   r  r   r   )r   r   )r8   r   r   r   r   handler_blocks         r$   
_setup_tryzTraceRunner._setup_try  sW     (( ) 
 	

((!%	 )  	 	
r#   c                     |j                         }|j                  |j                  d             |j                  |       y )N	exception)r   r  r  )r8   r   r   rU  s       r$   op_PUSH_EXC_INFOzTraceRunner.op_PUSH_EXC_INFO$  s-    iik

5??;/0

3r#   c                     |j                  |       | j                  d||j                  |j                                y )Nr2   )r   r   )rn   r  r   r  r   s      r$   op_SETUP_FINALLYzTraceRunner.op_SETUP_FINALLY)  s5    Tu499$2F2F2H 	 	
r#   c                 $    |j                          y r5   r#  r   s      r$   op_POP_EXCEPTzTraceRunner.op_POP_EXCEPT0  s    IIKr#   c                 J   |j                         }|d   t        d      t        d      hvr,t        d|d    | j                  |j                              |j                          |j                          |j                          |j                  |j                         y )Nr   r1   r2   z$POP_EXCEPT got an unexpected block: r   r   )r  r-   r   r   r   r   r   r   r  s       r$   r  zTraceRunner.op_POP_EXCEPT4  s    //#C6{9X#6	)8L"MM&:3v;-H**4;;7  IIKIIKIIKJJ$))J$r#   c                     |j                         }|d   t        d      k(  r|j                  |d       n$|d   t        d      k(  r|j                  |d       |j                  |j                         y )Nr   r.   try)r   r0   withr   )r  r-   rn   r   r   r  s       r$   op_POP_BLOCKzTraceRunner.op_POP_BLOCKC  sb    oov;)E**LLEL*[If--LLFL+

dii
 r#   c                     |j                         }|j                         }|j                         }|j                  ||||       |j                  |       y )N)indexr   r  rS  )r8   r   r   r  r   r  s         r$   op_BINARY_SUBSCRzTraceRunner.op_BINARY_SUBSCRK  sC    		ooTv3?

3r#   c                     |j                         }|j                         }|j                         }|j                  ||||       y )N)r   r  r9   rB  )r8   r   r   r  r   r9   s         r$   op_STORE_SUBSCRzTraceRunner.op_STORE_SUBSCRR  s7    				T&UCr#   c                 l    |j                         }|j                         }|j                  |||       y )N)r   r  rB  )r8   r   r   r  r   s        r$   op_DELETE_SUBSCRzTraceRunner.op_DELETE_SUBSCRX  s*    		T&6r#   c           	         |j                   }t        t        t        |      D cg c]  }|j	                          c}            }|j	                         }|j	                         }t        |      r|}n|}|g|}|j                         }	|j                         }
|j                  ||||
|	       |j                  |	       y c c}w )N)funcrR   kw_namesr  )
r  r   r  r  r   r   r  pop_kw_namesrn   r  )r8   r   r   nargr   rR   callable_or_firstargnull_or_callablecallabler  r  s              r$   op_CALLzTraceRunner.op_CALL]  s    xxH5;?;aeiik;?@A$yy{ 99;-.+H'H(040Doo%%'TthCP

3 @s   Cc                 :    |j                  |j                         y r5   )set_kw_namesr  r   s      r$   op_KW_NAMESzTraceRunner.op_KW_NAMESm  s    488$r#   c           	      $   |j                   }t        t        t        |      D cg c]  }|j	                          c}            }|j	                         }|j                         }|j                  ||||       |j                  |       y c c}w )N)r  rR   r  r  )r8   r   r   r	  r   rR   r  r  s           r$   op_CALL_FUNCTIONzTraceRunner.op_CALL_FUNCTIONp  so    xxH5;?;aeiik;?@Ayy{ooT4S9

3 @s   Bc           	      F   |j                   }|j                         }t        t        t	        |      D cg c]  }|j                          c}            }|j                         }|j                         }|j                  |||||       |j                  |       y c c}w )N)r  rR   namesr  )r  r   r   r  r  r  rn   r  )	r8   r   r   r	  r  r   rR   r  r  s	            r$   op_CALL_FUNCTION_KWzTraceRunner.op_CALL_FUNCTION_KWy  s|    xx		H5;?;aeiik;?@Ayy{ooT4u#F

3 @s   Bc                    |j                   dz  rt        dk  rd}t        |      |j                   dz  r|j                         }nd }|j                         }|j                         }t        dv r+t	        |j                  d            r)|j                          nt        dv rnt        t              |j                         }|j                  |||||       |j                  |       y )Nr   r(   z,CALL_FUNCTION_EX with **kwargs not supportedr   r   )r  varargvarkwargr  )
r  r	   r   r   r   peekr   r  rn   r  )r8   r   r   errmsgr  r  r  r  s           r$   op_CALL_FUNCTION_EXzTraceRunner.op_CALL_FUNCTION_EX  s    88a<I/CF"6**88a<yy{HHyy{** A/		++%i00ooTVhCP

3r#   c                 X   t        |      D cg c]  }|j                          }}|j                          t        |      D cg c]  }|j                          }}|j	                  |||       |D ]  }|j                  |        |D ]  }|j                  |        y c c}w c c}w )N)origduped)r  r   reverser  rn   r  )r8   r   r   r  r   r  r  r  s           r$   	_dup_topxzTraceRunner._dup_topx  s    %*5\2\		\2 -2%L9Lq"L9TE2CJJsO CJJsO  3 :s   B"B'c                 f   	 t        |j                        }|t        j
                  k(  r$|j                  ||       |j                          y |t        j                  k(  rG|j                         }|j                         }|j                  ||||       |j                  |       y |t        j                  k(  rG|j                         }|j                         }|j                  ||||       |j                  |       y t        |      # t        $ r t        d|j                   d      w xY w)Nzop_CALL_INTRINSIC_1())operand)r#  r9   r  )r#  
const_listr  )r   r  rD   r   ci1opr   rn   r  r    r   r  r  r!   )r8   r   r   r#  r  r  rU  s          r$   op_CALL_INTRINSIC_1zTraceRunner.op_CALL_INTRINSIC_1  s   N2488< %===T73!E000iikoo'T7#&C  1

3E999iikoo'T7(+  6

3)'22+  N),@
!*LMMNs   D #D0c                 v    |j                   }d|cxk  rdk  sJ d        J d       | j                  |||       y )Nr   r   zInvalid DUP_TOPX count)r  r   )r8   r   r   r  s       r$   op_DUP_TOPXzTraceRunner.op_DUP_TOPX  s<    EQ8 888 88udE*r#   c                 ,    | j                  ||d       y )Nr   r  r   r   s      r$   
op_DUP_TOPzTraceRunner.op_DUP_TOP      ud!,r#   c                 ,    | j                  ||d       y )Nrr  r*  r+  r   s      r$   op_DUP_TOP_TWOzTraceRunner.op_DUP_TOP_TWO  r-  r#   c                 X    |j                  |j                  |j                               y r5   )r  r  r  r   s      r$   op_COPYzTraceRunner.op_COPY  s    

5::dhh'(r#   c                 :    |j                  |j                         y r5   )swapr  r   s      r$   op_SWAPzTraceRunner.op_SWAP  s    

488r#   c                     |j                         }|j                         }|j                  |       |j                  |       y r5   r   r  )r8   r   r   firstseconds        r$   
op_ROT_TWOzTraceRunner.op_ROT_TWO  s0    		

5

6r#   c                     |j                         }|j                         }|j                         }|j                  |       |j                  |       |j                  |       y r5   r6  )r8   r   r   r7  r8  thirds         r$   op_ROT_THREEzTraceRunner.op_ROT_THREE  sG    				

5

5

6r#   c                    |j                         }|j                         }|j                         }|j                         }|j                  |       |j                  |       |j                  |       |j                  |       y r5   r6  )r8   r   r   r7  r8  r;  forths          r$   op_ROT_FOURzTraceRunner.op_ROT_FOUR  s^    						

5

5

5

6r#   c                    |j                   }|j                         }t        |      D cg c]  }|j                          }}|j                         }|j	                  ||||       t        |      D ]  }|j                  |        y c c}w )N)iterablestorestupleobj)r  r   r  r  rn   r  r  )	r8   r   r   r  rA  r   rB  rC  sts	            r$   op_UNPACK_SEQUENCEzTraceRunner.op_UNPACK_SEQUENCE  st    99;-25\:\%//#\:??$THVhO6"BJJrN # ;s   B
c           	         |j                   }t        t        t        |      D cg c]  }|j	                          c}            }|j                         }|j                  |||       |j                  |       y c c}w N)r   r  r  )r8   r   r   r  r   r   tups          r$   op_BUILD_TUPLEzTraceRunner.op_BUILD_TUPLE  b    XE%LALquyy{LABCooTC0

3 B   A<c           	         t        t        t        |j                        D cg c]  }|j	                          c}            }t        t        |      dz
        D cg c]  }|j                          }}t        |      dk(  }|r|j                         g}|j                  ||||       |j                  |d          y c c}w c c}w )Nr   )tuplesr  	is_assignr   )	r   r  r  r  r   lenr  rn   r  )r8   r   r   r   rM  r  rN  s          r$   _build_tuple_unpackzTraceRunner._build_tuple_unpack  s    hU488_E_		_EFG,1#f+/,BC,Bq",BC K1$	__&(ET&K

59  FCs   CCc                 (    | j                  ||       y r5   rP  r   s      r$   op_BUILD_TUPLE_UNPACK_WITH_CALLz+TraceRunner.op_BUILD_TUPLE_UNPACK_WITH_CALL  s      -r#   c                 (    | j                  ||       y r5   rR  r   s      r$   op_BUILD_TUPLE_UNPACKz!TraceRunner.op_BUILD_TUPLE_UNPACK  s      -r#   c                     |j                         }|j                         }|j                  |||       |j                  |       y )N)r$  r  rS  )r8   r   r   rU  r  s        r$   op_LIST_TO_TUPLEzTraceRunner.op_LIST_TO_TUPLE  s8     iikooTcs3

3r#   c           	         |j                         }t        t        t        |j                        D cg c]  }|j                          c}            }t        |j                        D cg c]  }|j                          }}|j                         }|j                  |||||       |j                  |       y c c}w c c}w )N)keyskeytmpsvaluesr  )r   r   r  r  r  r  rn   r  )r8   r   r   rY  r   valsrZ  r  s           r$   op_BUILD_CONST_KEY_MAPz"TraceRunner.op_BUILD_CONST_KEY_MAP  s    yy{H5?C?aeiik?CDE.3DHHo>o5??$o>ooTgdL

3	 D>s   B<+Cc           	         |j                   }t        t        t        |      D cg c]  }|j	                          c}            }|j                         }|j                  |||       |j                  |       y c c}w rG  r  )r8   r   r   r  r   r   lsts          r$   op_BUILD_LISTzTraceRunner.op_BUILD_LIST'  rJ  rK  c                     |j                         }|j                  }|j                  |      }|j                         }|j                         }|j	                  |||||       y )N)r   r9   	appendvarr  r   r  r  r  rn   )r8   r   r   r9   r  r   rb  r  s           r$   op_LIST_APPENDzTraceRunner.op_LIST_APPEND.  X    		E"OO%	ooT& 	 	r#   c                     |j                         }|j                  }|j                  |      }|j                         }|j                         }|j	                  |||||       y )N)r   r9   	extendvarr  rc  )r8   r   r   r9   r  r   rg  r  s           r$   op_LIST_EXTENDzTraceRunner.op_LIST_EXTEND7  re  r#   c                    |j                         }|j                  }g }t        |      D ]5  }|j                         |j                         }}|j	                  ||f       7 |j	                  ||d d d   ||       |j                  |       y )Nr   )r   sizer  )r  r  r  r   rn   r  )	r8   r   r   dctr  r   r  vks	            r$   op_BUILD_MAPzTraceRunner.op_BUILD_MAP@  sx    oouA99;		qALL!Q   	Ttt5cB

3r#   c                     |j                         }|j                         }||}}|j                  }|j                  |      }|j                         }	|j                         }
|j	                  |||||	|
       y )N)r   rh   r9   
setitemvarr  rc  )r8   r   r   TOSTOS1rh   r9   r  r   rp  r  s              r$   
op_MAP_ADDzTraceRunner.op_MAP_ADDK  sn    iikyy{CUE"__&
ooT&c * 	 	5r#   c           	         |j                   }t        t        t        |      D cg c]  }|j	                          c}            }|j                         }|j                  |||       |j                  |       y c c}w rG  r  )r8   r   r   r  r   r   r  s          r$   op_BUILD_SETzTraceRunner.op_BUILD_SETV  sb    XE%LALquyy{LABCooTC0

3 BrK  c                     |j                         }|j                  }|j                  |      }|j                         }|j                         }|j	                  |||||       y N)r   r9   	updatevarr  rc  r8   r   r   r9   r  r   rx  r  s           r$   op_SET_UPDATEzTraceRunner.op_SET_UPDATE^  re  r#   c                     |j                         }|j                  }|j                  |      }|j                         }|j                         }|j	                  |||||       y rw  rc  ry  s           r$   op_DICT_UPDATEzTraceRunner.op_DICT_UPDATEg  re  r#   c                     |j                         }|j                         }|j                  |||       |j                  |       y r  rS  )r8   r   r   r9   r  s        r$   op_GET_ITERzTraceRunner.op_GET_ITERp  s6    		ooTC0

3r#   c                    |j                         }|j                         }|j                         }|j                         }|j                  |||||       |j                  |       |j	                         }t
        dv r|j                  |       n+t
        dv r|j                  |d       nt        t
              |j                  |j                         y )N)iteratorpairindvalr  r   r   r%   rr  r  )	r  r  rn   r  r  r	   r   r   r   )r8   r   r   r  r  r  r  r   s           r$   op_FOR_ITERzTraceRunner.op_FOR_ITERv  s    ==? " TH4 	 	 

6""$# JJ#J44JJ#AJ&%i00

dii
 r#   c                      y)a(  Pops TOS. If TOS was not None, raises an exception. The kind
        operand corresponds to the type of generator or coroutine and
        determines the error message. The legal kinds are 0 for generator,
        1 for coroutine, and 2 for async generator.

        New in version 3.10.
        Nr"   r   s      r$   op_GEN_STARTzTraceRunner.op_GEN_START  s     	r#   c                 "   t         j                  |j                     d   }|j                         }|j                         }t        |   j
                  }|j                  d|       }|j                  |||||       |j                  |       y )Nr   binop_r  )oplhsr   r  )	dis_nb_opsr  r   r
   r   r  rn   r  )r8   r   r   r  r   r  op_namer  s           r$   op_BINARY_OPzTraceRunner.op_BINARY_OP  sw    [["1%iikiik)"-66oovgY%7o8Tbcs<

3r#   c                     |j                         }|j                         }|j                  |||       |j                  |       y r  rS  r  s        r$   _unaryopzTraceRunner._unaryop  r  r#   c                     |j                         }|j                         }|j                         }|j                  ||||       |j                  |       y )N)r  r   r  rS  )r8   r   r   r   r  r  s         r$   	_binaryopzTraceRunner._binaryop  sC    iikiikooTs5

3r#   c           
         t         dv rd }n(t         dv r|j                         }nt        t               |j                         }d x}x}x}}	|j                  dz  r|j                         }|j                  dz  r|j                         }|j                  dz  r|j                         }|j                  dz  r|j                         }	|j	                         }
|j                  |||||||	|
       |j                  |
       y )Nr   r         rr  r   )r=  codeclosureannotations
kwdefaultsdefaultsr  )r	   r   r   r  r  rn   r  )r8   r   r   MAKE_CLOSUREr=  r  r  r  r  r  r  s              r$   op_MAKE_FUNCTIONzTraceRunner.op_MAKE_FUNCTION  s    ** D++99;D%i00yy{8<<<+<
X88c>iikG88c>))+K88c>J88c>yy{Hoo#! 	 		
 	

3r#   c                 ,    | j                  ||d       y )NT)r  )r  r   s      r$   op_MAKE_CLOSUREzTraceRunner.op_MAKE_CLOSURE  s    eT=r#   c                 l    |j                         }|j                  ||       |j                  |       y r)  r+  r,  s       r$   op_LOAD_CLOSUREzTraceRunner.op_LOAD_CLOSURE  r3  r#   c                 n    |j                  d      }|j                  ||       |j                  |       y )Nassertion_errorr*  r+  r,  s       r$   op_LOAD_ASSERTION_ERRORz#TraceRunner.op_LOAD_ASSERTION_ERROR  s,    oo/0Ts#

3r#   c                     |j                  d      }|j                         }|j                         }|j                  ||||       |j	                  |       y )N	predicater  rU  rV  )r  r   r  rn   r  r8   r   r   r  rU  rV  s         r$   op_CHECK_EXC_MATCHzTraceRunner.op_CHECK_EXC_MATCH  sF    {+iik}}T#D9

4r#   c                    |j                  d      }|j                         }|j                         }|j                  ||||       |j                  |j                         |j                  |j                                y )Nr  r  r   )r  r   rn   r   r   r  r  s         r$   op_JUMP_IF_NOT_EXC_MATCHz$TraceRunner.op_JUMP_IF_NOT_EXC_MATCH  se     {+iikyy{T#D9

dii
 

d**,
-r#   c                     |j                         }|j                  dk7  r|j                          |j                  ||       |j                         r| j	                  |       y |j                          y )Nr   r  )r   r  rn   r   r   r  r  s       r$   
op_RERAISEzTraceRunner.op_RERAISE  sU    ))+Cxx1}		LL3L'##%))%0!r#   c                 j    |j                         }|j                  ||       |j                          y )Nr  )r   rn   r  r  s       r$   r  zTraceRunner.op_RERAISE   s'    ))+CLL3L'OOr#   )r*   c                     |j                         }|j                         }|j                  |       |j                         }|j	                  |||       |j                  |       y )Nr8  )r   r  r  r  rn   )r8   r   r   r9  extrar  s         r$   op_LOAD_METHODzTraceRunner.op_LOAD_METHOD/  sN    99;DOO%EJJu//#CLLDcL2JJsOr#   c                 (    | j                  ||       y r5   )r:  r   s      r$   r  zTraceRunner.op_LOAD_METHOD7  s    eT*r#   c                 (    | j                  ||       y r5   )r  r   s      r$   op_CALL_METHODzTraceRunner.op_CALL_METHOD<  s    eT*r#   N)F)r   r   r   rM   r:   r   rr   r   r  r  r
  r  r  r  r  r!  r$  r	   r'  r   r.  r0  r2  r6  r:  r>  op_LOAD_FAST_CHECKop_LOAD_FAST_AND_CLEARr@  rC  rE  rI  rL  rW  rZ  r]  r`  rc  re  rg  ri  rl  rn  rp  rw  r{  r}  r  op_POP_JUMP_IF_TRUEop_POP_JUMP_IF_FALSEop_POP_JUMP_IF_NONEop_POP_JUMP_IF_NOT_NONEr  op_JUMP_IF_FALSE_OR_POPop_JUMP_IF_TRUE_OR_POPr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r   r&  r(  r,  r/  r1  r4  r9  r<  r?  rE  rI  rP  rS  rU  rW  r]  r`  rd  rh  rn  rs  ru  rz  r|  r~  r  r  r  r  op_UNARY_NEGATIVEop_UNARY_POSITIVEop_UNARY_NOTop_UNARY_INVERTr  op_COMPARE_OPop_IS_OPop_CONTAINS_OPop_INPLACE_ADDop_INPLACE_SUBTRACTop_INPLACE_MULTIPLYop_INPLACE_DIVIDEop_INPLACE_TRUE_DIVIDEop_INPLACE_FLOOR_DIVIDEop_INPLACE_MODULOop_INPLACE_POWERop_INPLACE_MATRIX_MULTIPLYop_INPLACE_LSHIFTop_INPLACE_RSHIFTop_INPLACE_ANDop_INPLACE_ORop_INPLACE_XORop_BINARY_ADDop_BINARY_SUBTRACTop_BINARY_MULTIPLYop_BINARY_DIVIDEop_BINARY_TRUE_DIVIDEop_BINARY_FLOOR_DIVIDEop_BINARY_MODULOop_BINARY_POWERop_BINARY_MATRIX_MULTIPLYop_BINARY_LSHIFTop_BINARY_RSHIFTop_BINARY_ANDop_BINARY_ORop_BINARY_XORr  r  r  r  r  r  r  r  r  r"   r#   r$   rj   rj   B  s/   
0M4/("" &&	 
'	'	
 "),,
$
 K)!-	0	0!),,*7
((***
$
(
(
(

$
$
6 K	 
0	0!),,K	 
0	0!),,
' **K-"1	0	0!),,. 1/********... K	 
0	0!),, &&	"* 
'	'	& "),,(. K	 
0	0!),,M
!<!8
(

 &&	 
'	'	% "),,!D7
 %.
 K	38 
0	0!),,+
--)..		5!(	 ! LO MHNN##!&'! !*!!NMNM"" %& O )  MLM@>

. &&
	" 
'	'	 "),,
 K+ 
k	!	+ 
'	'	+
+ "),,r#   rj   c                   2   e Zd ZdZd(dZd Zd Zd Zd Zd Z	e
d        Ze
d	        Ze
d
        Ze
d        Ze
d        Ze
d        Zd Zd Zd Zd Zd)dZd Zd Zd Zd Zd Zd Zd Zd Zd*dZd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d+d$Z&d% Z'd& Z(d' Z)y),_StatezState of the trace
    c                    || _         || _        || _        || _        g | _        t        |      | _        t        |      | _        g | _	        g | _
        g | _        d| _        i | _        t               | _        t!               | _        t%        |      D ]I  }||v r| j'                  d      }n| j'                  d      }|| j                  |<   | j)                  |       K y)aG  
        Parameters
        ----------
        bytecode : numba.bytecode.ByteCode
            function bytecode
        pc : int
            program counter
        nstack : int
            stackdepth at entry
        blockstack : Sequence[Dict]
            A sequence of dictionary denoting entries on the blockstack.
        Fnull$r   N)r\   _pc_initialr   _nstack_initialrq   tuple_blockstack_initialr   r   _temp_registers_insts	_outedges_terminatedr   r   r   r   r   r  r  r  )r8   r^   r`   ra   rb   nullvalsr  r   s           r$   r:   z_State.__init__D  s     "%#(#4 
+! 
(l%vAH}nnW-nnU+DJJsOIIcN r#   c                 N    dj                  | j                  | j                        S )Nz&State(pc_initial={} nstack_initial={}))rE   r  r  r>   s    r$   rL   z_State.__repr__g  s&    7>>d22
 	
r#   c                 2    | j                   | j                  fS r5   )r  r  r>   s    r$   get_identityz_State.get_identityl  s      $"6"677r#   c                 4    t        | j                               S r5   )r<   r  r>   s    r$   r?   z_State.__hash__o  s    D%%'((r#   c                 D    | j                         |j                         k  S r5   r  rF   s     r$   rH   z_State.__lt__r  s      "U%7%7%999r#   c                 D    | j                         |j                         k(  S r5   r  rF   s     r$   rJ   z_State.__eq__u  s      "e&8&8&:::r#   c                     | j                   S )z]The starting bytecode offset of this State.
        The PC given to the constructor.
        )r  r>   s    r$   re   z_State.pc_initialx  s    
 r#   c                     | j                   S )ziThe list of instructions information as a 2-tuple of
        ``(pc : int, register_map : Dict)``
        )r  r>   s    r$   instructionsz_State.instructions  s    
 {{r#   c                     | j                   S )zaThe list of outgoing edges.

        Returns
        -------
        edges : List[State]
        )r  r>   s    r$   rx   z_State.outgoing_edges  s     ~~r#   c                     | j                   S )zThe dictionary of outgoing phi nodes.

        The keys are the name of the PHI nodes.
        The values are the outgoing states.
        )r   r>   s    r$   outgoing_phisz_State.outgoing_phis  s     """r#   c                     | j                   S )z6A copy of the initial state of the blockstack
        )r  r>   s    r$   blockstack_initialz_State.blockstack_initial  s     '''r#   c                 ,    t        | j                        S )zYThe current size of the stack

        Returns
        -------
        res : int
        )rO  rq   r>   s    r$   r   z_State.stack_depth  s     4;;r#   c                 b    t        | j                        D ]  }|d   t        d      k(  s|c S  y)z&Find the initial *try* block.
        r   r.   N)r  r  r-   )r8   r  s     r$   find_initial_try_blockz_State.find_initial_try_block  s/     D445C6{i..
 6r#   c                     | j                   S r5   r  r>   s    r$   rs   z_State.has_terminated  s    r#   c                 4    | j                   | j                     S r5   )r\   r   r>   s    r$   r   z_State.get_inst  s    ~~dhh''r#   c                 F    | j                         }|j                  | _        y r5   )r   r   r   r8   r   s     r$   r   z_State.advance_pc  s    }}99r#   c                 T   |sYdj                  || j                  | j                         j                  j	                         t        | j                              }n1dj                  || j                  t        | j                              }| j                  j                  |       |S )Nz"${prefix}{offset}{opname}.{tempct})r  r   r   tempctz${prefix}{offset}.{tempct})r  r   r  )rE   r   r   r   lowerrO  r  rn   )r8   r  r=  s      r$   r  z_State.make_temp  s    7>>xx}}--3354//0	 ? D 066xx4//0 7 D 	##D)r#   c                     | j                   j                  |j                  |f       | xj                  t	        t        |j                                     z  c_        y)zAppend new instN)r  rn   r   r   r   _flatten_inst_regsr[  )r8   r   rS   s      r$   rn   z_State.append  s<    DKK0131&--/BCCr#   c                 $    | j                  d      S )Nr   )r  r>   s    r$   r  z_State.get_tos  s    yy|r#   c                 "    | j                   |    S )z-Return the k'th element on the stack
        rq   )r8   rm  s     r$   r  z_State.peek  s     {{A2r#   c                 :    | j                   j                  |       y)zPush to stackN)rq   rn   )r8   r9  s     r$   r  z_State.push  s    4 r#   c                 6    | j                   j                         S )zPop the stack)rq   r   r>   s    r$   r   z
_State.pop  s    {{  r#   c                 B    | j                   }||    |d   c|d<   || <   y)zSwap stack[idx] with the tosr   Nr	  )r8   r&  ss      r$   r3  z_State.swap  s*    KKC4!B%"q#wr#   c                 F    d|v sJ | j                   j                  |       y)z#Push a block to blockstack
        r   N)r   rn   )r8   synblks     r$   r  z_State.push_block  s&     &&&'r#   c                 N    | j                   d| | j                   |d c| _         }|S )zVReset the stack to the given stack depth.
        Returning the popped items.
        Nr	  )r8   r   poppeds      r$   r  z_State.reset_stack  s-     #kk&514;;uv3FVr#   Nc                     t        |      |t        | j                        d}|rt        | j                        |d<   nd|d<   ||d<   |S )zMake a new block
        )r   r   r   r   Nr   )r-   rO  rq   )r8   r   r   r  r   ds         r$   r   z_State.make_block  sQ     dOt{{+

 "4;;/Am#Am)r#   c                 b    | j                   j                         }| j                  |d          |S )z)Pop a block and unwind the stack
        r   )r   r   r  r8   r   s     r$   r  z_State.pop_block  s0       "=)*r#   c                     | j                   j                  |      }d|cxk  rt        | j                         k  sJ  J | j                   d| | _         y)zcFind *blk* in the blockstack and remove it and all blocks above it
        from the stack.
        r   N)r   r  rO  )r8   r  r&  s      r$   r   z_State.pop_block_and_above	  sS     $$S)C/#d..//////++DS1r#   c                 f    t        |      }t        | j                        D ]  }|d   |k(  s|c S  yz1Find the first block that matches *kind*
        r   Nr-   r  r   )r8   r   bss      r$   r   z_State.get_top_block  s3     4++,B&zT!	 -r#   c                     |D ch c]  }t        |       }}t        | j                        D ]  }|d   |v s|c S  yc c}w r  r  )r8   kindsr   r  s       r$   get_top_block_eitherz_State.get_top_block_either  sG     .33UT4U34++,B&zU"	 - 4s   ?c                 (    | j                  d      duS )zGReturns a boolean indicating if the top-block is a *try* block
        r.   N)r   r>   s    r$   r   z_State.has_active_try!  s     !!%(44r#   c                 H    | j                   j                  |j                     S )z4Get referenced variable name from the oparg
        )r\   co_varnamesr  r  s     r$   r<  z_State.get_varname&  s     ~~))$((33r#   c                     d| _         y)z!Mark block as terminated
        TNr  r>   s    r$   r  z_State.terminate+  s      r#   c           
         t        | j                        }|r@d|cxk  rt        | j                        k  sJ  J t        | j                        |z
  }|d| }|r6d|k  sJ t        |      D ]!  }|j	                  | j                                # t        | j                        }t        dv r:|rP|d   }	|	j                  d      xs |	d   }
||
k\  r|j                          nn|r7nt        dv rnt        t              |r|j	                  |       | j                  j	                  t        |t        |      |t        |                   | j                          y)	zFork the state
        r   Nr   r   r   r   r   )r`   stackr   rb   )r   rq   rO  r  rn   r  r   r	   getr   r   r  Edger  r  )r8   r`   r   r   r   r#  ra   r  rb   topr   s              r$   r   z_State.fork0  s>    T[[!0DKK 000000%,F'6NE::5\T^^-. " $**+
** nggl+9s5z9NN$  ++%i00k*duUZ(
 	 	r#   c                 <    | j                  | j                         y)zSplit the state
        r   N)r   r   r>   s    r$   rw   z_State.split_new_blockU  s     			TXX	r#   c                    | j                   rJ g }| j                  D ]  }t        | j                  |j                  t        |j                        |j                  t        |j                        D cg c]  \  }}t        |      r| c}}      }|j                  |       |j                  j                         D ]!  \  }}|j                  |   | j                   |<   #  |S c c}}w )z+Get states for each outgoing edges
        )r^   r`   ra   rb   r  )r   r  ri   r\   r`   rO  r#  rb   	enumerater   rn   r   r   )r8   retr   r  rl  r   r   s          r$   rz   z_State.get_outgoing_statesZ  s     &&&&NND4>>dgg!$TZZT__2;DJJ2G $=2G$!Q'8'; %&2G $=>E JJu++++-Q+/::a=##C( . # 
$=s   2C%c           	          | j                   D ci c]0  }|j                  t        |j                  |j                   d       2 c}S c c}w )z
        Returns
        -------
        Dict[int, int]
            where keys are the PC
            values are the edge-pushed stack values
        N)r  r`   r  r#  r   )r8   r   s     r$   get_outgoing_edgepushedz_State.get_outgoing_edgepushedk  sL     !NN,*D tzz4::+,788*, 	, ,s   5A)r"   ) )TN)r   r   N)*r   r   r   rM   r:   rL   r  r?   rH   rJ   propertyre   r  rx   r  r  r   r  rs   r   r   r  rn   r  r  r  r   r3  r  r  r   r  r   r   r  r   r<  r  r   rw   rz   r,  r"   r#   r$   r  r  @  s   !F

8):;         # # ( (
     ($D

!!(
(25
4
 
#J
"
,r#   r  c                   B     e Zd Z fdZd Zd Zd Zd Zd Zd Z	 xZ
S )
StatePy311c                 2    t        |   |i | d | _        y r5   )superr:   	_kw_names)r8   rR   rS   	__class__s      r$   r:   zStatePy311.__init__y  s    $)&)r#   c                 ,    | j                   }d | _         |S r5   r3  )r8   outs     r$   r  zStatePy311.pop_kw_names}  s    nn
r#   c                 .    | j                   J || _         y r5   r6  )r8   r  s     r$   r  zStatePy311.set_kw_names  s    ~~%%%r#   c                 T    | j                   }|j                  | j                        d uS r5   r\   r  r   r8   r  s     r$   r   zStatePy311.is_in_exception  s%    ^^&&txx0<<r#   c                 P    | j                   }|j                  | j                        S r5   r:  r;  s     r$   r   zStatePy311.get_exception  s     ^^&&txx00r#   c                 L    | j                   D ]  }|d   t        d      k(  s y y )Nr   r0   T)r  r-   )r8   ents     r$   r   zStatePy311.in_with  s&    ++C6{i// ,r#   c                 &    | j                  d      S )Nr  r  )r  r>   s    r$   r  zStatePy311.make_null  s    ~~W~--r#   )r   r   r   r:   r  r  r   r   r   r  __classcell__)r4  s   @r$   r0  r0  x  s&    
=1
.r#   r0  r*   r%  )r`   r#  rb   r   c                   &    e Zd ZdZd Zed        Zy)AdaptDFAz<Adapt Flow to the old DFA class expected by Interpreter
    c                     || _         y r5   )_flow)r8   flows     r$   r:   zAdaptDFA.__init__  s	    
r#   c                 .    | j                   j                  S r5   )rD  r]   r>   s    r$   infoszAdaptDFA.infos  s    zz%%%r#   N)r   r   r   rM   r:   r.  rG  r"   r#   r$   rB  rB    s      & &r#   rB  AdaptBlockInfoinstsr  rb   active_try_blockoutgoing_edgepushedc                     t        t        | j                        | j                  | j                  | j                         | j                               S )NrI  )rH  r  r  r  r  r  r,  )r   s    r$   r   r     sG    E&&'))++557!99; r#   c              #      K   | D ]B  }t        |t              r| t        |t        t        f      s/t	        |      D ]  }|  D yw)z<Flatten an iterable of registers used in an instruction
    N)rC   strr  r   r  )rA  r9  rf   s      r$   r  r    sC      dC Judm,'- .	 s
   1AAc                   R    e Zd ZdZd Zed        Zed        Zed        Zd Z	d Z
y)	AdaptCFAz<Adapt Flow to the old CFA class expected by Interpreter
    c                    || _         i | _        |j                  j                         D ]  \  }}t	        ||      | j                  |<     | j                   j
                  j                         }|j
                  }|j                         }t               }| j                  j                         D ]%  }|j                  |      s|j                  |       ' ||z
  | _        y r5   )rD  _blocksr]   r   AdaptCFBlockr   backboner   blocksrY  in_loopsry   	_backbone)r8   rE  r   	blockinforU  r   inloopblocksr   s           r$   r:   zAdaptCFA.__init__  s    
!%!1!1!7!7!9FI#/	6#BDLL  ":::%%..0>># u!!#A~~a   # $ "L0r#   c                 .    | j                   j                  S r5   )rD  r   r>   s    r$   r   zAdaptCFA.graph  s    zz!!!r#   c                     | j                   S r5   )rX  r>   s    r$   rU  zAdaptCFA.backbone  s    ~~r#   c                     | j                   S r5   )rS  r>   s    r$   rV  zAdaptCFA.blocks  s    ||r#   c              #   b   K   t        | j                        D ]  }| j                  |     y wr5   )r~   rV  r  s     r$   iterliveblockszAdaptCFA.iterliveblocks  s'     $A++a.  %s   -/c                 L    | j                   j                  j                          y r5   )rD  r   r[   r>   s    r$   r[   zAdaptCFA.dump  s    

!r#   N)r   r   r   rM   r:   r.  r   rU  rV  r_  r[   r"   r#   r$   rQ  rQ    sR    1& " "    !"r#   rQ  c                       e Zd Zd Zy)rT  c                 T    || _         t        d |j                  D              | _        y )Nc              3   &   K   | ]	  \  }}|  y wr5   r"   )r  r  r   s      r$   r  z(AdaptCFBlock.__init__.<locals>.<genexpr>  s     81!s   )r   r  rJ  body)r8   rY  r   s      r$   r:   zAdaptCFBlock.__init__  s    8	88	r#   N)r   r   r   r:   r"   r#   r$   rT  rT    s    9r#   rT  )2rM   r  pprintr   loggingcollectionsr   r   r   	functoolsr   numba.core.utilsr   r	   r
   numba.core.controlflowr   r   numba.core.irr   numba.core.errorsr   	getLoggerr   rY   r   r   rN   r   enumr   r   r%  r   objectr-   rP   rW   r   rj   r  r0  ri   r%  rB  rH  r   r  rQ  rT  r"   r#   r$   <module>rp     s      6 6 $ K K 8  . '

H
% #   $4 $ %E,,
i
(( 3 3 3@2F 2g,6 g,T${+& {+|' t,V t, t,n	. .> EE
i
(( &@A&v & '"v '"T96 9r#   