
    shy                         S SK r S SKrS SKrS SKJr  S SKJr  S SKJr  \	" / SQ5      r
 " S S\5      r " S S	\ R                  " S	S
5      5      r " S S\ R                  5      r " S S\5      r " S S\5      rg)    N)Loc)UnsupportedError)	PYVERSION)
SETUP_LOOPFOR_ITER
SETUP_WITHBEFORE_WITHc                   &    \ rS rSrS rS rS rSrg)CFBlock   c                 H    Xl         / U l        0 U l        0 U l        SU l        g )NF)offsetbodyoutgoing_jumpsincoming_jumpsterminating)selfr   s     j/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/core/controlflow.py__init__CFBlock.__init__   s*    	 ! !     c                 v    U R                   [        U R                  5      [        U R                  5      4nSU-  $ )Nz,block(offset:%d, outgoing: %s, incoming: %s))r   sortedr   r   )r   argss     r   __repr__CFBlock.__repr__   s9    t**+t**+- >DDr   c                 ,    [        U R                  5      $ N)iterr   r   s    r   __iter__CFBlock.__iter__#   s    DIIr   )r   r   r   r   r   N)__name__
__module____qualname____firstlineno__r   r   r!   __static_attributes__ r   r   r   r      s    	!Er   r   c                   (    \ rS rSrSrSrS rS rSrg)Loop'   z7
A control flow loop, as detected by a CFGraph object.
r(   c                 b    [        U[        5      =(       a    UR                  U R                  :H  $ r   )
isinstancer*   headerr   others     r   __eq__Loop.__eq__4   s!    %&F5<<4;;+FFr   c                 ,    [        U R                  5      $ r   )hashr.   r    s    r   __hash__Loop.__hash__7   s    DKK  r   N)	r#   r$   r%   r&   __doc__	__slots__r1   r5   r'   r(   r   r   r*   r*   '   s     IG!r   r*   )entriesexitsr.   r   c                   *    \ rS rSrSrS rS rS rSrg)_DictOfContainers;   zA defaultdict with customized equality checks that ignore empty values.

Non-empty value is checked by: `bool(value_item) == True`.
c                     [        U[        5      (       a$  U R                  5       nUR                  5       nX#:H  $ [        $ r   )r-   r<   _non_empty_itemsNotImplemented)r   r0   minetheirss       r   r1   _DictOfContainers.__eq__A   s:    e.//((*D++-F>!r   c                 H    U R                  U5      nU[        L a  U$ U(       + $ r   )r1   r@   )r   r0   rets      r   __ne___DictOfContainers.__ne__I   s$    kk% . J7Nr   c                 ~    [        U R                  5       5       VVs/ s H  u  pU(       d  M  X4PM     snn$ s  snnf r   )r   items)r   kvss      r   r?   "_DictOfContainers._non_empty_itemsP   s/    %+DJJL%9@%9EAR%9@@@s   99r(   N)	r#   r$   r%   r&   r7   r1   rF   r?   r'   r(   r   r   r<   r<   ;   s    
Ar   r<   c                      \ rS rSrSrS rS rS<S jrS rS r	S	 r
S
 rS rS rS rS rS r\R$                  S 5       r\R$                  S 5       r\R$                  S 5       r\R$                  S 5       r\R$                  S 5       r\R$                  S 5       r\R$                  S 5       r\R$                  S 5       r\R$                  S 5       r\R$                  S 5       r\R$                  S 5       rS rS rS r S r!S r"S  r#S! r$S" r%S# r&S=S$ jr'S<S% jr(S>S& jr)S<S' jr*S( r+S<S) jr,S* r-S+ r.S, r/S- r0S. r1S/ r2S=S0 jr3S1 r4S2 r5S<S3 jr6S4 r7S5 r8S6 r9S7 r:S8 r;S9 r<S: r=S;r>g)?CFGraphT   z:
Generic (almost) implementation of a Control Flow Graph.
c                     [        5       U l        [        [         5      U l        [        [         5      U l        0 U l        S U l        g r   )set_nodesr<   _preds_succs
_edge_data_entry_pointr    s    r   r   CFGraph.__init__Y   s2    e',', r   c                 :    U R                   R                  U5        g)z{
Add *node* to the graph.  This is necessary before adding any
edges from/to the node.  *node* can be any hashable object.
N)rR   addr   nodes     r   add_nodeCFGraph.add_node`   s    
 	r   Nc                     XR                   ;  a  [        SU< SU R                   < 35      eX R                   ;  a  [        SU< SU R                   < 35      eU R                  XU5        g)z
Add an edge from node *src* to node *dest*, with optional
per-edge *data*.
If such an edge already exists, it is replaced (duplicate edges
are not possible).
zCannot add edge as src node z not in nodes zCannot add edge as dest node N)rR   
ValueError	_add_edge)r   srcdestdatas       r   add_edgeCFGraph.add_edgeg   s\     kk!!4;;0 1 1{{""DKK1 2 2s$'r   c              #   ^   #    U R                   U    H  nX R                  X4   4v   M     g7f)z
Yield (node, data) pairs representing the successors of node *src*.
(*data* will be None if no data was specified when adding the edge)
N)rT   rU   )r   ra   rb   s      r   
successorsCFGraph.successorsv   s.     
 KK$D	222 %   +-c              #   ^   #    U R                   U    H  nX R                  X!4   4v   M     g7f)z
Yield (node, data) pairs representing the predecessors of node *dest*.
(*data* will be None if no data was specified when adding the edge)
N)rS   rU   )r   rb   ra   s      r   predecessorsCFGraph.predecessors~   s.     
 ;;t$Csy111 %ri   c                 2    XR                   ;   d   eXl        g)z-
Set the entry point of the graph to *node*.
N)rR   rV   rZ   s     r   set_entry_pointCFGraph.set_entry_point   s     {{""" r   c                 T    U R                   c  [        S5      eU R                  5         g)z
Compute essential properties of the control flow graph.  The graph
must have been fully populated, and its entry point specified. Other
graph properties are computed on-demand.
Nzno entry point defined!)rV   RuntimeError_eliminate_dead_blocksr    s    r   processCFGraph.process   s(     $899##%r   c                     U R                   $ )z
Return a dictionary of {node -> set(nodes)} mapping each node to
the nodes dominating it.

A node D dominates a node N when any path leading to N must go through D
)_domsr    s    r   
dominatorsCFGraph.dominators        zzr   c                     U R                   $ )z
Return a dictionary of {node -> set(nodes)} mapping each node to
the nodes post-dominating it.

A node P post-dominates a node N when any path starting from N must go
through P.
)
_post_domsr    s    r   post_dominatorsCFGraph.post_dominators   s     r   c                     U R                   $ )z
Return a dictionary of {node -> node} mapping each node to its
immediate dominator (idom).

The idom(B) is the closest strict dominator of V
)_idomr    s    r   immediate_dominatorsCFGraph.immediate_dominators   ry   r   c                     U R                   $ )z
Return a dictionary of {node -> set(nodes)} mapping each node to
the nodes in its dominance frontier.

The dominance frontier _df(N) is the set of all nodes that are
immediate successors to blocks dominated by N but which aren't
strictly dominated by N
)_dfr    s    r   dominance_frontierCFGraph.dominance_frontier   s     xxr   c                     U R                   $ )z
return a dictionary of {node -> set(nodes)} mapping each node to
the set of nodes it immediately dominates

The domtree(B) is the closest strict set of nodes that B dominates
)_domtreer    s    r   dominator_treeCFGraph.dominator_tree   s     }}r   c                 "    U R                  5       $ r   )_find_exit_pointsr    s    r   _exit_pointsCFGraph._exit_points       %%''r   c                 "    U R                  5       $ r   )_find_dominatorsr    s    r   rv   CFGraph._doms       $$&&r   c                 "    U R                  5       $ r   )_find_back_edgesr    s    r   _back_edgesCFGraph._back_edges   r   r   c                 "    U R                  5       $ r   )_find_topo_orderr    s    r   _topo_orderCFGraph._topo_order   r   r   c                 "    U R                  5       $ r   )_find_descendentsr    s    r   _descsCFGraph._descs   r   r   c                 "    U R                  5       $ r   )_find_loopsr    s    r   _loopsCFGraph._loops   s    !!r   c                 "    U R                  5       $ r   )_find_in_loopsr    s    r   	_in_loopsCFGraph._in_loops   s    ""$$r   c                 "    U R                  5       $ r   )_find_post_dominatorsr    s    r   r{   CFGraph._post_doms   s    ))++r   c                 "    U R                  5       $ r   )_find_immediate_dominatorsr    s    r   r   CFGraph._idom   s    ..00r   c                 "    U R                  5       $ r   )_find_dominance_frontierr    s    r   r   CFGraph._df   s    ,,..r   c                 "    U R                  5       $ r   )_find_dominator_treer    s    r   r   CFGraph._domtree   s    ((**r   c                      U R                   U   $ )z`
Return the set of descendents of the given *node*, in topological
order (ignoring back edges).
)r   rZ   s     r   descendentsCFGraph.descendents   s    
 {{4  r   c                 8    U R                   c   eU R                   $ )z
Return the entry point node.
)rV   r    s    r   entry_pointCFGraph.entry_point   s"       ,,,   r   c                     U R                   $ )z7
Return the computed set of exit nodes (may be empty).
)r   r    s    r   exit_pointsCFGraph.exit_points  s        r   c                 4    U R                   U R                     $ )z
Return the set of nodes constituting the graph's backbone.
(i.e. the nodes that every path starting from the entry point
 must go through).  By construction, it is non-empty: it contains
 at least the entry point.
)r{   rV   r    s    r   backboneCFGraph.backbone  s     t0011r   c                     U R                   $ )zp
Return a dictionary of {node -> loop} mapping each loop header
to the loop (a Loop instance) starting with it.
)r   r    s    r   loopsCFGraph.loops  s    
 {{r   c                 ~    U R                   R                  US5       Vs/ s H  o R                  U   PM     sn$ s  snf )zU
Return the list of Loop objects the *node* belongs to,
from innermost to outermost.
r(   )r   getr   )r   r[   xs      r   in_loopsCFGraph.in_loops  s5    
 )-(:(:4(DE(D1A(DEEEs   :c                     U R                   $ )z;
Return the set of dead nodes (eliminated from the graph).
)_dead_nodesr    s    r   
dead_nodesCFGraph.dead_nodes  s     r   c                     U R                   $ )z
Return the set of live nodes.
)rR   r    s    r   nodesCFGraph.nodes$  s     {{r   c                     U R                   $ )zJ
Return the sequence of nodes in topological order (ignoring back
edges).
)r   r    s    r   
topo_orderCFGraph.topo_order*  s    
 r   c              #      #    [        U5      nU R                  nU(       a  [        U5      nU H  nXA;   d  M
  Uv   M     g7f)zn
Iterate over the *nodes* in topological order (ignoring back edges).
The sort isn't guaranteed to be stable.
N)rQ   r   reversed)r   r   reverseitns        r   	topo_sortCFGraph.topo_sort1  s;     
 E
"BAz s
   2A	Ac                 "   SSK nU=(       d    [        R                  n [        SUS9  U R	                  U5        [        SUS9  UR                  U R
                  US9  [        SUS9  UR                  U R                  US9  [        S[        U R                  5      US9  [        S	US9  UR                  U R                  US9  [        S
US9  UR                  U R                  US9  [        SUS9  UR                  U R                  5       US9  g)z#
Dump extensive debug information.
r   NzCFG adjacency lists:filezCFG dominators:streamzCFG post-dominators:zCFG back edges:z
CFG loops:zCFG node-to-loops:zCFG backbone:)pprintsysstdoutprint_dump_adj_listsrv   r{   r   r   r   r   r   )r   r   r   s      r   dumpCFGraph.dump>  s     	!szz(t4  &d+djj.$40dood3(8(8!9El&dkk$/".dnnT2oD)dmmod3r   c                 T    SSK nUR                  US9nU R                   H  nUR	                  [        U5      5        M     U R                   H=  nU R                  U    H'  nUR                  [        U5      [        U5      5        M)     M?     U$ ! [         a    [        S5      ef = f)zRender the controlflow graph with GraphViz DOT via the
``graphviz`` python binding.

Returns
-------
g : graphviz.Digraph
    Use `g.view()` to open the graph in the default PDF application.
r   NzcThe feature requires `graphviz` but it is not available. Please install with `pip install graphviz`)filename)graphvizImportErrorDigraphrR   r[   strrT   edge)r   r   gvgr   r   s         r   
render_dotCFGraph.render_dotS  s    	! JJJ)AFF3q6N  AAs1vs4y) '    	= 	s   B B'c                     U R                   U   R                  U5        U R                  U   R                  U5        X0R                  X4'   g r   )rS   rY   rT   rU   )r   from_torc   s       r   r`   CFGraph._add_edgep  s?     	BE"Er"%)	"r   c                 @   U R                   R                  US5       H/  nU R                  U   R                  U5        U R                  X4	 M1     U R                  R                  US5       H/  nU R                   U   R                  U5        U R                  X14	 M1     g )Nr(   )rT   poprS   removerU   )r   r[   succpreds       r   _remove_node_edgesCFGraph._remove_node_edgesw  s    KKOOD"-DKK$$T*
+ . KKOOD"-DKK$$T*
+ .r   c              #     #    Uc  U R                   4n[        5       n[        U5      nU(       a[  UR                  5       nXB;  a<  Uv   UR	                  U5        U R
                  U    H  nUR                  U5        M     U(       a  MZ  g g 7fr   )rV   rQ   listr   rY   rT   append)r   r9   seenstackr[   r   s         r   _dfsCFGraph._dfs  sr     ?((*GuW99;D
 KK-DLL& . es   BB	Bc                     [        5       nU R                  5        H  nUR                  U5        M     U R                  U-
  U l        Xl        U R                   H  nU R                  U5        M     g)z`
Eliminate all blocks not reachable from the entry point, and
stash them into self._dead_nodes.
N)rQ   r   rY   rR   r   r   )r   liver[   deads       r   rr   CFGraph._eliminate_dead_blocks  sZ    
 uIIKDHHTN  ;;-$$D##D) %r   c                     [        5       nU R                   H6  nU R                  R                  U5      (       a  M%  UR	                  U5        M8     U$ )z"
Compute the graph's exit points.
)rQ   rR   rT   r   rY   )r   r   r   s      r   r   CFGraph._find_exit_points  s@     eA;;??1%%"  r   c                    ^^^^^^ U R                   mU R                  m/ m[        5       m/ mUUUUUU4S jmTU R                  4/mT(       a#  TR	                  5       u  pU" U5        T(       a  M#  T$ )Nc                    > U T;  aW  TR                  U 5        TR                  TR                  U 45        TU     H  nX4T;  d  M  TR                  TU45        M!     g g r   rY   r   )r[   rb   
back_edgesdfs_rec
post_orderr   r   succss     r   r  (CFGraph._find_postorder.<locals>.dfs_rec  sZ    4j//67!$KD|:5gt_5 (  r   )rT   r   rQ   rV   r   )	r   cbrc   r
  r  r  r   r   r  s	      @@@@@@r   _find_postorderCFGraph._find_postorder  sm    %%

u
	6 	6 4,,-.yy{HBtH e r   c                   ^
^ U
U4S jnU R                   nU R                  nU R                  5       n[        U5       VVs0 s H  u  pVXe_M	     snnmX"0m
UR	                  5         UR                  5         SnU(       aO  SnU H>  n[        R                  " UU
4S jX8    5       5      n	UT
;  d  T
U   U	:w  d  M7  U	T
U'   SnM@     U(       a  MO  T
$ s  snnf )Nc                    > X:w  aE  TU    TU   :  a  TU    n TU    TU   :  a  M  TU    TU   :  a  TU   nTU    TU   :  a  M  X:w  a  ME  U $ r   r(   )uvidomidxs     r   	intersect5CFGraph._find_immediate_dominators.<locals>.intersect  sh    &!fs1voQA !fs1vo!fs1voQA !fs1vo &
 Hr   TFc              3   8   >#    U  H  nUT;   d  M  Uv   M     g 7fr   r(   ).0r  r  s     r   	<genexpr>5CFGraph._find_immediate_dominators.<locals>.<genexpr>  s      -;101T	 ./Qs   
	)rV   rS   r  	enumerater   r   	functoolsreduce)r   r  entrypreds_tableorderiechangedr  new_idomr  r  s             @@r   r   "CFGraph._find_immediate_dominators  s    	 !!kk$$& )% 01 0qt 01		G$++I-; -;< D=DGx$7&DG"G  g ! 2s    Cc                     U R                   n[        [        5      nUR                  5        H0  u  p4X2;  a  [        5       X#'   X4:w  d  M  X$   R	                  U5        M2     U$ r   )r   r<   rQ   rI   rY   )r   r  domtreer  r  s        r   r   CFGraph._find_dominator_tree  sP    zz#C(JJLDA U
v
q! ! r   c                    U R                   nU R                  nU Vs0 s H  o3[        5       _M     nnU HL  n[        X#   5      S:  a  M  X#    H.  nXQU   :w  d  M  XE   R	                  U5        X   nXQU   :w  a  M!  M0     MN     U$ s  snf )N   )r   rS   rQ   lenrY   )r   r  r"  r  dfr  s         r   r    CFGraph._find_dominance_frontier  s    zzkk $%1h%A;>"Q& ^7lEIIaLA 7l $  	 &s   Bc           	         U(       a.  [        U R                  5      nU R                  nU R                  nO.[        U R                  /5      nU R                  nU R                  nU(       d  [        S5      e0 nU H  n[        U/5      XV'   M     / nU R                   H2  nX;  d  M
  [        U R                  5      XX'   UR                  U5        M4     U(       a  UR                  5       nX;   a  M  [        U/5      n	X8   n
U
(       a;  U	[        R                  " [         R                  U
 Vs/ s H  oU   PM	     sn5      -  n	XU   :w  a3  [        U	5      [        XX   5      :  d   eXU'   UR                  XH   5        U(       a  M  U$ s  snf )Nz5no entry points: dominator algorithm cannot be seeded)rQ   r   rT   rS   rV   rq   rR   r   r   r  r   intersectionr.  extend)r   postr9   r"  succs_tabledomsr%  todor   new_domspredsps               r   _find_dominators_internal!CFGraph._find_dominators_internal   sd   
 $++,G++K++K4,,-.G++K++K  2 3 3 A1#hDG  Adkk*A 
 
A|A3xHNEI,,S-=-=?D-Eu!1gu-EG G7"8}s47|333"QKN+ d  .Fs   ,F	c                      U R                  SS9$ )NFr4  )r;  r    s    r   r   CFGraph._find_dominators+  s    --5-99r   c                    [        5       nU R                  R                  U5        U R                  R	                  5        H:  nUR
                  (       a  M  UR                   H  nU R                  X15        M     M<     U R                  SS9nXA	 UR	                  5        H  nUR                  U5        M     U R                  U5        U R                  R                  U5        U$ )NTr>  )objectr   rY   r   valuesr:   r   r`   r;  discardr   r   )r   
dummy_exitloopbpdomsr6  s         r   r   CFGraph._find_post_dominators.  s     X
j)KK&&(D:::ANN11 # ) ..D.9LLNDLL$ #
+  ,r   c                   ^ ^
^ Ub>  [        U[        5      (       d  [        S[        U5       35      eUR	                  SS5        [        5       n/ m
0 mT R                  5       n[        5       nU U
U4S jnU" U5        SnT
(       aw  US-  nT
S   nTU   nU(       a7  UR                  5       n	U	T
;   a  UR                  Xy45        O/X;  a  U" U	5        O!T
R                  5         UR                  U5        T
(       a  Mw  Ub  US==   U-  ss'   U$ )z]
Find back edges.  An edge (src, dest) is a back edge if and
only if *dest* dominates *src*.
z*stats* must be a dict; got iteration_countr   c                 v   > TR                  U 5        TR                  U     Vs/ s H  oPM     snTU '   g s  snf r   )r   rT   )r[   rb   r   r   succs_states     r   
push_state,CFGraph._find_back_edges.<locals>.push_stateZ  s6    LL26++d2C D2C$2C DK Ds   6   )	r-   dict	TypeErrortype
setdefaultrQ   r   r   rY   )r   statsr
  r   checkedrM  iter_cttos	tos_succscur_noder   rL  s   `         @@r   r   CFGraph._find_back_edgesC  s    eT**">tE{m LMM.2
 U
&&(%	E 	; qLG)C#C(I$==?u$NNC?3,x( 		C % e( #$/$r   c                    ^^^^^ U R                   mU R                  m/ m[        5       mUUUUU4S jmT" U R                  5        TR	                  5         T$ )Nc                    > U T;  a@  TR                  U 5        TU     H  nX4T;  d  M  T" U5        M     TR                  U 5        g g r   r	  )r[   rb   _dfs_recr
  r  r   r  s     r   r^  *CFGraph._find_topo_order.<locals>._dfs_rec  sJ    4!$KD|:5  ( !!$'  r   )rT   r   rQ   rV   r   )r   r^  r
  r  r   r  s    @@@@@r   r   CFGraph._find_topo_orderz  sO    %%

u	( 	( 	""#r   c                     0 n[        U R                  5       H^  n[        5       =X'   nU R                  U    H:  nX$4U R                  ;  d  M  UR                  U5        UR                  X   5        M<     M`     U$ r   )r   r   rQ   rT   r   rY   update)r   descsr[   
node_descsr   s        r   r   CFGraph._find_descendents  sp    T--.D'*u,EK*D)<t'7'77NN4(%%ek2 * / r   c                 J   0 nU R                    H  u  p#Un[        U/5      nU/nU(       aM  UR                  5       nXu;  a/  UR                  U5        UR	                  U R
                  U   5        U(       a  MM  XA;   a  X   R                  U5        M  XQU'   M     0 nUR                  5        Hr  u  pE[        5       n	[        5       n
U HE  nU	R                  U R
                  U   U-
  5        U
R                  U R                  U   U-
  5        MG     [        XEXS9nXU'   Mt     U$ )z3
Find the loops defined by the graph's back edges.
)r.   r   r9   r:   )
r   rQ   r   rY   r3  rS   rb  rI   rT   r*   )r   bodiesra   rb   r.   r   queuer   r   r9   r:   rE  s               r   r   CFGraph._find_loops  s    ))ICF x=DEEIIK=HHQKLLQ0	 % %%d+!%v# *( "LLNLFeGEEt{{1~45T[[^d23  v'OD &M + r   c                     U R                   n[        S U R                   5       5      n[        UR	                  5       S S9 H3  nUR
                   H   nX$   R                  UR                  5        M"     M5     U$ )Nc              3   (   #    U  H  o/ 4v   M
     g 7fr   r(   )r  r   s     r   r  )CFGraph._find_in_loops.<locals>.<genexpr>  s     5ABs   c                 ,    [        U R                  5      $ r   )r.  r   )rE  s    r   <lambda>(CFGraph._find_in_loops.<locals>.<lambda>  s    C		Nr   )key)r   rQ  rR   r   rB  r   r   r.   )r   r   r   rE  r   s        r   r   CFGraph._find_in_loops  sc    555 5<<>/JKDYY""4;;/  L r   c                 ~    [        S U R                  R                  5        5       5      nSS KnUR                  X!S9  g )Nc              3   R   #    U  H  u  pU[        [        U5      5      4v   M     g 7fr   )r   r   )r  ra   destss      r   r  *CFGraph._dump_adj_lists.<locals>.<genexpr>  s(      @+>ZS vd5k23+>s   %'r   r   )rQ  rT   rI   r   )r   r   	adj_listsr   s       r   r   CFGraph._dump_adj_lists  s:     @+/;;+<+<+>@ @	i-r   c                     [        U[        5      (       d  [        $ S H"  n[        XS 5      n[        XS 5      nX4:w  d  M"    g   g)N)rR   rU   rV   rS   rT   FT)r-   rN   r@   getattr)r   r0   r   thisthats        r   r1   CFGraph.__eq__  sE    %))!!MA4D)D5T*D|	 N
 r   c                 .    U R                  U5      (       + $ r   )r1   r/   s     r   rF   CFGraph.__ne__  s    ;;u%%%r   )r   rU   rV   rR   rS   rT   r   )F)znumba_cfg.dot)?r#   r$   r%   r&   r7   r   r\   rd   rg   rk   rn   rs   rw   r|   r   r   r   r  cached_propertyr   rv   r   r   r   r   r   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r`   r   r   rr   r   r  r   r   r   r;  r   r   r   r   r   r   r   r   r1   rF   r'   r(   r   r   rN   rN   T   s   !(32!&	 ( ( ' ' ' ' ' ' ( ( " " % % , , 1 1 / / + +!!!2F  4*:*,'*0&P)V:*5n$"H	.	&r   rN   c                      \ rS rSrSrS rS rS rS rSS jr	S	 r
SS
 jrS rS rS rS rS rS rS rS rS r\r\r\r\r\r\r\r\rS r\r\rS r S r!\!r"S r#\$S;   a  S r%O\$S;   a  O\&" \$5      eS r'S r(Sr)g) ControlFlowAnalysisi  z
Attributes
----------
- bytecode

- blocks

- blockseq

- doms: dict of set
    Dominators

- backbone: set of block offsets
    The set of block that is common to all possible code path.

c                     Xl         0 U l        0 U l        / U l        S U l        S U l        SU l        S U l        / U l        / U l	        / U l
        g NT)bytecodeblocks
liveblocksblockseqr6  r   _force_new_block	_curblock_blockstackr   _withs)r   r  s     r   r   ControlFlowAnalysis.__init__  sO     	 $r   c              #   T   #    U R                    H  nU R                  U   v   M     g7f)z-
Return all blocks in sequence of occurrence
N)r  r  r   r$  s     r   
iterblocksControlFlowAnalysis.iterblocks  s#      A++a.  s   &(c              #   v   #    U R                    H%  nXR                  ;   d  M  U R                  U   v   M'     g7f)z2
Return all live blocks in sequence of occurrence
N)r  r  r  r  s     r   iterliveblocks"ControlFlowAnalysis.iterliveblocks   s-      AOO#kk!n$ s   99c              #      #    UR                   R                  5        H)  u  p#X R                  ;   d  M  U R                  U   U4v   M+     g7f)zA
Yield (incoming block, number of stack pops) pairs for *block*.
N)r   rI   r  r  )r   blockr$  popss       r   incoming_blocks#ControlFlowAnalysis.incoming_blocks  s?      ++113GAOO#kk!nd** 4s
   -AANc                 6    U R                   R                  S S9  g )Nr   )graphr   )r   r   s     r   r   ControlFlowAnalysis.dump  s    

T"r   c                   ^  T R                  5        H  nSUR                  -  n[        T US 5      nUb
  U" U5        M,  UR                  (       a_  [	        T R
                  R                  R                  UR                  5      nUR                  S;   a  SnOSUR                  -  n[        XTS9eM     [        T R                  T R                  SS  5       HI  u  pgT R                  U   nUR                  (       a  M'  UR                  (       a  M:  SUR                  U'   MK     [        5       n	T R                   H  n
U	R!                  U
5        M     T R                  R#                  5        HB  n
U
R                  R%                  5        H!  u  pU	R'                  U
R(                  X5        M#     MD     U	R+                  [-        T R                  5      5        U	R/                  5         U	T l        T R                  R#                  5        HL  n
U
R                  R%                  5        H+  u  pUT R                  U   R2                  U
R(                  '   M-     MN     [5        U 4S jT R0                  R7                  5        5       5      T l        [;        T R                  5       H  nUT R8                  ;   d  M    O   [=        S	5      eT R0                  R?                  5       n[A        5       nT R                  RC                  5        H6  n
T R0                  RE                  U
5      (       d  M%  URG                  U
5        M8     X-
  T l        g )
Nzop_%s>   SETUP_FINALLYz2'try' block not supported until python3.7 or laterz$Use of unsupported opcode (%s) found)locrO  r   c              3   F   >#    U  H  nUTR                   U   4v   M     g 7fr   )r  )r  r$  r   s     r   r  *ControlFlowAnalysis.run.<locals>.<genexpr>;  s%      <(:1 !"4;;q>2(:s   !zNo live block that exits!?)$
_iter_instopnamery  is_jumpr   r  func_idr   linenor   zipr  r  r   r   rN   r\   rB  rI   rd   r   rn   minrs   r  r   rQ  r   r  r   AssertionErrorr   rQ   keysr   rY   )r   instfnamefnlmsgcurnxtblkr  rF  outr  lastblkr   inloopblockss   `               r   runControlFlowAnalysis.run  s   OO%Ddkk)Eud+B~4--66D;;"33NC@4;;NC&s22  &$ DMM4==+<=HC++c"C%%%cooo*+""3' >
 	ANN1 ##%A--335	qxx3 6 & 	c$++./
 ##%A--335	<@C //9 6 &
  <(,

(8(8(:< <  .G$//) / !!=>> ::&&( u!!#Azz""1%%  # $ !/r   c                 4    X R                   R                  U'   g)z~
Register a jump (conditional or not) to *target* offset.
*pops* is the number of stack pops implied by the jump (default 0).
N)r  r   )r   targetr  s      r   jumpControlFlowAnalysis.jumpQ  s    
 15%%f-r   c              #     #    U R                    Hn  nU R                  U5      (       a"  U R                  U5        U R                  U5        U R                  R
                  R                  UR                  5        Uv   Mp     g 7fr   )r  _use_new_block_guard_with_as_start_new_blockr  r   r   r   r   r  s     r   r  ControlFlowAnalysis._iter_instX  sa     MMD""4((##D)%%d+NN&&t{{3J "s   B Bc                     UR                   U R                  R                  ;   a  SnO#UR                  [        ;   a  SnOU R
                  nSU l        U$ )NTF)r   r  labelsr  NEW_BLOCKERSr  )r   r  ress      r   r  "ControlFlowAnalysis._use_new_block`  sF    ;;$--...C[[L(C''C %
r   c                     [        UR                  5      U l        U R                  U R                  UR                  '   U R                  R                  UR                  5        g r   )r   r   r  r  r  r   r  s     r   r  $ControlFlowAnalysis._start_new_blockk  s>     -#'>>DKK T[[)r   c                     UR                   S:X  a7  U R                  UR                     R                   nUS:w  a  Sn[        U5      egg)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)`).r   POP_TOPzGThe 'with (context manager) as (variable):' construct is not supported.N)r  r  nextr   )r   current_instnext_opr  s       r   r  "ControlFlowAnalysis._guard_with_asp  sR     ,.mmL$5$56==G)#$ 's++	 $ /r   c                     UR                  5       nU R                  R                  U5        U R                  R                  UR                  U45        U R                  UR                  5        SU l        g r  )get_jump_targetr  r   r   r   r  r  r  r   r  ends      r   op_SETUP_LOOP!ControlFlowAnalysis.op_SETUP_LOOP|  Y    ""$$DKK-. 			$)) $r   c                     UR                  5       nU R                  R                  U5        U R                  R                  UR                  U45        U R                  UR                  5        SU l        g r  )r  r  r   r  r   r  r  r  r  s      r   op_SETUP_WITH!ControlFlowAnalysis.op_SETUP_WITH  r  r   c                 8    U R                   R                  5         g r   )r  r   r  s     r   op_POP_BLOCK ControlFlowAnalysis.op_POP_BLOCK  s    r   c                     U R                  UR                  5       5        U R                  UR                  5        SU l        g r  r  r  r  r  r  s     r   op_FOR_ITERControlFlowAnalysis.op_FOR_ITER  /    		$&&()		$)) $r   c                     U R                  UR                  5       5        U R                  UR                  5        SU l        g r  r  r  s     r   _op_ABSOLUTE_JUMP_IF(ControlFlowAnalysis._op_ABSOLUTE_JUMP_IF  r  r   c                     U R                  UR                  5       5        U R                  UR                  SS9  SU l        g )NrO  )r  Tr  r  s     r   _op_ABSOLUTE_JUMP_OR_POP,ControlFlowAnalysis._op_ABSOLUTE_JUMP_OR_POP  s3    		$&&()		$))!	$ $r   c                 P    U R                  UR                  5       5        SU l        g r  r  r  r  r  s     r   op_JUMP_ABSOLUTE$ControlFlowAnalysis.op_JUMP_ABSOLUTE      		$&&() $r   c                 P    U R                  UR                  5       5        SU l        g r  r  r  s     r   op_JUMP_FORWARD#ControlFlowAnalysis.op_JUMP_FORWARD  r  r   c                 4    SU R                   l        SU l        g r  r  r   r  r  s     r   op_RETURN_VALUE#ControlFlowAnalysis.op_RETURN_VALUE      %)" $r   ))      )r     c                 4    SU R                   l        SU l        g r  r  r  s     r   op_RETURN_CONST#ControlFlowAnalysis.op_RETURN_CONST  s    )-DNN&$(D!r   ))r  
   )r     c                 4    SU R                   l        SU l        g r  r  r  s     r   op_RAISE_VARARGS$ControlFlowAnalysis.op_RAISE_VARARGS  r  r   c                 N    U R                  U R                  S   5        SU l        g )NrP  T)r  r  r  r  s     r   op_BREAK_LOOP!ControlFlowAnalysis.op_BREAK_LOOP  s!    		$""2&' $r   )r  r  r  r   r  r   r  r  r  r6  r  r  r   )r   )*r#   r$   r%   r&   r7   r   r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  op_POP_JUMP_IF_FALSEop_POP_JUMP_IF_TRUEop_JUMP_IF_FALSEop_JUMP_IF_TRUEop_POP_JUMP_FORWARD_IF_FALSEop_POP_JUMP_BACKWARD_IF_FALSEop_POP_JUMP_FORWARD_IF_TRUEop_POP_JUMP_BACKWARD_IF_TRUEr  op_JUMP_IF_FALSE_OR_POPop_JUMP_IF_TRUE_OR_POPr  r  op_JUMP_BACKWARDr  r   r  NotImplementedErrorr  r  r'   r(   r   r   r  r    s     !%+#<0|5	*

,%%%
%
 0.+*O#7 $8!"6#7 %
 75%% '% &&	) 
(	(!),,%%r   r  )collectionsr  r   numba.core.irr   numba.core.errorsr   numba.core.utilsr   	frozensetr  rA  r   
namedtupler*   defaultdictr<   rN   r  r(   r   r   <module>r     s      
  . &   
f .!;!!&"HJ !(A// A2C
&f C
&Lr%& r%r   