
    xKgy                         d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ  e	g d      Z
 G d de      Z G d d	 e j                  d	d
            Z G d de j                        Z G d de      Z G d de      Zy)    N)Loc)UnsupportedError)	PYVERSION)
SETUP_LOOPFOR_ITER
SETUP_WITHBEFORE_WITHc                       e Zd Zd Zd Zd Zy)CFBlockc                 J    || _         g | _        i | _        i | _        d| _        y )NF)offsetbodyoutgoing_jumpsincoming_jumpsterminating)selfr   s     Z/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/core/controlflow.py__init__zCFBlock.__init__   s,    	 ! !     c                 v    | j                   t        | j                        t        | j                        f}d|z  S )Nz,block(offset:%d, outgoing: %s, incoming: %s))r   sortedr   r   )r   argss     r   __repr__zCFBlock.__repr__   s9    t**+t**+- >DDr   c                 ,    t        | j                        S N)iterr   r   s    r   __iter__zCFBlock.__iter__#   s    DIIr   N)__name__
__module____qualname__r   r   r    r   r   r   r      s    	!Er   r   c                        e Zd ZdZdZd Zd Zy)Loopz?
    A control flow loop, as detected by a CFGraph object.
    r"   c                 X    t        |t              xr |j                  | j                  k(  S r   )
isinstancer$   headerr   others     r   __eq__zLoop.__eq__4   s!    %&F5<<4;;+FFr   c                 ,    t        | j                        S r   )hashr'   r   s    r   __hash__zLoop.__hash__7   s    DKK  r   N)r   r    r!   __doc__	__slots__r*   r-   r"   r   r   r$   r$   '   s     IG!r   r$   )entriesexitsr'   r   c                   "    e Zd ZdZd Zd Zd Zy)_DictOfContainerszA defaultdict with customized equality checks that ignore empty values.

    Non-empty value is checked by: `bool(value_item) == True`.
    c                 x    t        |t              r%| j                         }|j                         }||k(  S t        S r   )r&   r3   _non_empty_itemsNotImplemented)r   r)   minetheirss       r   r*   z_DictOfContainers.__eq__A   s9    e./((*D++-F6>!r   c                 >    | j                  |      }|t        u r|S | S r   )r*   r6   )r   r)   rets      r   __ne__z_DictOfContainers.__ne__I   s$    kk% . J7Nr   c                 p    t        | j                               D cg c]  \  }}|s	||f c}}S c c}}w r   )r   items)r   kvss      r   r5   z"_DictOfContainers._non_empty_itemsP   s1    %+DJJL%9@%9EArRB%9@@@s   
22N)r   r    r!   r.   r*   r;   r5   r"   r   r   r3   r3   ;   s    
Ar   r3   c                      e Zd ZdZd Zd Zd:dZd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zej"                  d        Zej"                  d        Zej"                  d        Zej"                  d        Zej"                  d        Zej"                  d        Zej"                  d        Zej"                  d        Zej"                  d        Zej"                  d        Zej"                  d        Zd Zd Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%d;d#Z&d:d$Z'd<d%Z(d:d&Z)d' Z*d:d(Z+d) Z,d* Z-d+ Z.d, Z/d- Z0d. Z1d;d/Z2d0 Z3d1 Z4d:d2Z5d3 Z6d4 Z7d5 Z8d6 Z9d7 Z:d8 Z;d9 Z<y)=CFGraphzB
    Generic (almost) implementation of a Control Flow Graph.
    c                     t               | _        t        t               | _        t        t               | _        i | _        d | _        y r   )set_nodesr3   _preds_succs
_edge_data_entry_pointr   s    r   r   zCFGraph.__init__Y   s2    e',', r   c                 :    | j                   j                  |       y)z
        Add *node* to the graph.  This is necessary before adding any
        edges from/to the node.  *node* can be any hashable object.
        N)rD   addr   nodes     r   add_nodezCFGraph.add_node`   s    
 	r   Nc                     || j                   vrt        d|d| j                         || j                   vrt        d|d| j                         | j                  |||       y)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)rD   
ValueError	_add_edge)r   srcdestdatas       r   add_edgezCFGraph.add_edgeg   sb     dkk!!4;;0 1 1t{{""DKK1 2 2sD$'r   c              #   ^   K   | j                   |   D ]  }|| j                  ||f   f  yw)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)rF   rG   )r   rQ   rR   s      r   
successorszCFGraph.successorsv   s3     
 KK$DT	222 %   +-c              #   ^   K   | j                   |   D ]  }|| j                  ||f   f  yw)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)rE   rG   )r   rR   rQ   s      r   predecessorszCFGraph.predecessors~   s3     
 ;;t$CtsDy111 %rW   c                 2    || j                   v sJ || _        y)z=
        Set the entry point of the graph to *node*.
        N)rD   rH   rK   s     r   set_entry_pointzCFGraph.set_entry_point   s     t{{""" r   c                 R    | j                   t        d      | j                          y)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!)rH   RuntimeError_eliminate_dead_blocksr   s    r   processzCFGraph.process   s(     $899##%r   c                     | j                   S )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   
dominatorszCFGraph.dominators        zzr   c                     | j                   S )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_dominatorszCFGraph.post_dominators   s     r   c                     | j                   S )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_dominatorszCFGraph.immediate_dominators   rc   r   c                     | j                   S )a.  
        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_frontierzCFGraph.dominance_frontier   s     xxr   c                     | j                   S )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_treezCFGraph.dominator_tree   s     }}r   c                 "    | j                         S r   )_find_exit_pointsr   s    r   _exit_pointszCFGraph._exit_points       %%''r   c                 "    | j                         S r   )_find_dominatorsr   s    r   ra   zCFGraph._doms       $$&&r   c                 "    | j                         S r   )_find_back_edgesr   s    r   _back_edgeszCFGraph._back_edges   rv   r   c                 "    | j                         S r   )_find_topo_orderr   s    r   _topo_orderzCFGraph._topo_order   rv   r   c                 "    | j                         S r   )_find_descendentsr   s    r   _descszCFGraph._descs   rs   r   c                 "    | j                         S r   )_find_loopsr   s    r   _loopszCFGraph._loops   s    !!r   c                 "    | j                         S r   )_find_in_loopsr   s    r   	_in_loopszCFGraph._in_loops   s    ""$$r   c                 "    | j                         S r   )_find_post_dominatorsr   s    r   re   zCFGraph._post_doms   s    ))++r   c                 "    | j                         S r   )_find_immediate_dominatorsr   s    r   rh   zCFGraph._idom   s    ..00r   c                 "    | j                         S r   )_find_dominance_frontierr   s    r   rk   zCFGraph._df   s    ,,..r   c                 "    | j                         S r   )_find_dominator_treer   s    r   rn   zCFGraph._domtree   s    ((**r   c                      | j                   |   S )zx
        Return the set of descendents of the given *node*, in topological
        order (ignoring back edges).
        )r   rK   s     r   descendentszCFGraph.descendents   s    
 {{4  r   c                 6    | j                   J | j                   S )z.
        Return the entry point node.
        )rH   r   s    r   entry_pointzCFGraph.entry_point   s"       ,,,   r   c                     | j                   S )zG
        Return the computed set of exit nodes (may be empty).
        )rr   r   s    r   exit_pointszCFGraph.exit_points  s        r   c                 4    | j                   | j                     S )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.
        )re   rH   r   s    r   backbonezCFGraph.backbone  s     t0011r   c                     | j                   S )z
        Return a dictionary of {node -> loop} mapping each loop header
        to the loop (a Loop instance) starting with it.
        )r   r   s    r   loopszCFGraph.loops  s    
 {{r   c                 z    | j                   j                  |d      D cg c]  }| j                  |    c}S c c}w )zm
        Return the list of Loop objects the *node* belongs to,
        from innermost to outermost.
        r"   )r   getr   )r   rL   xs      r   in_loopszCFGraph.in_loops  s7    
 )-(:(:4(DE(D1A(DEEEs   8c                     | j                   S )zK
        Return the set of dead nodes (eliminated from the graph).
        )_dead_nodesr   s    r   
dead_nodeszCFGraph.dead_nodes  s     r   c                     | j                   S )z/
        Return the set of live nodes.
        )rD   r   s    r   nodeszCFGraph.nodes$  s     {{r   c                     | j                   S )zb
        Return the sequence of nodes in topological order (ignoring back
        edges).
        )r|   r   s    r   
topo_orderzCFGraph.topo_order*  s    
 r   c              #   t   K   t        |      }| j                  }|rt        |      }|D ]  }||v s|  yw)z
        Iterate over the *nodes* in topological order (ignoring back edges).
        The sort isn't guaranteed to be stable.
        N)rC   r|   reversed)r   r   reverseitns        r   	topo_sortzCFGraph.topo_sort1  s>     
 E
"BAEz s   .88c                 `   ddl }|xs t        j                  }	 t        d|       | j	                  |       t        d|       |j                  | j
                  |       t        d|       |j                  | j                  |       t        dt        | j                        |       t        d	|       |j                  | j                  |       t        d
|       |j                  | j                  |       t        d|       |j                  | j                         |       y)z3
        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_listsra   re   r   ry   r   r   r   )r   r   r   s      r   dumpzCFGraph.dump>  s     	!szz(t4  &d+djj.$40dood3(8(8!9El&dkk$/".dnnT2oD)dmmod3r   c                 L   	 ddl }|j                  |      }| j                  D ]  }|j	                  t        |              | j                  D ]:  }| j                  |   D ]&  }|j                  t        |      t        |             ( < |S # t        $ r t        d      w xY w)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DigraphrD   rL   strrF   edge)r   r   gvgr   r   s         r   
render_dotzCFGraph.render_dotS  s    	! JJJ)AFF3q6N  AAs1vs4y) '    	= 	s   B B#c                     | j                   |   j                  |       | j                  |   j                  |       || j                  ||f<   y r   )rE   rJ   rF   rG   )r   from_torS   s       r   rP   zCFGraph._add_edgep  sC     	BE"Er"%)r	"r   c                 <   | j                   j                  |d      D ]/  }| j                  |   j                  |       | j                  ||f= 1 | j                  j                  |d      D ]/  }| j                   |   j                  |       | j                  ||f= 1 y )Nr"   )rF   poprE   removerG   )r   rL   succpreds       r   _remove_node_edgeszCFGraph._remove_node_edgesw  s    KKOOD"-DKK$$T*d
+ . KKOOD"-DKK$$T*d
+ .r   c              #      K   || j                   f}t               }t        |      }|rR|j                         }||vr:| |j	                  |       | j
                  |   D ]  }|j                  |        |rQy y wr   )rH   rC   listr   rJ   rF   append)r   r0   seenstackrL   r   s         r   _dfszCFGraph._dfs  ss     ?((*GuW99;D4
 KK-DLL& . s   A7A<:A<c                     t               }| j                         D ]  }|j                  |        | j                  |z
  | _        || _        | j                  D ]  }| j                  |        y)zx
        Eliminate all blocks not reachable from the entry point, and
        stash them into self._dead_nodes.
        N)rC   r   rJ   rD   r   r   )r   liverL   deads       r   r^   zCFGraph._eliminate_dead_blocks  s\    
 uIIKDHHTN  ;;-$$D##D) %r   c                     t               }| j                  D ]/  }| j                  j                  |      r|j	                  |       1 |S )z2
        Compute the graph's exit points.
        )rC   rD   rF   r   rJ   )r   r   r   s      r   rq   zCFGraph._find_exit_points  s=     eA;;??1%"  r   c                     | j                   | j                  g t               g fd| j                  fgrj	                         \  }} ||       rS )Nc                     | vrSj                  |        j                  j                  | f       |    D ]  }| |fvs
j                  |f        y y r   rJ   r   )rL   rR   
back_edgesdfs_rec
post_orderr   r   succss     r   r   z(CFGraph._find_postorder.<locals>.dfs_rec  s\    4j//67!$KDd|:5gt_5 (  r   )rF   ry   rC   rH   r   )	r   cbrS   r   r   r   r   r   r   s	      @@@@@@r   _find_postorderzCFGraph._find_postorder  sm    %%

u
	6 	6 4,,-.yy{HBtH  r   c                   
 
fd}| j                   }| j                  }| j                         }t        |      D ci c]  \  }}||
 c}}||i
|j	                          |j                          d}|rBd}|D ]8  }t        j                  |
fd||   D              }	|
vs	
|   |	k7  s2|	
|<   d}: |rB
S c c}}w )Nc                     | |k7  r>|    |   k  r|    } |    |   k  r|    |   kD  r|   }|    |   kD  r| |k7  r>| S r   r"   )uvidomidxs     r   	intersectz5CFGraph._find_immediate_dominators.<locals>.intersect  sl    q&!fs1voQA !fs1vo!fs1voQA !fs1vo q&
 Hr   TFc              3   *   K   | ]
  }|v r|  y wr   r"   ).0r   r   s     r   	<genexpr>z5CFGraph._find_immediate_dominators.<locals>.<genexpr>  s      -;101T	 ./s   )rH   rE   r   	enumerater   r   	functoolsreduce)r   r   entrypreds_tableorderiechangedr   new_idomr   r   s             @@r   r   z"CFGraph._find_immediate_dominators  s    	 !!kk$$& )% 01 01q!t 01		G$++I-;A -;< D=DGx$7&DG"G   ! 2s   B<c                     | j                   }t        t              }|j                         D ]0  \  }}||vrt               ||<   ||k7  s||   j	                  |       2 |S r   )rh   r3   rC   r=   rJ   )r   r   domtreer   r   s        r   r   zCFGraph._find_dominator_tree  sZ    zz#C(JJLDAq U
Av
q! ! r   c                    | j                   }| j                  }|D ci c]  }|t                }}|D ]I  }t        ||         dk  r||   D ]-  }|||   k7  s||   j	                  |       ||   }|||   k7  r"/ K |S c c}w )N   )rh   rE   rC   lenrJ   )r   r   r   r   dfr   s         r   r   z CFGraph._find_dominance_frontier  s    zzkk $%1ah%A;q>"Q& ^47lqEIIaLQA 47l $  	 &s   Bc           	         |r.t        | j                        }| j                  }| j                  }n.t        | j                  g      }| j                  }| j                  }|st        d      i }|D ]  }t        |g      ||<    g }| j                  D ]0  }||vst        | j                        ||<   |j                  |       2 |r|j                         }||v rt        |g      }	||   }
|
r8|	t        j                  t         j                  |
D cg c]  }||   	 c}      z  }	|	||   k7  r5t        |	      t        ||         k  sJ |	||<   |j                  ||          |r|S c c}w )Nz5no entry points: dominator algorithm cannot be seeded)rC   rr   rF   rE   rH   r]   rD   r   r   r   r   intersectionr   extend)r   postr0   r   succs_tabledomsr   todor   new_domspredsps               r   _find_dominators_internalz!CFGraph._find_dominators_internal   sv   
 $++,G++K++K4,,-.G++K++K  2 3 3 A1#hDG  Adkk*QA 
 
AG|A3xHNEI,,S-=-=?D-Eu!d1gu-EG G47"8}s47|333"QKN+   .Fs   E)c                 &    | j                  d      S )NFr   )r   r   s    r   ru   zCFGraph._find_dominators+  s    --5-99r   c                    t               }| j                  j                  |       | j                  j	                         D ]2  }|j
                  r|j                  D ]  }| j                  ||        4 | j                  d      }||= |j	                         D ]  }|j                  |        | j                  |       | j                  j                  |       |S )NTr   )objectrr   rJ   r   valuesr1   r   rP   r   discardr   r   )r   
dummy_exitloopbpdomsr   s         r   r   zCFGraph._find_post_dominators.  s     X
j)KK&&(D::ANN1j1 # ) ..D.9*LLNDLL$ #
+  ,r   c                    
 |9t        |t              st        dt        |             |j	                  dd       t               }g 
i  j                         }t               } 
fd} ||       d}
rj|dz  }
d   }|   }|r5|j                         }	|	
v r|j                  ||	f       n.|	|vr* ||	       n!
j                          |j                  |       
rj||dxx   |z  cc<   |S )zu
        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                 r    j                  |        j                  |    D cg c]  }| c}| <   y c c}w r   )r   rF   )rL   rR   r   r   succs_states     r   
push_statez,CFGraph._find_back_edges.<locals>.push_stateZ  s6    LL26++d2C D2C$2C DK Ds   	4   )	r&   dict	TypeErrortype
setdefaultrC   r   r   rJ   )r   statsr   r   checkedr  iter_cttos	tos_succscur_noder   r  s   `         @@r   rx   zCFGraph._find_back_edgesC  s    eT*">tE{m LMM.2
 U
&&(%	E 	; qLG)C#C(I$==?u$NNC?3W,x( 		C % ( #$/$r   c                     | j                   | j                  g t               fd | j                         j	                          S )Nc                     | vr<j                  |        |    D ]  }| |fvs
 |        j                  |        y y r   r   )rL   rR   _dfs_recr   r   r   r   s     r   r  z*CFGraph._find_topo_order.<locals>._dfs_rec  sL    4!$KDd|:5  ( !!$'  r   )rF   ry   rC   rH   r   )r   r  r   r   r   r   s    @@@@@r   r{   zCFGraph._find_topo_orderz  sO    %%

u	( 	( 	""#r   c                     i }t        | j                        D ][  }t               x||<   }| j                  |   D ]8  }||f| j                  vs|j                  |       |j                  ||          : ] |S r   )r   r|   rC   rF   ry   rJ   update)r   descsrL   
node_descsr   s        r   r~   zCFGraph._find_descendents  sv    T--.D'*u,E$K*D)$<t'7'77NN4(%%eDk2 * / r   c                 6   i }| j                   D ]|  \  }}|}t        |g      }|g}|rF|j                         }||vr/|j                  |       |j	                  | j
                  |          |rF||v r||   j                  |       x|||<   ~ i }|j                         D ]v  \  }}t               }	t               }
|D ]D  }|	j                  | j
                  |   |z
         |
j                  | j                  |   |z
         F t        |||	|
      }|||<   x |S )zC
        Find the loops defined by the graph's back edges.
        )r'   r   r0   r1   )
ry   rC   r   rJ   r   rE   r  r=   rF   r$   )r   bodiesrQ   rR   r'   r   queuer   r   r0   r1   r  s               r   r   zCFGraph._find_loops  s    ))ICF x=DEEIIKD=HHQKLLQ0	  v%%d+!%v# *( "LLNLFDeGEEt{{1~45T[[^d23  vD'OD E&M + r   c                     | j                   }t        d | j                  D              }t        |j	                         d       D ]1  }|j
                  D ]   }||   j                  |j                         " 3 |S )Nc              3   $   K   | ]  }|g f 
 y wr   r"   )r   r   s     r   r   z)CFGraph._find_in_loops.<locals>.<genexpr>  s     5ABs   c                 ,    t        | j                        S r   )r   r   )r  s    r   <lambda>z(CFGraph._find_in_loops.<locals>.<lambda>  s    C		Nr   )key)r   r  rD   r   r  r   r   r'   )r   r   r   r  r   s        r   r   zCFGraph._find_in_loops  se    555 5<<>/JKDYY""4;;/  L r   c                     t        d | j                  j                         D              }dd l}|j                  ||       y )Nc              3   N   K   | ]  \  }}|t        t        |            f  y wr   )r   r   )r   rQ   destss      r   r   z*CFGraph._dump_adj_lists.<locals>.<genexpr>  s+      @+>ZS% vd5k23+>s   #%r   r   )r  rF   r=   r   )r   r   	adj_listsr   s       r   r   zCFGraph._dump_adj_lists  s<     @+/;;+<+<+>@ @	i-r   c                     t        |t              st        S dD ]#  }t        | |d       }t        ||d       }||k7  s# y y)N)rD   rG   rH   rE   rF   FT)r&   rA   r6   getattr)r   r)   r   thisthats        r   r*   zCFGraph.__eq__  sH    %)!!MA4D)D5!T*Dt|	 N
 r   c                 &    | j                  |       S r   )r*   r(   s     r   r;   zCFGraph.__ne__  s    ;;u%%%r   r   )F)znumba_cfg.dot)=r   r    r!   r.   r   rM   rT   rV   rY   r[   r_   rb   rf   ri   rl   ro   r   cached_propertyrr   ra   ry   r|   r   r   r   re   rh   rk   rn   r   r   r   r   r   r   r   r   r   r   r   r   rP   r   r   r^   rq   r   r   r   r   r   ru   r   rx   r{   r~   r   r   r   r*   r;   r"   r   r   rA   rA   T   s   !(32!&	 ( ( ' ' ' ' ' ' ( ( " " % % , , 1 1 / / + +!!!2F  4*:*,'*0&P)V:*5n$"H	.	&r   rA   c                       e Zd ZdZd Zd Zd Zd ZddZd Z	dd	Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd ZeZeZeZeZeZeZeZeZd ZeZeZd Zd Z e Z!d Z"e#dv rd Z$ne#dv rn e%e#      d Z&d Z'y)ControlFlowAnalysisz
    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                     || _         i | _        i | _        g | _        d | _        d | _        d| _        d | _        g | _        g | _	        g | _
        y NT)bytecodeblocks
liveblocksblockseqr   r   _force_new_block	_curblock_blockstackr   _withs)r   r7  s     r   r   zControlFlowAnalysis.__init__  sQ     	 $r   c              #   P   K   | j                   D ]  }| j                  |     yw)z=
        Return all blocks in sequence of occurrence
        N)r:  r8  r   r   s     r   
iterblockszControlFlowAnalysis.iterblocks  s$      A++a.  s   $&c              #   n   K   | j                   D ]"  }|| j                  v s| j                  |    $ yw)zB
        Return all live blocks in sequence of occurrence
        N)r:  r9  r8  r@  s     r   iterliveblocksz"ControlFlowAnalysis.iterliveblocks   s0      ADOO#kk!n$ s   55c              #      K   |j                   j                         D ]'  \  }}|| j                  v s| j                  |   |f ) yw)zQ
        Yield (incoming block, number of stack pops) pairs for *block*.
        N)r   r=   r9  r8  )r   blockr   popss       r   incoming_blocksz#ControlFlowAnalysis.incoming_blocks  sD      ++113GAtDOO#kk!nd** 4s
   /AANc                 <    | j                   j                  d        y )Nr   )graphr   )r   r   s     r   r   zControlFlowAnalysis.dump  s    

T"r   c                 6     j                         D ]  }d|j                  z  }t         |d       }|	 ||       *|j                  rat	         j
                  j                  j                  |j                        }|j                  dv rd}nd|j                  z  }t        ||       t         j                   j                  dd        D ]=  \  }} j                  |   }|j                  r"|j                  r/d|j                  |<   ? t               }	 j                  D ]  }
|	j!                  |
         j                  j#                         D ]A  }
|
j                  j%                         D ]"  \  }}|	j'                  |
j(                  ||       $ C |	j+                  t-         j                               |	j/                          |	 _         j                  j#                         D ]J  }
|
j                  j%                         D ]+  \  }}| j                  |   j2                  |
j(                  <   - L t5         fd j0                  j7                         D               _        t;         j                        D ]  }| j8                  v s n t=        d	       j0                  j?                         }tA               } j                  jC                         D ]/  }
 j0                  jE                  |
      s|jG                  |
       1 ||z
   _        y )
Nzop_%s>   SETUP_FINALLYz2'try' block not supported until python3.7 or laterz$Use of unsupported opcode (%s) found)locr  r   c              3   @   K   | ]  }|j                   |   f  y wr   )r8  )r   r   r   s     r   r   z*ControlFlowAnalysis.run.<locals>.<genexpr>;  s&      <(:1 !"4;;q>2(:s   zNo live block that exits!?)$
_iter_instopnamer.  is_jumpr   r7  func_idr   linenor   zipr:  r8  r   r   rA   rM   r  r=   rT   r   r[   minr_   rI  r   r  r   r9  r   AssertionErrorr   rC   keysr   rJ   )r   instfnamefnlmsgcurnxtblkrI  r  outrF  lastblkr   inloopblockss   `               r   runz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%%coo*+""3' >
 	ANN1 ##%A--335	Tqxxd3 6 & 	c$++./
 ##%A--335	T<@C //9 6 &
  <(,

(8(8(:< <  .G$//) / !!=>> ::&&( u!!#Azz""1%  # $ !</r   c                 6    || j                   j                  |<   y)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   targetrF  s      r   jumpzControlFlowAnalysis.jumpQ  s    
 15%%f-r   c              #      K   | j                   D ]h  }| j                  |      r"| j                  |       | j                  |       | j                  j
                  j                  |j                         | j y wr   )r7  _use_new_block_guard_with_as_start_new_blockr<  r   r   r   r   rW  s     r   rN  zControlFlowAnalysis._iter_instX  s_     MMD""4(##D)%%d+NN&&t{{3J "s   A9A;c                     |j                   | j                  j                  v rd}n!|j                  t        v rd}n| j
                  }d| _        |S )NTF)r   r7  labelsrO  NEW_BLOCKERSr;  )r   rW  ress      r   rg  z"ControlFlowAnalysis._use_new_block`  sF    ;;$--...C[[L(C''C %
r   c                     t        |j                        | _        | j                  | j                  |j                  <   | j                  j                  |j                         y r   )r   r   r<  r8  r:  r   rj  s     r   ri  z$ControlFlowAnalysis._start_new_blockk  s>     -#'>>DKK T[[)r   c                     |j                   dk(  r6| j                  |j                     j                   }|dk7  rd}t        |      yy)zChecks if the next instruction after a SETUP_WITH is something other
        than a POP_TOP, if it is something else it'll be some sort of store
        which is not supported (this corresponds to `with CTXMGR as VAR(S)`).r   POP_TOPzGThe 'with (context manager) as (variable):' construct is not supported.N)rO  r7  nextr   )r   current_instnext_opr[  s       r   rh  z"ControlFlowAnalysis._guard_with_asp  sR     ,.mmL$5$56==G)#$ 's++	 $ /r   c                     |j                         }| j                  j                  |       | j                  j                  |j                  |f       | j                  |j                         d| _        y r6  )get_jump_targetr=  r   r   r   re  rr  r;  r   rW  ends      r   op_SETUP_LOOPz!ControlFlowAnalysis.op_SETUP_LOOP|  Y    ""$$DKK-. 			$)) $r   c                     |j                         }| j                  j                  |       | j                  j                  |j                  |f       | j                  |j                         d| _        y r6  )rv  r=  r   r>  r   re  rr  r;  rw  s      r   op_SETUP_WITHz!ControlFlowAnalysis.op_SETUP_WITH  rz  r   c                 8    | j                   j                          y r   )r=  r   rj  s     r   op_POP_BLOCKz ControlFlowAnalysis.op_POP_BLOCK  s    r   c                     | j                  |j                                | j                  |j                         d| _        y r6  re  rv  rr  r;  rj  s     r   op_FOR_ITERzControlFlowAnalysis.op_FOR_ITER  /    		$&&()		$)) $r   c                     | j                  |j                                | j                  |j                         d| _        y r6  r  rj  s     r   _op_ABSOLUTE_JUMP_IFz(ControlFlowAnalysis._op_ABSOLUTE_JUMP_IF  r  r   c                     | j                  |j                                | j                  |j                  d       d| _        y )Nr  )rF  Tr  rj  s     r   _op_ABSOLUTE_JUMP_OR_POPz,ControlFlowAnalysis._op_ABSOLUTE_JUMP_OR_POP  s3    		$&&()		$))!	$ $r   c                 P    | j                  |j                                d| _        y r6  re  rv  r;  rj  s     r   op_JUMP_ABSOLUTEz$ControlFlowAnalysis.op_JUMP_ABSOLUTE      		$&&() $r   c                 P    | j                  |j                                d| _        y r6  r  rj  s     r   op_JUMP_FORWARDz#ControlFlowAnalysis.op_JUMP_FORWARD  r  r   c                 4    d| j                   _        d| _        y r6  r<  r   r;  rj  s     r   op_RETURN_VALUEz#ControlFlowAnalysis.op_RETURN_VALUE      %)" $r   ))      c                 4    d| j                   _        d| _        y r6  r  rj  s     r   op_RETURN_CONSTz#ControlFlowAnalysis.op_RETURN_CONST  s    )-DNN&$(D!r   ))r  	   )r  
   )r     c                 4    d| j                   _        d| _        y r6  r  rj  s     r   op_RAISE_VARARGSz$ControlFlowAnalysis.op_RAISE_VARARGS  r  r   c                 N    | j                  | j                  d          d| _        y )Nr  T)re  r=  r;  rj  s     r   op_BREAK_LOOPz!ControlFlowAnalysis.op_BREAK_LOOP  s!    		$""2&' $r   r   )r   )(r   r    r!   r.   r   rA  rC  rG  r   rb  re  rN  rg  ri  rh  ry  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   r4  r4    s     !%+#<0|5	*

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