o
    1Æ&i,% ã                   @   sÐ  d Z ddl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mZ ddlmZmZ ddlmZ ddlmZ e e¡Zd	ZeZeh d
£ƒZedv r^ddlmZ G dd„ deƒZeZn	edv rcne eƒ‚eG dd„ de!ƒƒZ"G dd„ de!ƒZ#dd„ Z$G dd„ de!ƒZ%eG dd„ de!ƒƒZ&G dd„ de&ƒZ'G dd„ de'ƒZ(edv r¦e(Z)nedv r­e'Z)ned k r´e&Z)ne eƒ‚ed!g d"¢ƒZ*G d#d$„ d$e!ƒZ+ed%g d&¢ƒZ,d'd(„ Z-d)d*„ Z.G d+d,„ d,e!ƒZ/G d-d.„ d.e!ƒZ0dS )/z)
Implement python 3.8+ bytecode analysis
é    N)Ú
namedtupleÚdefaultdictÚdeque)Útotal_ordering)Ú
UniqueDictÚ	PYVERSIONÚALL_BINOPS_TO_OPERATORSÚ_lazy_pformat)ÚNEW_BLOCKERSÚCFGraph)ÚLoc)ÚUnsupportedBytecodeErroré   >   ÚNOPÚ
LOAD_DEREFÚ
LOAD_CONSTZPRECALL©©é   é   ©r   é   )ÚEnumc                   @   s   e Zd ZdZdZdZdS )ÚCALL_INTRINSIC_1_Operandr   é   r   N)Ú__name__Ú
__module__Ú__qualname__ÚINTRINSIC_STOPITERATION_ERRORÚUNARY_POSITIVEÚINTRINSIC_LIST_TO_TUPLE© r!   r!   ú>C:\wamp64\www\opt\env\Lib\site-packages\numba/core/byteflow.pyr      s    r   ©©r   é
   ©r   é   c                   @   sD   e Zd ZdZeh d£ƒZdd„ Zdd„ Zdd„ Zd	d
„ Z	dd„ Z
dS )Ú	BlockKindz?Kinds of block to make related code safer than just `str`.
    >   ZWITH_FINALLYÚWITHÚLOOPÚFINALLYÚEXCEPTÚTRYc                 C   s   || j v sJ ‚|| _d S ©N)Ú_membersÚ_value)ÚselfÚvaluer!   r!   r"   Ú__init__4   ó   
zBlockKind.__init__c                 C   s   t t| ƒ| jfƒS r.   )ÚhashÚtyper0   ©r1   r!   r!   r"   Ú__hash__8   s   zBlockKind.__hash__c                 C   s(   t |tƒr| j|jk S td t|ƒ¡ƒ‚©Nzcannot compare to {!r}©Ú
isinstancer(   r0   Ú	TypeErrorÚformatr6   ©r1   Úotherr!   r!   r"   Ú__lt__;   ó   
zBlockKind.__lt__c                 C   s(   t |tƒr| j|jkS td t|ƒ¡ƒ‚r9   r:   r>   r!   r!   r"   Ú__eq__A   rA   zBlockKind.__eq__c                 C   s   d  | j¡S )NzBlockKind({}))r=   r0   r7   r!   r!   r"   Ú__repr__G   ó   zBlockKind.__repr__N)r   r   r   Ú__doc__Ú	frozensetr/   r3   r8   r@   rB   rC   r!   r!   r!   r"   r(   *   s    r(   c                   @   sl   e Zd ZdZdd„ Zdd„ Zedv rdd„ Zned	v r d
d„ Zneeƒ‚dd„ Z	dd„ Z
dd„ Zdd„ ZdS )ÚFlowziData+Control Flow analysis.

    Simulate execution to recover dataflow and controlflow information.
    c                 C   s*   t  dt|dd„ d¡ || _tƒ | _d S )Nzbytecode dump:
%sc                 S   s   |   ¡ S r.   )Údump©Úxr!   r!   r"   Ú<lambda>R   s    zFlow.__init__.<locals>.<lambda>)Z	lazy_func)Ú_loggerÚdebugr	   Ú	_bytecoder   Úblock_infos)r1   Úbytecoder!   r!   r"   r3   P   s
   ÿzFlow.__init__c                 C   sL  t | jdddd}t| jjjd}|j |¡ tƒ }|jr|t 	d|j¡ |j 
¡ }||jvryt 	d|j¡ t 	d|¡ |||j< 	 | |¡ | ¡ rKn|  ||¡rRn|  |¡ra|  |¡ | ¡  nqAt 	d	|j¡ |j |¡ | ¡ }|j |¡ |js|  |j¡ |  |¡ t|jd
d„ dD ]}t|ƒ | j|j< }t 	d||¡ qdS )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!   )rP   ÚpcÚnstackÚ
blockstack)Údebug_filenamezpending: %sz	stack: %szstate.pc_initial: %sTzend state. edges=%sc                 S   ó   | j S r.   )Ú
pc_initialrI   r!   r!   r"   rK   Œ   s    zFlow.run.<locals>.<lambda>)Úkeyzblock_infos %s:
%sN)ÚStaterN   ÚTraceRunnerZfunc_idÚfilenameÚpendingÚappendr   rL   rM   ÚpopleftÚfinishedÚ_stackrV   Ú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_infosrO   )r1   Z
firststateÚrunnerZfirst_encounterÚstateZ
out_statesÚsir!   r!   r"   ÚrunV   sF   

ÿ





òæ
þzFlow.run©r&   r   r   c                 C   sà   |  ¡ s| ¡ r| ¡ jtvr|j| ¡ jd | |¡ dS | ¡  |  ¡ sl| 	¡ rnt
 d| ¡ |j¡ | ¡ }| d¡}|rK|d |jkrKd }d S |jd|jd}|j|d< |j|d< |j|d	< |j|j|d
 dS d S d S )N©rQ   Tz3.11 exception %s PC=%sr-   Úend©rt   Ú
end_offsetÚstack_depthÚ
push_lasti©rQ   Úextra_block)Úin_withÚhas_active_tryÚget_instÚopnameÚ_NO_RAISE_OPSÚforkÚnextÚ_adjust_except_stackÚ
advance_pcÚis_in_exceptionrL   rM   Úget_exceptionÚ_pcÚget_top_blockÚtargetÚ
make_blockrt   ÚdepthÚlasti)r1   rn   ro   ÚehZeh_topZeh_blockr!   r!   r"   rb   ‘   s.   ÿ

ÿ



òzFlow._run_handle_exception©r$   c                 C   sº   |  ¡ rW| ¡ jtvrW|j| ¡ jd | d¡}| |¡ |j}i }||d kr1||d  |d< |d }t	dƒt
t	dƒti|d  |d	< ||d
< |jdd|d i|¤Ž dS | ¡  d S )Nrs   r-   Úentry_stackÚnpopÚhandlerr,   r+   ÚkindÚnpushrz   rQ   rt   Tr!   )r|   r}   r~   r   r€   r   r‡   Úpop_block_and_aboverw   r(   Ú_EXCEPT_STACK_OFFSETÚ_FINALLY_POPrƒ   )r1   rn   ro   ÚtryblkrR   Úkwargsr   r!   r!   r"   rb   ­   s&   

þýc                 C   sd   t ƒ }|D ]
}|j}| |¡ q|D ]}|jD ]}| |j|jd¡ qq| d¡ | ¡  || _d S )Nr   )	r   rV   Úadd_noderf   Zadd_edgerQ   Zset_entry_pointÚprocessÚcfgraph)r1   Z
all_statesÚgraphro   ÚbÚedger!   r!   r"   rj   Å   s   
ÿ

zFlow._build_cfgc           	         s   t  d dd¡¡ ‡fdd„}‡ ‡fdd„}‡ fdd	„}‡fd
d„}|ƒ \}‰ t  dt|ƒ¡ |ƒ \}}||ƒ |||ƒ t  d dd¡¡ d S )Nz
Prune PHIsé<   ú-c                     sR   t tƒ} tƒ }ˆ jD ]}t|jƒ}t|jƒ}| |  ||@ O  < ||O }q
| |fS r.   )r   Úsetr^   Ú
_used_regsÚ_phis)Ú	used_phisÚphi_setro   ÚusedZphis©rn   r!   r"   Úget_used_phis_per_stateÙ   s   



z1Flow._prune_phis.<locals>.get_used_phis_per_statec                     sv   i } t tƒ}ˆjD ]}|j ¡ D ]\}}|ˆ vr|| |< ||  ||f¡ qq	t dt| ƒ¡ t dt|ƒ¡ | |fS )Nz
defmap: %szphismap: %s)	r   r    r^   Ú_outgoing_phisÚitemsrg   rL   rM   r	   )ÚdefmapÚphismapro   ÚphiÚrhs©r¤   rn   r!   r"   Úfind_use_defsä   s   
üz'Flow._prune_phis.<locals>.find_use_defsc                    sš   t tƒ}	 d}tt|  ¡ ƒƒD ]0\}}tt|ƒƒD ]\}}|ˆ v r0|| | O }||  ||f¡ q|| }||@ r?||8 }d}qt dt| ƒ¡ |sLdS q)znAn iterative dataflow algorithm to find the definition
            (the source) of each PHI node.
            TFzchanging phismap: %sN)	r   r    rl   Úlistr©   rg   rL   rM   r	   )r«   Z	blacklistZchangingr¬   Zdefsitesr­   ro   Ú	to_remove)r¤   r!   r"   Úpropagate_phi_mapñ   s$   €€òz+Flow._prune_phis.<locals>.propagate_phi_mapc                    s¦   i }|   ¡ D ]\}}|D ]}|| ||< qqt dt|ƒ¡ ttƒ}|D ]}|| D ]
\}}||| |< q*q$t dt|ƒ¡ ˆ jD ]}|j ¡  |j 	|| ¡ qAd S )Nzkeep phismap: %sznew_out: %s)
r©   rL   rM   r	   r   Údictr^   r¨   ÚclearÚupdate)r£   r«   Zkeepro   Zused_setr¬   Znew_outr­   r¦   r!   r"   Úapply_changes  s    ÿÿ

þz'Flow._prune_phis.<locals>.apply_changeszUsed_phis: %szDONE Prune PHIs)rL   rM   Úcenterr	   )	r1   rn   r§   r¯   r²   r¶   r£   rª   r«   r!   r®   r"   rk   Ñ   s   


zFlow._prune_phisc                 C   s,   |  ¡ }|j| jjv rdS |jtv rdS dS )NTF)r}   ÚoffsetrN   Úlabelsr~   r
   ©r1   ro   Úinstr!   r!   r"   rc     s   
zFlow._is_implicit_new_blockc                 C   s<   |  ¡ }|jdv r| j|j j}|dkrd}t|ƒ‚dS dS )zÞChecks 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_WITHZBEFORE_WITHÚPOP_TOPzGThe 'with (context manager) as (variable):' construct is not supported.N)r}   r~   rN   r   r   )r1   ro   Zcurrent_instZnext_opÚmsgr!   r!   r"   rd   (  s   
úzFlow._guard_with_asN)r   r   r   rE   r3   rq   r   rb   ÚNotImplementedErrorrj   rk   rc   rd   r!   r!   r!   r"   rG   K   s    :

M
rG   c                 C   ó
   |   d¡S )Nz$null$)Ú
startswith)Úregr!   r!   r"   Ú_is_null_temp_reg6  ó   
rÃ   c                   @   sF  e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zedv r6dd„ Zdd„ Zdd„ Zdd„ Zedv rKdd „ Zned!k rP	 edv rYd"d#„ Zned$v rbd%d#„ Zned&v rkd'd#„ Zneeƒ‚d(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zedv r˜d4d5„ Zd6d7„ Zd8d9„ Zn	ed:v rneeƒ‚ed;v rªeZeZ n	ed<v r¯neeƒ‚d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%dGdH„ Z&dIdJ„ Z'dKdL„ Z(dMdN„ Z)dOdP„ Z*dQdR„ Z+dSdT„ Z,dUdV„ Z-dWdX„ Z.dYdZ„ Z/d[d\„ Z0d]d^„ Z1ed;v rd_d`„ Z2n
ed<v rneeƒ‚ed;v rdadb„ Z3n
ed<v rneeƒ‚dcdd„ Z4e4Z5e4Z6ed;v r1e4Z7e4Z8n
ed<v r7neeƒ‚dedf„ Z9e9Z:e9Z;dgdh„ Z<didj„ Z=dkdl„ Z>dmdn„ Z?dodp„ Z@dqdr„ ZAdsdt„ ZBdudv„ ZCdwdx„ ZDdydz„ ZEeEZFd{d|„ ZGd}d~„ ZHdd€„ ZIed;v rƒdd‚„ ZJn
ed<v r‰neeƒ‚dƒd„„ ZKed…v r›d†d‡„ ZLned&v r¥dˆd‡„ ZLneeƒ‚d‰dŠ„ ZMd‹dŒ„ ZNedv r»ddŽ„ ZOnedv rÅddŽ„ ZOn
ed<v rËneeƒ‚d‘d’„ ZPd“d”„ ZQd•d–„ ZRd—d˜„ ZSd™dš„ ZTd›dœ„ ZUddž„ ZVdŸd „ ZWd¡d¢„ ZXd£d¤„ ZYd¥d¦„ ZZed…v rd§d¨„ Z[ned&v rd©d¨„ Z[neeƒ‚dªd«„ Z\d¬d­„ Z]d®d¯„ Z^d°d±„ Z_d²d³„ Z`d´dµ„ Zad¶d·„ Zbd¸d¹„ Zcedv r=dºd»„ Zdn
ed:v rCneeƒ‚edv rQd¼d½„ Zened:v r[d¾d½„ Zeneeƒ‚d¿dÀ„ Zfed;v rmdÁdÂ„ Zgn
ed<v rsneeƒ‚dÃdÄ„ ZhdÅdÆ„ ZidÇdÈ„ ZjdÉdÊ„ ZkdËdÌ„ ZldÍdÎ„ ZmdÏdÐ„ ZndÑdÒ„ ZodÓdÔ„ ZpdÕdÖ„ Zqd×dØ„ ZrdÙdÚ„ ZsdÛdÜ„ ZtdÝdÞ„ Zudßdà„ Zvdádâ„ Zwdãdä„ Zxdådæ„ Zydçdè„ Zzdédê„ Z{dëdì„ Z|dídî„ Z}dïdð„ Z~dñdò„ Zdódô„ Z€dõdö„ Zd÷dø„ Z‚dùdú„ ZƒeƒZ„eƒZ…eƒZ†eƒZ‡dûdü„ ZˆeˆZ‰eˆZŠeˆZ‹eˆZŒeˆZeˆZŽeˆZeˆZeˆZ‘eˆZ’eˆZ“eˆZ”eˆZ•eˆZ–eˆZ—eˆZ˜eˆZ™eˆZšeˆZ›eˆZœeˆZeˆZžeˆZŸeˆZ eˆZ¡eˆZ¢eˆZ£eˆZ¤eˆZ¥eˆZ¦eˆZ§ddþdÿ„Z¨d d„ Z©dd„ Zªdd„ Z«dd„ Z¬dd	„ Z­d
d„ Z®ed…v rgdd„ Z¯ned&v rsdd„ Z¯neeƒ‚ed;v r}nedv rŠdd„ Z°ned&v r–dd„ Z°neeƒ‚dd„ Z±dS (  rY   zLTrace runner contains the states for the trace and the opcode dispatch.
    c                 C   s   || _ tƒ | _tƒ | _d S r.   )rT   r   r[   r    r^   )r1   rT   r!   r!   r"   r3   =  s   zTraceRunner.__init__c                 C   s   t | j|ƒS r.   )r   rT   )r1   Úlinenor!   r!   r"   Úget_debug_locB  rD   zTraceRunner.get_debug_locc                 C   sØ   t dv r'|jr&|jr&|jd }|d }|d ur"||jkr"|j ¡  nn|js
n	t dv r,ntt ƒ‚| ¡ }|jdkrHt d|j	|¡ t d|j
¡ t| d |j¡d ƒ}|d ur]|||ƒ d S d	|j }t||  |j¡d
‚)Nrr   éÿÿÿÿrt   r   ZCACHEzdispatch pc=%s, inst=%szstack %szop_{}z$Use of unsupported opcode (%s) found©Úloc)r   Ú_blockstackrV   Úpopr¿   r}   r~   rL   rM   r†   r_   Úgetattrr=   r   rÆ   rÅ   )r1   ro   ZtopblkZblk_endr»   Úfnr¾   r!   r!   r"   r`   E  s0   
ú€


ÿzTraceRunner.dispatchc                 C   sr   |  d¡}| |¡ |j}i }|d }||kr|| |d< d}|d r'|d7 }||d< |jd
d|d i|¤Ž d	S )zo
        Adjust stack when entering an exception handler to match expectation
        by the bytecode.
        r-   rw   r   é   rx   r’   rQ   rt   Nr!   )r‡   r“   rw   r€   )r1   ro   r–   rR   r—   Zexpected_depthZextra_stackr!   r!   r"   r‚   `  s   

z TraceRunner._adjust_except_stackc                 C   ó   |  |¡ d S r.   ©r\   rº   r!   r!   r"   Úop_NOPt  ó   zTraceRunner.op_NOPc                 C   rÏ   r.   rÐ   rº   r!   r!   r"   Ú	op_RESUMEw  rÒ   zTraceRunner.op_RESUMEc                 C   rÏ   r.   rÐ   rº   r!   r!   r"   Úop_CACHEz  rÒ   zTraceRunner.op_CACHEc                 C   rÏ   r.   rÐ   rº   r!   r!   r"   Ú
op_PRECALL}  rÒ   zTraceRunner.op_PRECALLc                 C   ó   |  | ¡ ¡ | |¡ d S r.   )ÚpushÚ	make_nullr\   rº   r!   r!   r"   Úop_PUSH_NULL€  s   zTraceRunner.op_PUSH_NULLc                 C   rÖ   r.   )r×   Ú	make_tempr\   rº   r!   r!   r"   Úop_RETURN_GENERATOR„  s   
zTraceRunner.op_RETURN_GENERATOR©r   c                 C   sD   t dksJ ‚| ¡ }| ¡ }| ¡ }|j||||d | |¡ d S )Nr   ©r2   ÚresÚstrvar)r   rË   rÚ   r\   r×   )r1   ro   r»   r2   rß   rÞ   r!   r!   r"   Úop_FORMAT_SIMPLE’  s   zTraceRunner.op_FORMAT_SIMPLEc                 C   sZ   |j dkrd}t||  |j¡d‚| ¡ }| ¡ }| ¡ }|j||||d | |¡ dS )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È   rÝ   N)Úargr   rÆ   rÅ   rË   rÚ   r\   r×   )r1   ro   r»   r¾   r2   rß   rÞ   r!   r!   r"   Úop_FORMAT_VALUEš  s   

ÿzTraceRunner.op_FORMAT_VALUEc                    st   |j }tt‡ fdd„t|ƒD ƒƒƒ}|dkrˆ  ¡ g}n‡ fdd„t|d ƒD ƒ}ˆ j|||d ˆ  |d ¡ dS )	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
        c                    ó   g | ]}ˆ   ¡ ‘qS r!   ©rË   ©Ú.0Ú_©ro   r!   r"   Ú
<listcomp>´  ó    z/TraceRunner.op_BUILD_STRING.<locals>.<listcomp>r   c                    rã   r!   ©rÚ   rå   rè   r!   r"   ré   ¹  rê   rÎ   )ÚstringsÚtmpsrÇ   N©rá   r°   ÚreversedÚrangerÚ   r\   r×   )r1   ro   r»   Úcountrì   rí   r!   rè   r"   Úop_BUILD_STRING¬  s   zTraceRunner.op_BUILD_STRINGc                 C   ó   |  ¡  d S r.   rä   rº   r!   r!   r"   Ú
op_POP_TOP½  rD   zTraceRunner.op_POP_TOPc                 C   s.   |  ¡ }| ¡ }|j|||d | |¡ d S )N)ÚvalrÞ   )rÚ   rË   r\   r×   )r1   ro   r»   rÞ   Útosr!   r!   r"   Ú
op_TO_BOOLÁ  ó   zTraceRunner.op_TO_BOOLr   c                 C   sL   |  ¡ }|jd? }|j|||d | |¡ |jd@ r$| | ¡ ¡ d S d S ©NrÎ   )ÚidxrÞ   ©rÚ   rá   r\   r×   rØ   ©r1   ro   r»   rÞ   rú   r!   r!   r"   Úop_LOAD_GLOBALË  s   


ÿzTraceRunner.op_LOAD_GLOBAL©r&   r   c                 C   sH   |  ¡ }|jd? }|j|||d |jd@ r| | ¡ ¡ | |¡ d S rù   rû   rü   r!   r!   r"   rý   Õ  s   

r   c                 C   ó$   |  ¡ }|j||d | |¡ d S ©N©rÞ   ©rÚ   r\   r×   ©r1   ro   r»   rÞ   r!   r!   r"   rý   Þ  ó   c                 C   rÏ   r.   rÐ   rº   r!   r!   r"   Úop_COPY_FREE_VARSå  rÒ   zTraceRunner.op_COPY_FREE_VARSc                 C   rÏ   r.   rÐ   rº   r!   r!   r"   Úop_MAKE_CELLè  rÒ   zTraceRunner.op_MAKE_CELLc                 C   rÿ   r   r  r  r!   r!   r"   Úop_LOAD_DEREFë  r  zTraceRunner.op_LOAD_DEREFc                 C   s2   |  d¡d|j›  }| |¡ |j||d d S )NÚconstÚ.r  )rÚ   rá   r×   r\   r  r!   r!   r"   Úop_LOAD_CONSTð  s   
zTraceRunner.op_LOAD_CONSTc                 C   s˜   |  ¡ }| ¡ }tdv r| |¡ |jd@ r| | ¡ ¡ n$tdv r4|jd@ r.| | ¡ ¡ | |¡ ntdv r>| |¡ nttƒ‚|j|||d d S )NrÜ   rÎ   ©r   r#   ©ÚitemrÞ   )rË   rÚ   r   r×   rá   rØ   r¿   r\   )r1   ro   r»   r  rÞ   r!   r!   r"   Úop_LOAD_ATTRö  s   

€
zTraceRunner.op_LOAD_ATTRc           
      C   sØ   t dksJ ‚t dv rTz| |¡}W nG tyS   |j}t|jƒ}t|jƒ}t|jƒ}|| }d|j|   kr<|k s?J ‚ J ‚| 	¡ }	|j
||	dd | |	¡ Y d S w | |¡}| 	|¡}	|j
||	d | |	¡ d S )Nr   rÜ   r   T)rÞ   Zas_load_derefr  )r   Úget_varnameÚ
IndexErrorrN   ÚlenÚco_varnamesÚco_freevarsÚco_cellvarsrá   rÚ   r\   r×   )
r1   ro   r»   ÚnameÚbcZnum_varnamesZnum_freevarsZnum_cellvarsZmax_fast_localrÞ   r!   r!   r"   Úop_LOAD_FAST  s(   


"
ñ

zTraceRunner.op_LOAD_FASTc           
      C   sf   |j }|d? }|d@ }| |¡}| |¡}| |¡}| |¡}	|j|||	d | |¡ | |	¡ d S )Né   é   )Úres1Úres2)rá   Úget_varname_by_argrÚ   r\   r×   )
r1   ro   r»   ÚopargZoparg1Úoparg2Zname1Zname2r  r  r!   r!   r"   Úop_LOAD_FAST_LOAD_FAST#  s   




z"TraceRunner.op_LOAD_FAST_LOAD_FASTc                 C   sH   |j }|d@ }| ¡ }| |¡}| |¡}|j|||d | |¡ d S )Nr  )Ústore_valueÚload_res)rá   rË   r  rÚ   r\   r×   )r1   ro   r»   r  r  r   Z	load_namer!  r!   r!   r"   Úop_STORE_FAST_LOAD_FAST/  s   

z#TraceRunner.op_STORE_FAST_LOAD_FASTc                 C   ó$   |  ¡ }|  ¡ }|j|||d d S )N)Úvalue1Úvalue2©rË   r\   )r1   ro   r»   r$  r%  r!   r!   r"   Úop_STORE_FAST_STORE_FAST9  ó   z$TraceRunner.op_STORE_FAST_STORE_FAST©r$   r&   r   r   r#   c                 C   rÏ   r.   rÐ   rº   r!   r!   r"   Úop_DELETE_FASTK  rÒ   zTraceRunner.op_DELETE_FASTc                 C   ó   |  ¡ }|j||d d S )N)rˆ   r&  )r1   ro   r»   rˆ   r!   r!   r"   Úop_DELETE_ATTRN  ó   zTraceRunner.op_DELETE_ATTRc                 C   r#  )N)rˆ   r2   r&  )r1   ro   r»   rˆ   r2   r!   r!   r"   Úop_STORE_ATTRR  r(  zTraceRunner.op_STORE_ATTRc                 C   r+  ©N)r2   r&  ©r1   ro   r»   r2   r!   r!   r"   Úop_STORE_DEREFW  r-  zTraceRunner.op_STORE_DEREFc                 C   r+  r/  r&  r0  r!   r!   r"   Úop_STORE_FAST[  r-  zTraceRunner.op_STORE_FASTc           	   	   C   óV   |  ¡ }|  ¡ }| ¡ }| ¡ }| ¡ }| ¡ }|j|||||||d | |¡ dS )z"
        TOS = TOS1[TOS:]
        )ÚbaseÚstartrÞ   ÚslicevarÚindexvarÚnonevarN©rË   rÚ   r\   r×   ©	r1   ro   r»   rö   Útos1rÞ   r6  r7  r8  r!   r!   r"   Ú
op_SLICE_1_  ó    ù	zTraceRunner.op_SLICE_1c           	   	   C   r3  )z"
        TOS = TOS1[:TOS]
        )r4  ÚstoprÞ   r6  r7  r8  Nr9  r:  r!   r!   r"   Ú
op_SLICE_2t  r=  zTraceRunner.op_SLICE_2c           	   	   C   sV   |  ¡ }|  ¡ }|  ¡ }| ¡ }| ¡ }| ¡ }|j|||||||d | |¡ dS )z&
        TOS = TOS2[TOS1:TOS]
        )r4  r5  r>  rÞ   r6  r7  Nr9  )	r1   ro   r»   rö   r;  Útos2rÞ   r6  r7  r!   r!   r"   Ú
op_SLICE_3‰  r=  zTraceRunner.op_SLICE_3c                 C   sB   |  ¡ }|  ¡ }| ¡ }| ¡ }| ¡ }|j||||||d dS )z
        TOS[:] = TOS1
        )r4  r2   r6  r7  r8  N©rË   rÚ   r\   )r1   ro   r»   rö   r2   r6  r7  r8  r!   r!   r"   Úop_STORE_SLICE_0ž  ó   
úzTraceRunner.op_STORE_SLICE_0c           	   	   C   sL   |  ¡ }|  ¡ }|  ¡ }| ¡ }| ¡ }| ¡ }|j|||||||d dS )z#
        TOS1[TOS:] = TOS2
        )r4  r5  r6  r2   r7  r8  NrB  ©	r1   ro   r»   rö   r;  r2   r6  r7  r8  r!   r!   r"   Úop_STORE_SLICE_1°  ó   
ùzTraceRunner.op_STORE_SLICE_1c           	   	   C   sL   |  ¡ }|  ¡ }|  ¡ }| ¡ }| ¡ }| ¡ }|j|||||||d dS )z#
        TOS1[:TOS] = TOS2
        )r4  r>  r2   r6  r7  r8  NrB  rE  r!   r!   r"   Úop_STORE_SLICE_2Ä  rG  zTraceRunner.op_STORE_SLICE_2c           	   	   C   sL   |  ¡ }|  ¡ }|  ¡ }|  ¡ }| ¡ }| ¡ }|j|||||||d dS )z'
        TOS2[TOS1:TOS] = TOS3
        )r4  r5  r>  r2   r6  r7  NrB  )	r1   ro   r»   rö   r;  r@  r2   r6  r7  r!   r!   r"   Úop_STORE_SLICE_3Ø  rG  zTraceRunner.op_STORE_SLICE_3c                 C   s8   |  ¡ }| ¡ }| ¡ }| ¡ }|j|||||d dS )z
        del TOS[:]
        )r4  r6  r7  r8  NrB  )r1   ro   r»   rö   r6  r7  r8  r!   r!   r"   Úop_DELETE_SLICE_0ì  s   
þzTraceRunner.op_DELETE_SLICE_0c                 C   óB   |  ¡ }|  ¡ }| ¡ }| ¡ }| ¡ }|j||||||d dS )z 
        del TOS1[TOS:]
        )r4  r5  r6  r7  r8  NrB  ©r1   ro   r»   rö   r;  r6  r7  r8  r!   r!   r"   Úop_DELETE_SLICE_1ù  rD  zTraceRunner.op_DELETE_SLICE_1c                 C   rK  )z 
        del TOS1[:TOS]
        )r4  r>  r6  r7  r8  NrB  rL  r!   r!   r"   Úop_DELETE_SLICE_2  rD  zTraceRunner.op_DELETE_SLICE_2c                 C   sB   |  ¡ }|  ¡ }|  ¡ }| ¡ }| ¡ }|j||||||d dS )z$
        del TOS2[TOS1:TOS]
        )r4  r5  r>  r6  r7  NrB  )r1   ro   r»   rö   r;  r@  r6  r7  r!   r!   r"   Úop_DELETE_SLICE_3  s   

þzTraceRunner.op_DELETE_SLICE_3c                 C   s–   |j }|dkr| ¡ }| ¡ }|}|}d}n|dkr-| ¡ }| ¡ }| ¡ }	|	}|}|}ntdƒ‚| ¡ }
| ¡ }|j||||||
d | |¡ dS )z<
        slice(TOS1, TOS) or slice(TOS2, TOS1, TOS)
        é   Nr   Úunreachable)r5  r>  ÚsteprÞ   r6  )rá   rË   Ú	ExceptionrÚ   r\   r×   )r1   ro   r»   Zargcrö   r;  r5  r>  rR  r@  r6  rÞ   r!   r!   r"   Úop_BUILD_SLICE+  s*   ÿzTraceRunner.op_BUILD_SLICEc           	   	   C   sV   |  ¡ }|  ¡ }|  ¡ }| ¡ }| ¡ }| ¡ }|j|||||||d | |¡ d S )N)r5  rt   Ú	containerrÞ   r6  Útemp_resr9  )	r1   ro   r»   rt   r5  rU  rV  rÞ   r6  r!   r!   r"   Úop_BINARY_SLICEG  s   
þzTraceRunner.op_BINARY_SLICEc           	   	   C   sL   |  ¡ }|  ¡ }|  ¡ }|  ¡ }| ¡ }| ¡ }|j|||||||d d S )N)r5  rt   rU  r2   rÞ   r6  rB  )	r1   ro   r»   rt   r5  rU  r2   r6  rÞ   r!   r!   r"   Úop_STORE_SLICEY  s   

þzTraceRunner.op_STORE_SLICEc                 C   sL   |  ¡ }|j||d | ¡ }|j}|j|d ||kr$|j|d d S d S )N©Úpredrs   )rË   r\   Úget_jump_targetr   r€   )r1   ro   r»   rZ  Ztarget_instZ	next_instr!   r!   r"   Ú_op_POP_JUMP_IFj  s   ÿzTraceRunner._op_POP_JUMP_IFc                 C   s:   |  ¡ }|j||d |j|jdd |j| ¡ d d S )NrY  rÎ   ©rQ   r   rs   )Úget_tosr\   r€   r   r[  )r1   ro   r»   rZ  r!   r!   r"   Ú_op_JUMP_IF_OR_POP  s   zTraceRunner._op_JUMP_IF_OR_POPc                 C   ó   |   ||¡ d S r.   ©r\  rº   r!   r!   r"   Úop_POP_JUMP_FORWARD_IF_NONEŠ  ó   z'TraceRunner.op_POP_JUMP_FORWARD_IF_NONEc                 C   r`  r.   ra  rº   r!   r!   r"   Úop_POP_JUMP_FORWARD_IF_NOT_NONE  rc  z+TraceRunner.op_POP_JUMP_FORWARD_IF_NOT_NONEc                 C   r`  r.   ra  rº   r!   r!   r"   Úop_POP_JUMP_BACKWARD_IF_NONE  rc  z(TraceRunner.op_POP_JUMP_BACKWARD_IF_NONEc                 C   r`  r.   ra  rº   r!   r!   r"   Ú op_POP_JUMP_BACKWARD_IF_NOT_NONE“  rc  z,TraceRunner.op_POP_JUMP_BACKWARD_IF_NOT_NONEc                 C   r`  r.   ra  rº   r!   r!   r"   Úop_POP_JUMP_FORWARD_IF_FALSE–  rc  z(TraceRunner.op_POP_JUMP_FORWARD_IF_FALSEc                 C   r`  r.   ra  rº   r!   r!   r"   Úop_POP_JUMP_FORWARD_IF_TRUE™  rc  z'TraceRunner.op_POP_JUMP_FORWARD_IF_TRUEc                 C   r`  r.   ra  rº   r!   r!   r"   Úop_POP_JUMP_BACKWARD_IF_FALSEœ  rc  z)TraceRunner.op_POP_JUMP_BACKWARD_IF_FALSEc                 C   r`  r.   ra  rº   r!   r!   r"   Úop_POP_JUMP_BACKWARD_IF_TRUEŸ  rc  z(TraceRunner.op_POP_JUMP_BACKWARD_IF_TRUEc                 C   ó   |  |¡ |j| ¡ d d S ©Nrs   ©r\   r€   r[  rº   r!   r!   r"   Úop_JUMP_FORWARD¢  ó   
zTraceRunner.op_JUMP_FORWARDc                 C   rk  rl  rm  rº   r!   r!   r"   Úop_JUMP_BACKWARD¦  ro  zTraceRunner.op_JUMP_BACKWARDc                 C   rk  rl  rm  rº   r!   r!   r"   Úop_JUMP_ABSOLUTE¬  ro  zTraceRunner.op_JUMP_ABSOLUTEc                 C   s4   |  d¡d }|j||d | ¡  |j|d d S )Nr*   rt   ru   rs   )r‡   r\   Ú	pop_blockr€   )r1   ro   r»   rt   r!   r!   r"   Úop_BREAK_LOOP°  s   zTraceRunner.op_BREAK_LOOPc                 C   s$   |j || ¡ | ¡ d | ¡  d S )N©ÚretvalZcastval)r\   rË   rÚ   Ú	terminaterº   r!   r!   r"   Úop_RETURN_VALUE·  s   zTraceRunner.op_RETURN_VALUEc                 C   s*   |  d¡}|j|||  ¡ d | ¡  d S )Nr  rt  )rÚ   r\   rv  r  r!   r!   r"   Úop_RETURN_CONST¼  s   
zTraceRunner.op_RETURN_CONSTc                 C   ó.   |  ¡ }| ¡ }|j|||d | |¡ d S ©N)r2   rÞ   r9  ©r1   ro   r»   rõ   rÞ   r!   r!   r"   Úop_YIELD_VALUEÅ  rø   zTraceRunner.op_YIELD_VALUErr   c                 C   sx   |j dkrd }| ¡ rtd|  |j¡d‚n|j dkr | ¡ }ntdƒ‚|j||d | ¡ r6|  |¡ d S | 	¡  d S )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Ë   Ú
ValueErrorr\   r‚   rv  ©r1   ro   r»   r€  r!   r!   r"   Úop_RAISE_VARARGSÌ  s   

þÿ

zTraceRunner.op_RAISE_VARARGSc                 C   s~   t | d¡d u| d¡d ugƒ}|jdkr$d }|r#td|  |j¡d‚n|jdkr.| ¡ }ntdƒ‚|j||d | 	¡  d S )	Nr,   r+   r   r}  rÈ   rÎ   r~  r  )
Úanyr‡   rá   r   rÆ   rÅ   rË   r  r\   rv  )r1   ro   r»   Zin_exc_blockr€  r!   r!   r"   rƒ  â  s"   þ

þÿ

c                 C   s@   g }t tƒD ]}| ¡ }| |¡ | |¡ q|j||d d S )N)Útemps)rð   r”   rÚ   r\   r×   )r1   ro   r»   r…  ÚiÚtmpr!   r!   r"   Úop_BEGIN_FINALLY÷  s   
zTraceRunner.op_BEGIN_FINALLYc                 C   s   |  ¡ }| |d ¡ d S )NrŽ   )rr  Úreset_stack©r1   ro   r»   Úblkr!   r!   r"   Úop_END_FINALLYÿ  r-  zTraceRunner.op_END_FINALLYc                 C   ró   r.   rä   rº   r!   r!   r"   Ú
op_END_FOR  rD   zTraceRunner.op_END_FORr  c                 C   s   |  ¡  |  ¡  d S r.   rä   rº   r!   r!   r"   r    ó   c                 C   s&   |j dkrd}t||  |j¡d‚d S )Nr   zGUnsupported use of a bytecode related to try..finally or a with-contextrÈ   )rá   r   rÆ   rÅ   )r1   ro   r»   r¾   r!   r!   r"   Úop_POP_FINALLY  s   

ÿýzTraceRunner.op_POP_FINALLYc                 C   s   d S r.   r!   rº   r!   r!   r"   Úop_CALL_FINALLY  s   zTraceRunner.op_CALL_FINALLYc                 C   ró   r.   )rv  rº   r!   r!   r"   Úop_WITH_EXCEPT_START  rD   z TraceRunner.op_WITH_EXCEPT_STARTc                 C   rÏ   r.   rÐ   rº   r!   r!   r"   Úop_WITH_CLEANUP_START  ó   z!TraceRunner.op_WITH_CLEANUP_STARTc                 C   rÏ   r.   rÐ   rº   r!   r!   r"   Úop_WITH_CLEANUP_FINISH!  r“  z"TraceRunner.op_WITH_CLEANUP_FINISHc                 C   s   |  |jd| ¡ d¡ d S )Nr*   ©r‘   rt   )Ú
push_blockr‰   r[  rº   r!   r!   r"   Úop_SETUP_LOOP%  s   þÿzTraceRunner.op_SETUP_LOOPc                 C   s´   |  ¡ }| ¡ }|jdd}| |¡ | |¡ |j}| |j¡}|g}|jD ]}	|	j|jkr4| |	¡ q't	dd„ |D ƒƒ}
|j||||
d | 
|jd|
d¡ |j|jd d S )	NÚsetup_with_exitfn©Úprefixc                 s   s    | ]}|j V  qd S r.   ru   )ræ   rŒ   r!   r!   r"   Ú	<genexpr>@  s   € z-TraceRunner.op_BEFORE_WITH.<locals>.<genexpr>)ÚcontextmanagerÚexitfnrt   r)   r•  rs   )rË   rÚ   r×   rN   Úfind_exception_entryr   Zexception_entriesrˆ   r\   Úmaxr–  r‰   r€   )r1   ro   r»   ÚcmÚyieldedr  r  ZehheadZ	ehrelatedrŒ   rt   r!   r!   r"   Úop_BEFORE_WITH.  s*   



€þÿzTraceRunner.op_BEFORE_WITHc                 C   sj   |  ¡ }| ¡ }|jdd}|j|||d | |¡ | |¡ | |jd| ¡ d¡ |j|jd d S )Nr˜  r™  )rœ  r  r)   r•  rs   )	rË   rÚ   r\   r×   r–  r‰   r[  r€   r   )r1   ro   r»   r   r¡  r  r!   r!   r"   Úop_SETUP_WITHL  s   

þÿzTraceRunner.op_SETUP_WITHc                 C   s0   |j |d dd}|j||j d|d|dd d S )NF)r‘   rt   r‰  r-   )r‘   rt   r‰  r   ry   )r‰   r€   )r1   r‘   ro   r   rt   Zhandler_blockr!   r!   r"   Ú
_setup_try_  s   ýü
þzTraceRunner._setup_tryc                 C   s&   |  ¡ }| | d¡¡ | |¡ d S )NÚ	exception)rË   r×   rÚ   )r1   ro   r»   rö   r!   r!   r"   Úop_PUSH_EXC_INFOs  s   zTraceRunner.op_PUSH_EXC_INFOc                 C   s&   |  |¡ | jd||j| ¡ d d S )Nr+   )r   rt   )r\   r¤  r   r[  rº   r!   r!   r"   Úop_SETUP_FINALLYx  s   

ÿzTraceRunner.op_SETUP_FINALLYc                 C   ró   r.   rä   rº   r!   r!   r"   Úop_POP_EXCEPT  rD   zTraceRunner.op_POP_EXCEPTc                 C   sh   |  ¡ }|d tdƒtdƒhvrtd|d › |  |j¡d‚| ¡  | ¡  | ¡  |j|jd d S )Nr‘   r,   r+   z$POP_EXCEPT got an unexpected block: rÈ   rs   )rr  r(   r   rÆ   rÅ   rË   r€   r   rŠ  r!   r!   r"   r¨  ƒ  s   
þc                 C   sX   |  ¡ }|d tdƒkr|j|dd n|d tdƒkr#|j|dd |j|jd d S )Nr‘   r-   Útry)r‘   r)   Úwithrs   )rr  r(   r\   r€   r   rŠ  r!   r!   r"   Úop_POP_BLOCK’  s   zTraceRunner.op_POP_BLOCKc                 C   s8   |  ¡ }|  ¡ }| ¡ }|j||||d | |¡ d S )N)Úindexrˆ   rÞ   r9  )r1   ro   r»   r¬  rˆ   rÞ   r!   r!   r"   Úop_BINARY_SUBSCRš  ó
   zTraceRunner.op_BINARY_SUBSCRc                 C   s.   |  ¡ }|  ¡ }|  ¡ }|j||||d d S )N)rˆ   r¬  r2   r&  )r1   ro   r»   r¬  rˆ   r2   r!   r!   r"   Úop_STORE_SUBSCR¡  s   zTraceRunner.op_STORE_SUBSCRc                 C   s$   |  ¡ }|  ¡ }|j|||d d S )N)rˆ   r¬  r&  )r1   ro   r»   r¬  rˆ   r!   r!   r"   Úop_DELETE_SUBSCR§  r(  zTraceRunner.op_DELETE_SUBSCRc                    sº   |j }tt‡ fdd„t|ƒD ƒƒƒ}tdkr*ˆ  ¡ }ˆ  ¡ }t|ƒs'|g|¢}d }ntdk rHˆ  ¡ }ˆ  ¡ }	t|	ƒr=|}n|	}|g|¢}ˆ  ¡ }ˆ  ¡ }
ˆ j	|||||
d ˆ  
|
¡ d S )Nc                    rã   r!   rä   rå   rè   r!   r"   ré   ®  rê   z'TraceRunner.op_CALL.<locals>.<listcomp>r   ©ÚfuncÚargsÚkw_namesrÞ   )rá   r°   rï   rð   r   rË   rÃ   Úpop_kw_namesrÚ   r\   r×   )r1   ro   r»   Únargr³  Znull_or_selfÚcallabler´  Zcallable_or_firstargZnull_or_callablerÞ   r!   rè   r"   Úop_CALL¬  s&   

zTraceRunner.op_CALLc                 C   ó   |  |j¡ d S r.   )Úset_kw_namesrá   rº   r!   r!   r"   Úop_KW_NAMESÄ  rc  zTraceRunner.op_KW_NAMESc                    sT   |j }tt‡ fdd„t|ƒD ƒƒƒ}ˆ  ¡ }ˆ  ¡ }ˆ j||||d ˆ  |¡ d S )Nc                    rã   r!   rä   rå   rè   r!   r"   ré   É  rê   z0TraceRunner.op_CALL_FUNCTION.<locals>.<listcomp>)r²  r³  rÞ   )rá   r°   rï   rð   rË   rÚ   r\   r×   )r1   ro   r»   r¶  r³  r²  rÞ   r!   rè   r"   Úop_CALL_FUNCTIONÇ  s   zTraceRunner.op_CALL_FUNCTIONc                    s^   |j }ˆ  ¡ }tt‡ fdd„t|ƒD ƒƒƒ}ˆ  ¡ }ˆ  ¡ }ˆ j|||||d ˆ  |¡ d S )Nc                    rã   r!   rä   rå   rè   r!   r"   ré   Ó  rê   z3TraceRunner.op_CALL_FUNCTION_KW.<locals>.<listcomp>)r²  r³  ÚnamesrÞ   )rá   rË   r°   rï   rð   rÚ   r\   r×   )r1   ro   r»   r¶  r½  r³  r²  rÞ   r!   rè   r"   Úop_CALL_FUNCTION_KWÐ  s   zTraceRunner.op_CALL_FUNCTION_KWc           	         sx   |j }ˆ  ¡ }tt‡ fdd„t|ƒD ƒƒƒ}ˆ  ¡ }ˆ  ¡ }t|ƒs'|g|¢}ˆ  ¡ }ˆ j|||||d ˆ  |¡ d S )Nc                    rã   r!   rä   rå   rè   r!   r"   ré   Þ  rê   z*TraceRunner.op_CALL_KW.<locals>.<listcomp>r±  )	rá   rË   r°   rï   rð   rÃ   rÚ   r\   r×   )	r1   ro   r»   r¶  r´  r³  Znull_or_firstargr·  rÞ   r!   rè   r"   Ú
op_CALL_KWÛ  s   
ÿzTraceRunner.op_CALL_KWc                 C   sZ   |j d@ r
| ¡ }nd }| ¡ }| ¡  | ¡ }| ¡ }|j|||||d | |¡ d S )NrÎ   ©r²  ÚvarargÚvarkwargrÞ   )rá   rË   rÚ   r\   r×   ©r1   ro   r»   rÂ  rÁ  r²  rÞ   r!   r!   r"   Úop_CALL_FUNCTION_EXï  s   

ÿzTraceRunner.op_CALL_FUNCTION_EXc                 C   s„   |j d@ r
| ¡ }nd }| ¡ }| ¡ }tdv r$t| d¡ƒr#| ¡  n	tdv r)nttƒ‚| ¡ }|j|||||d | |¡ d S )NrÎ   rþ   r   rÀ  )	rá   rË   r   rÃ   Úpeekr¿   rÚ   r\   r×   rÃ  r!   r!   r"   rÄ    s"   

€ÿc                    sp   ‡ fdd„t |ƒD ƒ}| ¡  ‡ fdd„t |ƒD ƒ}ˆ j|||d |D ]}ˆ  |¡ q$|D ]}ˆ  |¡ q.d S )Nc                    rã   r!   rä   rå   rè   r!   r"   ré     rê   z)TraceRunner._dup_topx.<locals>.<listcomp>c                    rã   r!   rë   rå   rè   r!   r"   ré     rê   )ÚorigÚduped)rð   Úreverser\   r×   )r1   ro   r»   rñ   rÆ  rÇ  rõ   r!   rè   r"   Ú	_dup_topx  s   ÿzTraceRunner._dup_topxc           	      C   sä   zt |jƒ}W n ty!   d|j› d}|  |j¡}t||d‚w |tjkr4|j||d | 	¡  d S |tj
krQ| ¡ }| ¡ }|j||||d | |¡ d S |tjkrn| ¡ }| ¡ }|j||||d | |¡ d S t|ƒ‚)Nzop_CALL_INTRINSIC_1(ú)rÈ   )Úoperand)rË  r2   rÞ   )rË  Ú
const_listrÞ   )r   rá   r<   rÆ   rÅ   r   Úci1opr   r\   rv  r   rË   rÚ   r×   r    r¿   )	r1   ro   r»   rË  r¾   rÉ   rõ   rÞ   rö   r!   r!   r"   Úop_CALL_INTRINSIC_1%  s8   ý

ÿ

ÿ
zTraceRunner.op_CALL_INTRINSIC_1c                 C   s<   |j }d|  krdksJ dƒ‚ J dƒ‚|  |||¡ d S )NrÎ   r   zInvalid DUP_TOPX count)rá   rÉ  )r1   ro   r»   rñ   r!   r!   r"   Úop_DUP_TOPXH  s   $zTraceRunner.op_DUP_TOPXc                 C   ó   | j ||dd d S )NrÎ   ©rñ   ©rÉ  rº   r!   r!   r"   Ú
op_DUP_TOPM  ó   zTraceRunner.op_DUP_TOPc                 C   rÐ  )NrP  rÑ  rÒ  rº   r!   r!   r"   Úop_DUP_TOP_TWOP  rÔ  zTraceRunner.op_DUP_TOP_TWOc                 C   s   |  | |j¡¡ d S r.   )r×   rÅ  rá   rº   r!   r!   r"   Úop_COPYS  s   zTraceRunner.op_COPYc                 C   r¹  r.   )Úswaprá   rº   r!   r!   r"   Úop_SWAPV  rc  zTraceRunner.op_SWAPc                 C   s(   |  ¡ }|  ¡ }| |¡ | |¡ d S r.   ©rË   r×   )r1   ro   r»   ÚfirstÚsecondr!   r!   r"   Ú
op_ROT_TWOY  s   
zTraceRunner.op_ROT_TWOc                 C   s:   |  ¡ }|  ¡ }|  ¡ }| |¡ | |¡ | |¡ d S r.   rÙ  )r1   ro   r»   rÚ  rÛ  Úthirdr!   r!   r"   Úop_ROT_THREE_  s   

zTraceRunner.op_ROT_THREEc                 C   sL   |  ¡ }|  ¡ }|  ¡ }|  ¡ }| |¡ | |¡ | |¡ | |¡ d S r.   rÙ  )r1   ro   r»   rÚ  rÛ  rÝ  Úforthr!   r!   r"   Úop_ROT_FOURg  s   


zTraceRunner.op_ROT_FOURc                    sZ   |j }ˆ  ¡ }‡ fdd„t|ƒD ƒ}ˆ  ¡ }ˆ j||||d t|ƒD ]}ˆ  |¡ q#d S )Nc                    rã   r!   rë   rå   rè   r!   r"   ré   t  rê   z2TraceRunner.op_UNPACK_SEQUENCE.<locals>.<listcomp>)ÚiterableÚstoresÚtupleobj)rá   rË   rð   rÚ   r\   rï   r×   )r1   ro   r»   rñ   rá  râ  rã  Ústr!   rè   r"   Úop_UNPACK_SEQUENCEq  s   ÿzTraceRunner.op_UNPACK_SEQUENCEc                    óJ   |j }tt‡ fdd„t|ƒD ƒƒƒ}ˆ  ¡ }ˆ j|||d ˆ  |¡ d S )Nc                    rã   r!   rä   rå   rè   r!   r"   ré   |  rê   z.TraceRunner.op_BUILD_TUPLE.<locals>.<listcomp>©r©   rÞ   rî   )r1   ro   r»   rñ   r©   Útupr!   rè   r"   Úop_BUILD_TUPLEz  ó
   zTraceRunner.op_BUILD_TUPLEc                    s|   t t‡ fdd„t|jƒD ƒƒƒ}‡ fdd„tt|ƒd ƒD ƒ}t|ƒdk}|r,ˆ  ¡ g}ˆ j||||d ˆ  |d ¡ d S )Nc                    rã   r!   rä   rå   rè   r!   r"   ré   ƒ  rê   z3TraceRunner._build_tuple_unpack.<locals>.<listcomp>c                    rã   r!   rë   rå   rè   r!   r"   ré   „  rê   rÎ   )Útuplesr…  Ú	is_assignrÇ   )r°   rï   rð   rá   r  rÚ   r\   r×   )r1   ro   r»   rë  r…  rì  r!   rè   r"   Ú_build_tuple_unpack  s    
zTraceRunner._build_tuple_unpackc                 C   r`  r.   ©rí  rº   r!   r!   r"   Úop_BUILD_TUPLE_UNPACK_WITH_CALL  ó   z+TraceRunner.op_BUILD_TUPLE_UNPACK_WITH_CALLc                 C   r`  r.   rî  rº   r!   r!   r"   Úop_BUILD_TUPLE_UNPACK”  rc  z!TraceRunner.op_BUILD_TUPLE_UNPACKc                 C   ry  )N)rÌ  rÞ   r9  )r1   ro   r»   rö   rÞ   r!   r!   r"   Úop_LIST_TO_TUPLE—  s   zTraceRunner.op_LIST_TO_TUPLEc                    sj   ˆ   ¡ }tt‡ fdd„t|jƒD ƒƒƒ}‡ fdd„t|jƒD ƒ}ˆ  ¡ }ˆ j|||||d ˆ  |¡ d S )Nc                    rã   r!   rä   rå   rè   r!   r"   ré   ¡  rê   z6TraceRunner.op_BUILD_CONST_KEY_MAP.<locals>.<listcomp>c                    rã   r!   rë   rå   rè   r!   r"   ré   ¢  rê   )ÚkeysÚkeytmpsÚvaluesrÞ   )rË   r°   rï   rð   rá   rÚ   r\   r×   )r1   ro   r»   ró  Úvalsrô  rÞ   r!   rè   r"   Úop_BUILD_CONST_KEY_MAPŸ  s    z"TraceRunner.op_BUILD_CONST_KEY_MAPc                    ræ  )Nc                    rã   r!   rä   rå   rè   r!   r"   ré   ©  rê   z-TraceRunner.op_BUILD_LIST.<locals>.<listcomp>rç  rî   )r1   ro   r»   rñ   r©   Úlstr!   rè   r"   Úop_BUILD_LIST§  rê  zTraceRunner.op_BUILD_LISTc                 C   ó@   |  ¡ }|j}| |¡}| ¡ }| ¡ }|j|||||d d S )N)rˆ   r2   Ú	appendvarrÞ   ©rË   rá   rÅ  rÚ   r\   )r1   ro   r»   r2   r¬  rˆ   rû  rÞ   r!   r!   r"   Úop_LIST_APPEND®  ó   

ÿzTraceRunner.op_LIST_APPENDc                 C   rú  )N)rˆ   r2   Ú	extendvarrÞ   rü  )r1   ro   r»   r2   r¬  rˆ   rÿ  rÞ   r!   r!   r"   Úop_LIST_EXTEND·  rþ  zTraceRunner.op_LIST_EXTENDc           	      C   sj   |  ¡ }|j}g }t|ƒD ]}| ¡ | ¡ }}| ||f¡ q|j||d d d… ||d | |¡ d S )NrÇ   )r©   ÚsizerÞ   )rÚ   rá   rð   rË   r\   r×   )	r1   ro   r»   Údctrñ   r©   r†  ÚvÚkr!   r!   r"   Úop_BUILD_MAPÀ  s   zTraceRunner.op_BUILD_MAPc                 C   sT   |  ¡ }|  ¡ }||}}|j}| |¡}| ¡ }	| ¡ }
|j|||||	|
d d S )N)rˆ   rW   r2   Ú
setitemvarrÞ   rü  )r1   ro   r»   ZTOSZTOS1rW   r2   r¬  rˆ   r  rÞ   r!   r!   r"   Ú
op_MAP_ADDË  s   


ÿzTraceRunner.op_MAP_ADDc                    ræ  )Nc                    rã   r!   rä   rå   rè   r!   r"   ré   Ù  rê   z,TraceRunner.op_BUILD_SET.<locals>.<listcomp>rç  rî   )r1   ro   r»   rñ   r©   rÞ   r!   rè   r"   Úop_BUILD_SETÖ  s
   zTraceRunner.op_BUILD_SETc                 C   rú  ©N)rˆ   r2   Ú	updatevarrÞ   rü  ©r1   ro   r»   r2   r¬  rˆ   r
  rÞ   r!   r!   r"   Úop_SET_UPDATEÞ  rþ  zTraceRunner.op_SET_UPDATEc                 C   rú  r	  rü  r  r!   r!   r"   Úop_DICT_UPDATEç  rþ  zTraceRunner.op_DICT_UPDATEc                 C   ry  rz  r9  )r1   ro   r»   r2   rÞ   r!   r!   r"   Úop_GET_ITERð  rø   zTraceRunner.op_GET_ITERc                 C   sŽ   |  ¡ }| ¡ }| ¡ }| ¡ }|j|||||d | |¡ | ¡ }tdv r.|j|d ntdv r:|j|dd nttƒ‚|j|jd d S )N)ÚiteratorÚpairÚindvalrZ  r   rs   r#   rP  r]  )	r^  rÚ   r\   r×   r[  r   r€   r¿   r   )r1   ro   r»   r  r  r  rZ  rt   r!   r!   r"   Úop_FOR_ITERö  s   ÿ
zTraceRunner.op_FOR_ITERc                 C   s   dS )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º   r!   r!   r"   Úop_GEN_START
  s   	zTraceRunner.op_GEN_STARTc                 C   s^   t j|j d }| ¡ }| ¡ }t| j}|jd|› d}|j|||||d | |¡ d S )NrÎ   Zbinop_r™  )ÚopÚlhsr­   rÞ   )	ÚdisZ_nb_opsrá   rË   r   r   rÚ   r\   r×   )r1   ro   r»   r  r­   r  Zop_namerÞ   r!   r!   r"   Úop_BINARY_OP  s   
zTraceRunner.op_BINARY_OPc                 C   ry  rz  r9  r{  r!   r!   r"   Ú_unaryop  rø   zTraceRunner._unaryopc                 C   s8   |  ¡ }|  ¡ }| ¡ }|j||||d | |¡ d S )N)r  r­   rÞ   r9  )r1   ro   r»   r­   r  rÞ   r!   r!   r"   Ú	_binaryop)  r®  zTraceRunner._binaryopFc              
   C   sÐ   t dv rd }nt dv r| ¡ }ntt ƒ‚| ¡ }d  } } }}	t dv r,|jd u s+J ‚n$|jd@ r5| ¡ }|jd@ r>| ¡ }|jd@ rG| ¡ }|jd@ rP| ¡ }	| ¡ }
|j|||||||	|
d | |
¡ d S )	Nrr   r   rÜ   é   r  rP  rÎ   )r  ÚcodeÚclosureÚannotationsÚ
kwdefaultsÚdefaultsrÞ   )r   rË   r¿   rá   rÚ   r\   r×   )r1   ro   r»   ÚMAKE_CLOSUREr  r  r  r  r  r  rÞ   r!   r!   r"   Úop_MAKE_FUNCTIONT  s:   




ø
zTraceRunner.op_MAKE_FUNCTIONc                 C   sš   t dv sJ ‚| ¡ }| ¡ }|jdkr|j||d n+|jd@ r(|j||d n|jd@ r5|j||d n|jdkrB|j||d	 ntd
ƒ‚| |¡ d S )NrÜ   rÎ   )r  rP  )r  r  )r  r  )r  rQ  )r   rË   rá   Úset_function_attributeÚAssertionErrorr×   )r1   ro   r»   Zmake_func_stackÚdatar!   r!   r"   Úop_SET_FUNCTION_ATTRIBUTEy  s   



z%TraceRunner.op_SET_FUNCTION_ATTRIBUTEc                 C   rÐ  )NT)r   )r!  rº   r!   r!   r"   Úop_MAKE_CLOSUREŽ  rÔ  zTraceRunner.op_MAKE_CLOSUREc                 C   rÿ   r   r  r  r!   r!   r"   Úop_LOAD_CLOSURE‘  r  zTraceRunner.op_LOAD_CLOSUREc                 C   s&   |  d¡}|j||d | |¡ d S )NZassertion_errorr  r  r  r!   r!   r"   Úop_LOAD_ASSERTION_ERROR–  s   
z#TraceRunner.op_LOAD_ASSERTION_ERRORc                 C   s:   |  d¡}| ¡ }| ¡ }|j||||d | |¡ d S )NÚ	predicate©rZ  rö   r;  )rÚ   rË   r^  r\   r×   ©r1   ro   r»   rZ  rö   r;  r!   r!   r"   Úop_CHECK_EXC_MATCH›  s
   
zTraceRunner.op_CHECK_EXC_MATCHc                 C   sN   |  d¡}| ¡ }| ¡ }|j||||d |j|jd |j| ¡ d d S )Nr)  r*  rs   )rÚ   rË   r\   r€   r   r[  r+  r!   r!   r"   Úop_JUMP_IF_NOT_EXC_MATCH¢  s   
z$TraceRunner.op_JUMP_IF_NOT_EXC_MATCHc                 C   sJ   |  ¡ }|jdkr|  ¡  |j||d | ¡ r|  |¡ d S | ¡  d S )Nr   r  )rË   rá   r\   r|   r‚   rv  r‚  r!   r!   r"   Ú
op_RERAISE­  s   
zTraceRunner.op_RERAISEc                 C   s"   |  ¡ }|j||d | ¡  d S )Nr  )rË   r\   rv  r‚  r!   r!   r"   r.  º  s   )r&   c                 C   s@   |  ¡ }| ¡ }| |¡ | ¡ }|j|||d | |¡ d S )Nr  )rË   rØ   r×   rÚ   r\   )r1   ro   r»   r  ÚextrarÞ   r!   r!   r"   Úop_LOAD_METHODÉ  s   
zTraceRunner.op_LOAD_METHODc                 C   r`  r.   )r  rº   r!   r!   r"   r0  Ñ  rc  c                 C   r`  r.   )r¼  rº   r!   r!   r"   Úop_CALL_METHODÖ  rc  zTraceRunner.op_CALL_METHODN)F)²r   r   r   rE   r3   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'  Zop_LOAD_FAST_CHECKZop_LOAD_FAST_AND_CLEARr*  r,  r.  r1  r2  r<  r?  rA  rC  rF  rH  rI  rJ  rM  rN  rO  rT  rW  rX  r\  Zop_POP_JUMP_IF_TRUEZop_POP_JUMP_IF_FALSEZop_POP_JUMP_IF_NONEZop_POP_JUMP_IF_NOT_NONEr_  Zop_JUMP_IF_FALSE_OR_POPZop_JUMP_IF_TRUE_OR_POPrb  rd  re  rf  rg  rh  ri  rj  rn  rp  Zop_JUMP_BACKWARD_NO_INTERRUPTrq  rs  rw  rx  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÷  rù  rý  r   r  r  r  r  r  r  r  r  r  r  Zop_UNARY_NEGATIVEZop_UNARY_POSITIVEZop_UNARY_NOTZop_UNARY_INVERTr  Zop_COMPARE_OPZop_IS_OPZop_CONTAINS_OPZop_INPLACE_ADDZop_INPLACE_SUBTRACTZop_INPLACE_MULTIPLYZop_INPLACE_DIVIDEZop_INPLACE_TRUE_DIVIDEZop_INPLACE_FLOOR_DIVIDEZop_INPLACE_MODULOZop_INPLACE_POWERZop_INPLACE_MATRIX_MULTIPLYZop_INPLACE_LSHIFTZop_INPLACE_RSHIFTZop_INPLACE_ANDZop_INPLACE_ORZop_INPLACE_XORZop_BINARY_ADDZop_BINARY_SUBTRACTZop_BINARY_MULTIPLYZop_BINARY_DIVIDEZop_BINARY_TRUE_DIVIDEZop_BINARY_FLOOR_DIVIDEZop_BINARY_MODULOZop_BINARY_POWERZop_BINARY_MATRIX_MULTIPLYZop_BINARY_LSHIFTZop_BINARY_RSHIFTZop_BINARY_ANDZop_BINARY_ORZop_BINARY_XORr!  r%  r&  r'  r(  r,  r-  r.  r0  r1  r!   r!   r!   r"   rY   :  sè   

	























	



	











						%




rY   c                   @   sf  e Zd ZdZdTdd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	e
dd„ ƒZe
dd„ ƒZe
dd„ ƒZe
dd„ ƒZe
dd„ ƒZe
dd„ ƒZdd„ Zdd„ Zdd „ Zd!d"„ ZdUd$d%„Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ ZdVd8d9„Zd:d;„ Zd<d=„ Z d>d?„ Z!d@dA„ Z"dBdC„ Z#dDdE„ Z$dFe%fdGdH„Z&dIdJ„ Z'dWdLdM„Z(dNdO„ Z)dPdQ„ Z*dRdS„ Z+d7S )XÚ_StatezState of the trace
    r!   c                 C   s¤   || _ || _|| _|| _g | _t|ƒ| _t|ƒ| _g | _	g | _
g | _d| _i | _tƒ | _tƒ | _t|ƒD ]}||v r@|  d¡}n|  d¡}|| j|< |  |¡ q4dS )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)rN   Ú_pc_initialr†   Ú_nstack_initialr_   ÚtupleÚ_blockstack_initialr°   rÊ   Ú_temp_registersÚ_instsÚ	_outedgesÚ_terminatedr¢   r   r¨   r    r¡   rð   rÚ   r×   )r1   rP   rQ   rR   rS   Únullvalsr†  r¬   r!   r!   r"   r3   Þ  s*   



úz_State.__init__c                 C   s   d  | j| j¡S )Nz&State(pc_initial={} nstack_initial={}))r=   r4  r5  r7   r!   r!   r"   rC     s   ÿz_State.__repr__c                 C   s   | j | jfS r.   )r4  r5  r7   r!   r!   r"   Úget_identity  rD   z_State.get_identityc                 C   s   t |  ¡ ƒS r.   )r5   r=  r7   r!   r!   r"   r8   	  rD   z_State.__hash__c                 C   s   |   ¡ |  ¡ k S r.   ©r=  r>   r!   r!   r"   r@     rc  z_State.__lt__c                 C   s   |   ¡ |  ¡ kS r.   r>  r>   r!   r!   r"   rB     rc  z_State.__eq__c                 C   rU   )z]The starting bytecode offset of this State.
        The PC given to the constructor.
        )r4  r7   r!   r!   r"   rV     ó   z_State.pc_initialc                 C   rU   )ziThe list of instructions information as a 2-tuple of
        ``(pc : int, register_map : Dict)``
        )r9  r7   r!   r!   r"   Úinstructions  r?  z_State.instructionsc                 C   rU   )zaThe list of outgoing edges.

        Returns
        -------
        edges : List[State]
        ©r:  r7   r!   r!   r"   rf      s   z_State.outgoing_edgesc                 C   rU   )z‹The dictionary of outgoing phi nodes.

        The keys are the name of the PHI nodes.
        The values are the outgoing states.
        )r¨   r7   r!   r!   r"   Úoutgoing_phis*  s   z_State.outgoing_phisc                 C   rU   )z6A copy of the initial state of the blockstack
        )r7  r7   r!   r!   r"   Úblockstack_initial3  s   z_State.blockstack_initialc                 C   s
   t | jƒS )zYThe current size of the stack

        Returns
        -------
        res : int
        )r  r_   r7   r!   r!   r"   rw   9  s   
z_State.stack_depthc                 C   s,   t | jƒD ]}|d tdƒkr|  S qdS )z&Find the initial *try* block.
        r‘   r-   N)rï   r7  r(   )r1   r‹  r!   r!   r"   Úfind_initial_try_blockC  s
   ÿÿz_State.find_initial_try_blockc                 C   rU   r.   ©r;  r7   r!   r!   r"   ra   J  s   z_State.has_terminatedc                 C   s   | j | j S r.   )rN   r†   r7   r!   r!   r"   r}   M  rD   z_State.get_instc                 C   s   |   ¡ }|j| _d S r.   )r}   r   r†   ©r1   r»   r!   r!   r"   rƒ   P  rŽ  z_State.advance_pcÚ c                 C   sR   |sdj || j|  ¡ j ¡ t| jƒd}ndj || jt| jƒd}| j |¡ |S )Nz"${prefix}{offset}{opname}.{tempct})rš  r¸   r~   Útempctz${prefix}{offset}.{tempct})rš  r¸   rH  )r=   r†   r}   r~   Úlowerr  r8  r\   )r1   rš  r  r!   r!   r"   rÚ   T  s   üýz_State.make_tempc                 K   s0   | j  |j|f¡ |  jtt| ¡ ƒƒO  _dS )zAppend new instN)r9  r\   r¸   r¡   r    Ú_flatten_inst_regsrõ  )r1   r»   r—   r!   r!   r"   r\   f  s   z_State.appendc                 C   rÀ   )NrÎ   )rÅ  r7   r!   r!   r"   r^  k  rÄ   z_State.get_tosc                 C   s   | j |  S )z-Return the k'th element on the stack
        ©r_   )r1   r  r!   r!   r"   rÅ  n  ó   z_State.peekc                 C   s   | j  |¡ dS )zPush to stackN)r_   r\   )r1   r  r!   r!   r"   r×   s  rð  z_State.pushc                 C   s
   | j  ¡ S )zPop the stack)r_   rË   r7   r!   r!   r"   rË   w  s   
z
_State.popc                 C   s(   | j }||  |d |d< || < dS )zSwap stack[idx] with the tosrÇ   NrK  )r1   rú   Úsr!   r!   r"   r×  {  s   "z_State.swapc                 C   s   d|v sJ ‚| j  |¡ dS )z#Push a block to blockstack
        rw   N)rÊ   r\   )r1   Zsynblkr!   r!   r"   r–  €  s   z_State.push_blockc                 C   s$   | j d|… | j |d… | _ }|S )zVReset the stack to the given stack depth.
        Returning the popped items.
        NrK  )r1   rŠ   Úpoppedr!   r!   r"   r‰  †  s    z_State.reset_stackTNc                 C   s>   t |ƒ|t| jƒdœ}|rt| jƒ|d< nd|d< ||d< |S )zMake a new block
        )r‘   rt   rŽ   rw   Nr   )r(   r  r_   )r1   r‘   rt   r‰  r   Údr!   r!   r"   r‰     s   ýz_State.make_blockc                 C   s   | j  ¡ }|  |d ¡ |S )z)Pop a block and unwind the stack
        rw   )rÊ   rË   r‰  ©r1   rœ   r!   r!   r"   rr  œ  s   
z_State.pop_blockc                 C   sB   | j  |¡}d|  krt| j ƒk sJ ‚ J ‚| j d|… | _ dS )zcFind *blk* in the blockstack and remove it and all blocks above it
        from the stack.
        r   N)rÊ   r¬  r  )r1   r‹  rú   r!   r!   r"   r“   £  s   "z_State.pop_block_and_abovec                 C   s0   t |ƒ}t| jƒD ]}|d |kr|  S q	dS )ú1Find the first block that matches *kind*
        r‘   N)r(   rï   rÊ   )r1   r‘   Úbsr!   r!   r"   r‡   «  s   ÿÿz_State.get_top_blockc                 G   s6   dd„ |D ƒ}t | jƒD ]}|d |v r|  S qdS )rQ  c                 S   s   h | ]}t |ƒ’qS r!   )r(   )ræ   r‘   r!   r!   r"   Ú	<setcomp>¶  rê   z._State.get_top_block_either.<locals>.<setcomp>r‘   N)rï   rÊ   )r1   ÚkindsrR  r!   r!   r"   Úget_top_block_either³  s   ÿÿz_State.get_top_block_eitherc                 C   s   |   d¡duS )zGReturns a boolean indicating if the top-block is a *try* block
        r-   N)r‡   r7   r!   r!   r"   r|   »  s   z_State.has_active_tryc                 C   s   |   |j¡S )zBGet referenced variable name from the instruction's oparg
        )r  rá   rF  r!   r!   r"   r  À  rL  z_State.get_varnamer  c                 C   s   | j j| S )z4Get referenced variable name from the oparg
        )rN   r  )r1   r  r!   r!   r"   r  Å  rL  z_State.get_varname_by_argc                 C   s
   d| _ dS )z!Mark block as terminated
        TNrE  r7   r!   r!   r"   rv  Ê  s   
z_State.terminater   c                 C   s  t | jƒ}|r%d|  krt| jƒksJ ‚ J ‚t| jƒ| }|d|… }|r;d|ks-J ‚t|ƒD ]	}| |  ¡ ¡ q1t | jƒ}tdv r`|r_|d }	|	 d¡pR|	d }
||
kr\| 	¡  nn|sFn	tdv rent
tƒ‚|rp| |¡ | j t|t|ƒ|t|ƒd¡ |  ¡  dS )	zFork the state
        r   Nrr   rÇ   rv   rt   r   )rQ   Ústackr’   rS   )r°   r_   r  rð   r\   rÚ   rÊ   r   ÚgetrË   r¿   r:  ÚEdger6  rv  )r1   rQ   r   r’   rz   rV  rR   r†  rS   Útoprt   r!   r!   r"   r€   Ï  s:   
"

ú€

þz_State.forkc                 C   s   | j | jd dS )zSplit the state
        rs   N)r€   r†   r7   r!   r!   r"   re   ô  s   z_State.split_new_blockc              	   C   sz   | j rJ ‚g }| jD ]0}t| j|jt|jƒ|jdd„ t|jƒD ƒd}| 	|¡ |j
 ¡ D ]\}}|j| | j |< q-q
|S )z+Get states for each outgoing edges
        c                 S   s   g | ]
\}}t |ƒr|‘qS r!   )rÃ   )ræ   r†  r  r!   r!   r"   ré     s    
ÿz._State.get_outgoing_states.<locals>.<listcomp>)rP   rQ   rR   rS   r<  )r¨   r:  rX   rN   rQ   r  rV  rS   Ú	enumerater\   r¢   r©   )r1   Úretr   ro   r¬   r†  r!   r!   r"   rh   ù  s   


þ
ÿz_State.get_outgoing_statesc                 C   s   dd„ | j D ƒS )z–
        Returns
        -------
        Dict[int, int]
            where keys are the PC
            values are the edge-pushed stack values
        c                 S   s&   i | ]}|j t|j|j d … ƒ“qS r.   )rQ   r6  rV  r’   )ræ   r   r!   r!   r"   Ú
<dictcomp>  s    ÿz2_State.get_outgoing_edgepushed.<locals>.<dictcomp>rA  r7   r!   r!   r"   Úget_outgoing_edgepushed
  s   	ÿz_State.get_outgoing_edgepushed)r!   )rG  )TN)r   r   N),r   r   r   rE   r3   rC   r=  r8   r@   rB   ÚpropertyrV   r@  rf   rB  rC  rw   rD  ra   r}   rƒ   rÚ   r\   r^  rÅ  r×   rË   r×  r–  r‰  r‰   rr  r“   r‡   rU  r|   r  Úintr  rv  r€   re   rh   r]  r!   r!   r!   r"   r2  Ú  s\    
#


	


	


%r2  c                       sL   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	‡  Z
S )Ú
StatePy311c                    s   t ƒ j|i |¤Ž d | _d S r.   )Úsuperr3   Ú	_kw_names©r1   r³  r—   ©Ú	__class__r!   r"   r3     s   
zStatePy311.__init__c                 C   s   | j }d | _ |S r.   ©rb  )r1   Úoutr!   r!   r"   rµ    s   zStatePy311.pop_kw_namesc                 C   s   | j d u sJ ‚|| _ d S r.   rf  )r1   rõ   r!   r!   r"   rº  !  r4   zStatePy311.set_kw_namesc                 C   s   | j }| | j¡d uS r.   ©rN   rž  r†   ©r1   r  r!   r!   r"   r„   %  s   zStatePy311.is_in_exceptionc                 C   s   | j }| | j¡S r.   rh  ri  r!   r!   r"   r…   )  s   zStatePy311.get_exceptionc                 C   s&   | j D ]}|d tdƒkr dS qd S )Nr‘   r)   T)r7  r(   )r1   Úentr!   r!   r"   r{   -  s
   
ÿÿzStatePy311.in_withc                 C   s   | j ddS )Nr3  r™  rë   r7   r!   r!   r"   rØ   2  rD   zStatePy311.make_null)r   r   r   r3   rµ  rº  r„   r…   r{   rØ   Ú__classcell__r!   r!   rd  r"   r`    s    r`  c                       s,   e Zd Z‡ fdd„Zdd„ Zdd„ Z‡  ZS )Ú
StatePy313c                    s    t ƒ j|i |¤Ž ttƒ| _d S r.   )ra  r3   r   r³   Ú_make_func_attrsrc  rd  r!   r"   r3   7  s   zStatePy313.__init__c                 K   s   | j |  |¡ d S r.   )rm  rµ   )r1   Úmake_func_resr—   r!   r!   r"   r"  ;  rÔ  z!StatePy313.set_function_attributec                 C   s
   | j | S r.   )rm  )r1   rn  r!   r!   r"   Úget_function_attributes>  rÄ   z"StatePy313.get_function_attributes)r   r   r   r3   r"  ro  rk  r!   r!   rd  r"   rl  6  s    rl  rÜ   rþ   r&   rX  )rQ   rV  rS   r’   c                   @   s$   e Zd ZdZdd„ Zedd„ ƒZdS )ÚAdaptDFAz<Adapt Flow to the old DFA class expected by Interpreter
    c                 C   s
   || _ d S r.   )Ú_flow)r1   Úflowr!   r!   r"   r3   R  rÄ   zAdaptDFA.__init__c                 C   ó   | j jS r.   )rq  rO   r7   r!   r!   r"   ÚinfosU  ó   zAdaptDFA.infosN)r   r   r   rE   r3   r^  rt  r!   r!   r!   r"   rp  O  s
    rp  ÚAdaptBlockInfo©ÚinstsrB  rS   Zactive_try_blockZoutgoing_edgepushedc                    s`   ‡ fdd„}t dv rtt|ˆ jƒƒ}nt dv rtˆ jƒ}ntt ƒ‚t|ˆ jˆ jˆ  ¡ ˆ  	¡ dS )Nc                    s8   | \}}ˆ j | }|jdkr| ˆ  |d ¡¡ ||fS )NÚMAKE_FUNCTIONrÞ   )rN   r~   rµ   ro  )Z	inst_pairr¸   r$  r»   rè   r!   r"   Úprocess_function_attributesb  s
   

z6adapt_state_infos.<locals>.process_function_attributesrÜ   r)  rw  )
r   r6  Úmapr@  r¿   rv  rB  rC  rD  r]  )ro   rz  rx  r!   rè   r"   rm   a  s   ûrm   c                 c   sD    | D ]}t |tƒr|V  qt |ttfƒrt|ƒD ]}|V  qqdS )z<Flatten an iterable of registers used in an instruction
    N)r;   Ústrr6  r°   rJ  )rá  r  rJ   r!   r!   r"   rJ  w  s   €
€ûrJ  c                   @   sL   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZedd	„ ƒZd
d„ Z	dd„ Z
dS )ÚAdaptCFAz<Adapt Flow to the old CFA class expected by Interpreter
    c                 C   s‚   || _ i | _|j ¡ D ]\}}t||ƒ| j|< q| j j ¡ }|j}| ¡ }tƒ }| j 	¡ D ]}| 
|¡r9| |¡ q-|| | _d S r.   )rq  Ú_blocksrO   r©   ÚAdaptCFBlockrš   Úbackboner    Úblocksró  Zin_loopsrg   Ú	_backbone)r1   rr  r¸   Ú	blockinfor€  r›   Zinloopblocksrœ   r!   r!   r"   r3   …  s   

€zAdaptCFA.__init__c                 C   rs  r.   )rq  rš   r7   r!   r!   r"   r›   ˜  ru  zAdaptCFA.graphc                 C   rU   r.   )r‚  r7   r!   r!   r"   r€  œ  ó   zAdaptCFA.backbonec                 C   rU   r.   )r~  r7   r!   r!   r"   r     r„  zAdaptCFA.blocksc                 c   s"    t | jƒD ]}| j| V  qd S r.   )rl   r  rP  r!   r!   r"   Úiterliveblocks¤  s   €ÿzAdaptCFA.iterliveblocksc                 C   s   | j j ¡  d S r.   )rq  rš   rH   r7   r!   r!   r"   rH   ¨  rc  zAdaptCFA.dumpN)r   r   r   rE   r3   r^  r›   r€  r  r…  rH   r!   r!   r!   r"   r}  ‚  s    


r}  c                   @   s   e Zd Zdd„ ZdS )r  c                 C   s    || _ tdd„ |jD ƒƒ| _d S )Nc                 s   s    | ]\}}|V  qd S r.   r!   )ræ   r†  rç   r!   r!   r"   r›  ¯  s   € z(AdaptCFBlock.__init__.<locals>.<genexpr>)r¸   r6  rx  Úbody)r1   rƒ  r¸   r!   r!   r"   r3   ­  s   zAdaptCFBlock.__init__N)r   r   r   r3   r!   r!   r!   r"   r  ¬  s    r  )1rE   r  ÚloggingÚcollectionsr   r   r   Ú	functoolsr   Znumba.core.utilsr   r   r   r	   Znumba.core.controlflowr
   r   Znumba.core.irr   Znumba.core.errorsr   Ú	getLoggerr   rL   r”   r•   rF   r   Úenumr   r   rÍ  r¿   Úobjectr(   rG   rÃ   rY   r2  r`  rl  rX   rX  rp  rv  rm   rJ  r}  r  r!   r!   r!   r"   Ú<module>   sx    
  l           +  >þ*