U
    9%eR                     @   s  d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZmZ d dlmZ d dlmZ d dlmZmZ d dlmZmZmZmZ d dlmZmZmZmZ d d	lmZ e Z G d
d de!Z"e"dd d Z#e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'G dd de%e'Z(G dd de(Z)G dd de)Z*G dd de(Z+G dd de)Z,G dd  d e)Z-G d!d" d"e)Z.G d#d$ d$e)Z/G d%d& d&e)Z0G d'd( d(e)Z1G d)d* d*e)Z2G d+d, d,e*Z3G d-d. d.e*Z4G d/d0 d0e*Z5G d1d2 d2e)Z6G d3d4 d4e)Z7G d5d6 d6e)Z8G d7d8 d8e*Z9G d9d: d:e*Z:G d;d< d<e*Z;G d=d> d>e)Z<G d?d@ d@e)Z=G dAdB dBe(Z>G dCdD dDe)Z?G dEdF dFe)Z@G dGdH dHe%e'ZAG dIdJ dJe%e'ZBG dKdL dLe%e'ZCG dMdN dNe%e'ZDG dOdP dPe%e'ZEG dQdR dRe%ZFG dSdT dTe%ZGG dUdV dVe$ZHG dWdX dXe$ZIG dYdZ dZe!ZJG d[d\ d\e%ZKeK ZLdS )]    )defaultdictN)FunctionTypeBuiltinFunctionType)total_ordering)StringIO)errorsconfig)BINOPS_TO_OPERATORSINPLACE_BINOPS_TO_OPERATORSUNARY_BUITINS_TO_OPERATORSOPERATORS_TO_BUILTINS)NotDefinedErrorRedefinedErrorVerificationErrorConstantInferenceError)constsc                   @   s   e Zd ZdZedZd ddZdd Zd	d
 Z	e
dd Zdd Zdd Zdd Zdd Zdd Zdd Zd!ddZd"ddZdd ZdS )#LoczSource location

    zdef\s+(\w+)\(.*NFc                 C   s"   || _ || _|| _d| _|| _dS )z Arguments:
        filename - name of the file
        line - line in file
        col - column
        maybe_decorator - Set to True if location is likely a jit decorator
        N)filenamelinecollinesmaybe_decorator)selfr   r   r   r    r   L/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/numba/core/ir.py__init__   s
    zLoc.__init__c                 C   sH   t | t |k	rdS | j|jkr$dS | j|jkr4dS | j|jkrDdS dS NFT)typer   r   r   r   otherr   r   r   __eq__,   s        z
Loc.__eq__c                 C   s   |  | S Nr    r   r   r   r   __ne__4   s    z
Loc.__ne__c                 C   s   | |j |jddS )NT)r   )r   Zfirstlineno)clsfunc_idr   r   r   from_function_id7   s    zLoc.from_function_idc                 C   s   d| j | j| jf S )Nz!Loc(filename=%s, line=%s, col=%s))r   r   r   r   r   r   r   __repr__;   s     zLoc.__repr__c                 C   s2   | j d k	rd| j| j| j f S d| j| jf S d S )Nz
%s (%s:%s)z%s (%s))r   r   r   r'   r   r   r   __str__?   s    
zLoc.__str__c                 C   sB   d }|   }t|d | jd  D ]}| dr"|} q>q"|S )N   def )	get_linesreversedr   strip
startswith)r   fn_namer   xr   r   r   _find_definitionE   s    zLoc._find_definitionc                 C   s,   |   }|r$| j|  d S d S d S Nr   )r2   _defmatchermatchr.   groups)r   Zdefnr   r   r   _raw_function_nameR   s    zLoc._raw_function_namec                 C   s    | j d krt|  | _ | j S r!   )r   	linecachegetlines	_get_pathr'   r   r   r   r,   Z   s    
zLoc.get_linesc                 C   s>   d }zt j| j}W n" tk
r8   t j| j}Y nX |S r!   )ospathrelpathr   
ValueErrorabspath)r   r<   r   r   r   r:   a   s    zLoc._get_path   c                 C   s  |   }| j}| jr~dg| }|r~|r~d|| kr~td|}|d }||| }d}t|D ]\}	}
d|
kr\|	} qvq\|| }g }|r||dkr|dd }|td|| | }d}|D ]}
d|
krd}q|s,d }t|d |d	  D ]}
d|
kr|
} qq|r,|| ||
}|d
d|  d  |r|||d d  |t	|d  ||d }|d
| t
d  |s|sd}n|dkrd}tdd }||  |td|f }|S )N r+   r   
   c                 S   s(   d}t tjt| D ]}|d7 }q|S )Nr   r*   )	itertools	takewhilestrisspace)stringspacesr1   r   r   r   count_spaces   s    
z#Loc.strformat.<locals>.count_spacesFTr*       z<source elided>
^z#<source missing, REPL/exec in use?>z<source line number missing>z
File "%s", line %d:z
%s)r,   r   r   max	enumerater-   appendextend
_termcolor	highlightZindicater   r:   codejoin)r   Z	nlines_upr   Zuse_lineZtmplinesZmin_lineZmax_lineselectedindexidxr1   retrI   Z	def_foundr0   rH   errtmpr   r   r   	strformato   sZ    




zLoc.strformatc                 C   s   t | | j||S )z9
        Return a new Loc with this line number.
        )r   r   )r   r   r   r   r   r   with_lineno   s    zLoc.with_linenoc                 C   s   t j| j}d|| jf S )z(
        Returns a short string
        z%s:%s)r;   r<   basenamer   r   )r   Zshortfilenamer   r   r   short   s    z	Loc.short)NF)r@   )N)__name__
__module____qualname____doc__recompiler4   r   r    r#   classmethodr&   r(   r)   r2   r7   r,   r:   r\   r]   r_   r   r   r   r   r      s    



S
r   zunknown locationc                   @   s*   e Zd Ze Zdd Zdd Zdd ZdS )SlotEqualityCheckMixinc                 C   s>   t | t |kr:| jD ]}t| |t||kr dS qdS dS r   )r   	__slots__getattr)r   r   namer   r   r   r       s    
zSlotEqualityCheckMixin.__eq__c                 C   s   t | t |kS r!   rE   r   r   r   r   __le__   s    zSlotEqualityCheckMixin.__le__c                 C   s   t | S r!   idr'   r   r   r   __hash__   s    zSlotEqualityCheckMixin.__hash__N)r`   ra   rb   tuplerh   r    rl   ro   r   r   r   r   rg      s   	rg   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	EqualityCheckMixinz# Mixin for basic equality checking c                 C   s<   t | t |kr8dd }|| j}||j}||kr8dS dS )Nc                 S   s&   d}t | }|D ]}||d  q|S )N)locscope)dictpop)adictbaddr1   r   r   r   fixup   s
    z(EqualityCheckMixin.__eq__.<locals>.fixupTF)r   __dict__)r   r   ry   Zd1Zd2r   r   r   r       s    

zEqualityCheckMixin.__eq__c                 C   s   t | t |k S r!   rk   r   r   r   r   rl      s    zEqualityCheckMixin.__le__c                 C   s   t | S r!   rm   r'   r   r   r   ro      s    zEqualityCheckMixin.__hash__N)r`   ra   rb   rc   r    rl   ro   r   r   r   r   rq      s   rq   c                   @   s\   e 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dS )VarMapc                 C   s
   i | _ d S r!   _conr'   r   r   r   r     s    zVarMap.__init__c                 C   s"   || j krt|n
|| j |< d S r!   )r}   r   )r   rj   varr   r   r   define  s    

zVarMap.definec                 C   s.   z| j | W S  tk
r(   t|Y nX d S r!   )r}   KeyErrorr   r   rj   r   r   r   get  s    z
VarMap.getc                 C   s
   || j kS r!   r|   r   r   r   r   __contains__  s    zVarMap.__contains__c                 C   s
   t | jS r!   )lenr}   r'   r   r   r   __len__  s    zVarMap.__len__c                 C   s   t | jS r!   )pprintpformatr}   r'   r   r   r   r(     s    zVarMap.__repr__c                 C   s
   t | jS r!   )hashrj   r'   r   r   r   ro     s    zVarMap.__hash__c                 C   s
   | j  S r!   )r}   iterkeysr'   r   r   r   __iter__  s    zVarMap.__iter__c                 C   s(   t | t |kr$| j |j kS dS )NF)r   r}   keysr   r   r   r   r    "  s    zVarMap.__eq__c                 C   s   |  | S r!   r"   r   r   r   r   r#   (  s    zVarMap.__ne__N)r`   ra   rb   r   r   r   r   r   r(   ro   r   r    r#   r   r   r   r   r{     s   r{   c                   @   s   e Zd ZdZdS )AbstractRHSz{Abstract base class for anything that can be the RHS of an assignment.
    This class **does not** define any methods.
    N)r`   ra   rb   rc   r   r   r   r   r   ,  s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )Instz-
    Base class for all IR instructions.
    c                 C   s   t dS )zO
        List the variables used (read or written) by the instruction.
        N)NotImplementedErrorr'   r   r   r   	list_vars7  s    zInst.list_varsc                 C   s   t |tr|gS t |tr"| S t |ttfrRg }|D ]}|| | q8|S t |trg }|	 D ]}|| | qh|S g S dS )zQ
        A recursive helper used to implement list_vars() in subclasses.
        N)

isinstanceVarr   r   listrp   rQ   _rec_list_varsrt   values)r   vallstvr   r   r   r   =  s    


zInst._rec_list_varsN)r`   ra   rb   rc   r   r   r   r   r   r   r   2  s   r   c                   @   s    e Zd ZdZdZdZdd ZdS )Stmtzc
    Base class for IR statements (instructions which can appear on their
    own in a Block).
    Fc                 C   s   |  | jS r!   )r   rz   r'   r   r   r   r   ^  s    zStmt.list_varsN)r`   ra   rb   rc   is_terminatoris_exitr   r   r   r   r   r   S  s   r   c                   @   s   e Zd ZdZdZdd ZdS )
Terminatorz
    IR statements that are terminators: the last statement in a block.
    A terminator must either:
    - exit the function
    - jump to a block

    All subclass of Terminator must override `.get_targets()` to return a list
    of jump targets.
    Tc                 C   s   t t| d S r!   )r   r   r'   r   r   r   get_targetsn  s    zTerminator.get_targetsN)r`   ra   rb   rc   r   r   r   r   r   r   r   b  s   	r   c                   @   sJ  e Zd Z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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e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ed+d, Zed-d. Zed/d0 Zed1d2 Zed3d4 Zd5d6 Zd7d8 Zd9d: Z dS )<Exprz]
    An IR expression (an instruction which can only be part of a larger
    statement).
    c                 K   s2   t |tstt |tst|| _|| _|| _d S r!   )r   rE   AssertionErrorr   oprr   _kws)r   r   rr   kwsr   r   r   r   x  s
    zExpr.__init__c                 C   s    | drt| |S | j| S )N_)r/   r   __getattr__r   r   r   r   r   r     s    
zExpr.__getattr__c                 C   s"   |dkr|| j |< n
|| j|< d S )N)r   rr   r   )rz   r   )r   rj   valuer   r   r   __setattr__  s    zExpr.__setattr__c              	   C   sR   t |tstt |tstt |ts*tt |ts8td}| |||||ttdS )Nbinop)r   rr   fnlhsrhs
static_lhs
static_rhsr   r   r   r   r   	UNDEFINED)r$   r   r   r   rr   r   r   r   r   r     s     z
Expr.binopc              
   C   sb   t |tstt |tstt |ts*tt |ts8tt |tsFtd}| ||||||ttdS )Ninplace_binop)r   rr   r   immutable_fnr   r   r   r   r   )r$   r   r   r   r   rr   r   r   r   r   r     s    
  zExpr.inplace_binopc                 C   sB   t |tttfstt |ts"td}t||}| ||||dS )Nunary)r   rr   r   r   )r   rE   r   r   r   r   r   r   )r$   r   r   rr   r   r   r   r   r     s
    z
Expr.unaryNc           	   
   C   s8   t |tstt |tstd}| ||||||||dS )Ncall)r   rr   funcargsr   varargvarkwargtargetr   r   r   r   )	r$   r   r   r   rr   r   r   r   r   r   r   r   r     s      z	Expr.callc                 C   s    t |tstd}| |||dS )Nbuild_tupler   rr   itemsr   r   r   r$   r   rr   r   r   r   r   r     s    zExpr.build_tuplec                 C   s    t |tstd}| |||dS )N
build_listr   r   r   r   r   r   r     s    zExpr.build_listc                 C   s    t |tstd}| |||dS )N	build_setr   r   r   r   r   r   r     s    zExpr.build_setc                 C   s&   t |tstd}| ||||||dS )N	build_map)r   rr   r   sizeliteral_valuevalue_indexesr   )r$   r   r   r   r   rr   r   r   r   r   r     s    
 zExpr.build_mapc                 C   s    t |tstd}| |||dS )N
pair_firstr   rr   r   )r   r   r   r$   r   rr   r   r   r   r   r     s    zExpr.pair_firstc                 C   s.   t |tstt |tstd}| |||dS )Npair_secondr   r   r   r   r   r   r     s    zExpr.pair_secondc                 C   s.   t |tstt |tstd}| |||dS )Ngetiterr   r   r   r   r   r   r     s    zExpr.getiterc                 C   s.   t |tstt |tstd}| |||dS )Niternextr   r   r   r   r   r   r     s    zExpr.iternextc                 C   s>   t |tstt |tstt |ts*td}| ||||dS )Nexhaust_iter)r   rr   r   count)r   r   r   intr   )r$   r   r   rr   r   r   r   r   r     s
    zExpr.exhaust_iterc                 C   s>   t |tstt |tstt |ts*td}| ||||dS )Nri   )r   rr   r   attr)r   r   r   rE   r   )r$   r   r   rr   r   r   r   r   ri     s
    zExpr.getattrc                 C   sF   t |tstt |tstt |ts*td}tj}| |||||dS )Ngetitem)r   rr   r   rW   r   r   r   r   r   operatorr   )r$   r   rW   rr   r   r   r   r   r   r     s    zExpr.getitemc                 C   s2   t |tstt |tstd}| |||||dS )Ntyped_getitem)r   rr   r   dtyperW   r   )r$   r   r   rW   rr   r   r   r   r   r     s    
zExpr.typed_getitemc                 C   sP   t |tst|d ks$t |ts$tt |ts2td}tj}| ||||||dS )Nstatic_getitem)r   rr   r   rW   	index_varr   r   )r$   r   rW   r   rr   r   r   r   r   r   r     s    
 zExpr.static_getitemc                 C   s.   t |tstt |tstd}| |||dS )zE
        A node for implicit casting at the return statement
        cast)r   r   rr   r   r   r   r   r   r     s    z	Expr.castc                 C   s   t |tst| dg g |dS )zPhi node
        phi)r   Zincoming_valuesZincoming_blocksrr   r   )r$   rr   r   r   r   r     s    zExpr.phic                 C   s&   t |tstd}| ||||||dS )z6
        A node for making a function object.
        make_function)r   rj   rT   closuredefaultsrr   r   )r$   rj   rT   r   r   rr   r   r   r   r   r      s    zExpr.make_functionc                 C   s   t |tstd}| ||dS )z
        A node for null value.

        This node is not handled by type inference. It is only added by
        post-typing passes.
        null)r   rr   r   )r$   rr   r   r   r   r   r   )  s    z	Expr.nullc                 C   s*   t |tstt |tst| |||dS )a8  
        A node for a dummy value.

        This node is a place holder for carrying information through to a point
        where it is rewritten into something valid. This node is not handled
        by type inference or lowering. It's presence outside of the interpreter
        renders IR as illegal.
        )r   inforr   )r   r   r   rE   )r$   r   r   rr   r   r   r   dummy5  s    
z
Expr.dummyc           	      C   s(  | j dkrddd | jD }tjdkr4| j nt| j }ddd |D }| jd k	rld| jf nd}dt	d |||g}d	| j
|f S | j d
kr| j| j }}| jtjkr|| }}t| j| j}d|||f S tjdkr| j nt| j }dd |D }d| j d|f S d S )Nr   , c                 s   s   | ]}t |V  qd S r!   rk   ).0ar   r   r   	<genexpr>E  s     z Expr.__repr__.<locals>.<genexpr>r   c                 s   s   | ]\}}d ||f V  qdS z%s=%sNr   r   kr   r   r   r   r   G  s     z*%srA   zcall %s(%s)r   z%s %s %sc                 s   s   | ]\}}d ||f V  qdS r   r   r   r   r   r   r   S  s     z%s(%s))r   rU   r   r   ZDIFF_IRr   r   sortedr   filterr   r   r   r   r   containsr   r   )	r   r   Z
pres_orderr   r   Zarglistr   r   r   r   r   r   r(   C  s     
"

"zExpr.__repr__c                 C   s   |  | jS r!   )r   r   r'   r   r   r   r   V  s    zExpr.list_varsc                 C   s   t d|  | jdd S Nz%srr   r   rr   r'   r   r   r   infer_constantY  s    zExpr.infer_constant)NNN)!r`   ra   rb   rc   r   r   r   rf   r   r   r   r   r   r   r   r   r   r   r   r   r   ri   r   r   r   r   r   r   r   r   r(   r   r   r   r   r   r   r   r  sf   
	














	
	



r   c                   @   s    e Zd ZdZdd Zdd ZdS )SetItemz
    target[index] = value
    c                 C   sT   t |tstt |tstt |ts*tt |ts8t|| _|| _|| _|| _d S r!   )r   r   r   r   r   rW   r   rr   )r   r   rW   r   rr   r   r   r   r   b  s    zSetItem.__init__c                 C   s   d| j | j| jf S Nz%s[%s] = %sr   rW   r   r'   r   r   r   r(   l  s    zSetItem.__repr__Nr`   ra   rb   rc   r   r(   r   r   r   r   r   ]  s   
r   c                   @   s    e Zd ZdZdd Zdd ZdS )StaticSetItemz(
    target[constant index] = value
    c                 C   sh   t |tstt |trtt |ts*tt |ts8tt |tsFt|| _|| _|| _|| _|| _d S r!   )	r   r   r   r   r   rW   r   r   rr   )r   r   rW   r   r   rr   r   r   r   r   u  s    zStaticSetItem.__init__c                 C   s   d| j | j| jf S )Nz%s[%r] = %sr   r'   r   r   r   r(     s    zStaticSetItem.__repr__Nr   r   r   r   r   r   p  s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )DelItemz
    del target[index]
    c                 C   s@   t |tstt |tstt |ts*t|| _|| _|| _d S r!   )r   r   r   r   r   rW   rr   )r   r   rW   rr   r   r   r   r     s    zDelItem.__init__c                 C   s   d| j | jf S )Nz
del %s[%s])r   rW   r'   r   r   r   r(     s    zDelItem.__repr__Nr   r   r   r   r   r     s   r   c                   @   s   e Zd Zdd Zdd ZdS )SetAttrc                 C   sT   t |tstt |tstt |ts*tt |ts8t|| _|| _|| _|| _d S r!   )	r   r   r   rE   r   r   r   r   rr   )r   r   r   r   rr   r   r   r   r     s    zSetAttr.__init__c                 C   s   d| j | j| jf S )Nz(%s).%s = %s)r   r   r   r'   r   r   r   r(     s    zSetAttr.__repr__Nr`   ra   rb   r   r(   r   r   r   r   r     s   
r   c                   @   s   e Zd Zdd Zdd ZdS )DelAttrc                 C   s@   t |tstt |tstt |ts*t|| _|| _|| _d S r!   )r   r   r   rE   r   r   r   rr   )r   r   r   rr   r   r   r   r     s    zDelAttr.__init__c                 C   s   d| j | jf S )Nzdel (%s).%s)r   r   r'   r   r   r   r(     s    zDelAttr.__repr__Nr   r   r   r   r   r     s   r   c                   @   s   e Zd Zdd Zdd ZdS )StoreMapc                 C   sT   t |tstt |tstt |ts*tt |ts8t|| _|| _|| _|| _d S r!   )r   r   r   r   dctkeyr   rr   )r   r   r   r   rr   r   r   r   r     s    zStoreMap.__init__c                 C   s   d| j | j| jf S r   )r   r   r   r'   r   r   r   r(     s    zStoreMap.__repr__Nr   r   r   r   r   r     s   
r   c                   @   s   e Zd Zdd Zdd ZdS )Delc                 C   s,   t |tstt |tst|| _|| _d S r!   )r   rE   r   r   r   rr   r   r   rr   r   r   r   r     s    zDel.__init__c                 C   s
   d| j  S )Nzdel %sr   r'   r   r   r   r)     s    zDel.__str__N)r`   ra   rb   r   r)   r   r   r   r   r     s   r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	RaiseTc                 C   s4   |d kst |tstt |ts$t|| _|| _d S r!   r   r   r   r   	exceptionrr   r   r   rr   r   r   r   r     s    zRaise.__init__c                 C   s
   d| j  S )Nzraise %sr   r'   r   r   r   r)     s    zRaise.__str__c                 C   s   g S r!   r   r'   r   r   r   r     s    zRaise.get_targetsN)r`   ra   rb   r   r   r)   r   r   r   r   r   r     s   r   c                   @   s,   e Zd ZdZdZdd Zdd Zdd Zd	S )
StaticRaisez
    Raise an exception class and arguments known at compile-time.
    Note that if *exc_class* is None, a bare "raise" statement is implied
    (i.e. re-raise the current exception).
    Tc                 C   sP   |d kst |tstt |ts$t|d ks:t |ts:t|| _|| _|| _d S r!   r   r   r   r   rp   	exc_classexc_argsrr   r   r   r  rr   r   r   r   r     s    zStaticRaise.__init__c                 C   sD   | j d krdS | jd kr$d| j f S d| j dtt| jf S d S )Nz<static> raisez<static> raise %sz<static> raise %s(%s)r   r   r  rU   mapreprr'   r   r   r   r)     s    

zStaticRaise.__str__c                 C   s   g S r!   r   r'   r   r   r   r     s    zStaticRaise.get_targetsNr`   ra   rb   rc   r   r   r)   r   r   r   r   r   r     s
   	r   c                   @   s,   e Zd ZdZdZdd Zdd Zdd Zd	S )
DynamicRaisez
    Raise an exception class and some argument *values* unknown at compile-time.
    Note that if *exc_class* is None, a bare "raise" statement is implied
    (i.e. re-raise the current exception).
    Tc                 C   sP   |d kst |tstt |ts$t|d ks:t |ts:t|| _|| _|| _d S r!   r   r  r   r   r   r     s    zDynamicRaise.__init__c                 C   sD   | j d krdS | jd kr$d| j f S d| j dtt| jf S d S )Nz<dynamic> raisez<dynamic> raise %sz<dynamic> raise %s(%s)r   r  r'   r   r   r   r)   	  s    

zDynamicRaise.__str__c                 C   s   g S r!   r   r'   r   r   r   r     s    zDynamicRaise.get_targetsNr  r   r   r   r   r    s
   	r  c                   @   s    e Zd ZdZdd Zdd ZdS )TryRaisezZA raise statement inside a try-block
    Similar to ``Raise`` but does not terminate.
    c                 C   s4   |d kst |tstt |ts$t|| _|| _d S r!   r   r   r   r   r   r     s    zTryRaise.__init__c                 C   s
   d| j  S )Nztry_raise %sr   r'   r   r   r   r)      s    zTryRaise.__str__Nr`   ra   rb   rc   r   r)   r   r   r   r   r    s   r  c                   @   s    e Zd ZdZdd Zdd ZdS )StaticTryRaisezaA raise statement inside a try-block.
    Similar to ``StaticRaise`` but does not terminate.
    c                 C   sP   |d kst |tstt |ts$t|d ks:t |ts:t|| _|| _|| _d S r!   r   r  r   r   r   r   (  s    zStaticTryRaise.__init__c                 C   sN   | j d krdS | jd kr$d| j  S dtt| j}d| j  d| dS d S )NZstatic_try_raisezstatic_try_raise r   ()r  r   r   r   r   r   r)   0  s    

zStaticTryRaise.__str__Nr	  r   r   r   r   r
  $  s   r
  c                   @   s    e Zd ZdZdd Zdd ZdS )DynamicTryRaisezbA raise statement inside a try-block.
    Similar to ``DynamicRaise`` but does not terminate.
    c                 C   sP   |d kst |tstt |ts$t|d ks:t |ts:t|| _|| _|| _d S r!   r   r  r   r   r   r   >  s    zDynamicTryRaise.__init__c                 C   sN   | j d krdS | jd kr$d| j  S dtt| j}d| j  d| dS d S )NZdynamic_try_raisezdynamic_try_raise r   r  r  r  r  r   r   r   r)   F  s    

zDynamicTryRaise.__str__Nr	  r   r   r   r   r  :  s   r  c                   @   s,   e Zd ZdZdZdd Zdd Zdd Zd	S )
Returnz
    Return to caller.
    Tc                 C   s4   t |tstt|t |ts$t|| _|| _d S r!   )r   r   r   r   r   r   rr   r   r   r   r   r   V  s    zReturn.__init__c                 C   s
   d| j  S )Nz	return %sr   r'   r   r   r   r)   \  s    zReturn.__str__c                 C   s   g S r!   r   r'   r   r   r   r   _  s    zReturn.get_targetsNr  r   r   r   r   r  P  s
   r  c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	Jumpz
    Unconditional branch.
    c                 C   s   t |tst|| _|| _d S r!   )r   r   r   r   rr   )r   r   rr   r   r   r   r   h  s    zJump.__init__c                 C   s
   d| j  S )Nzjump %sr   r'   r   r   r   r)   m  s    zJump.__str__c                 C   s   | j gS r!   r  r'   r   r   r   r   p  s    zJump.get_targetsNr`   ra   rb   rc   r   r)   r   r   r   r   r   r  c  s   r  c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	Branchz
    Conditional branch.
    c                 C   s8   t |tstt |tst|| _|| _|| _|| _d S r!   )r   r   r   r   condtruebrfalsebrrr   )r   r  r  r  rr   r   r   r   r   y  s    zBranch.__init__c                 C   s   d| j | j| jf S )Nzbranch %s, %s, %s)r  r  r  r'   r   r   r   r)     s    zBranch.__str__c                 C   s   | j | jgS r!   )r  r  r'   r   r   r   r     s    zBranch.get_targetsNr  r   r   r   r   r  t  s   r  c                   @   s    e Zd ZdZdd Zdd ZdS )Assignz
    Assign to a variable.
    c                 C   s@   t |tstt |tstt |ts*t|| _|| _|| _d S r!   )r   r   r   r   r   r   r   rr   )r   r   r   rr   r   r   r   r     s    zAssign.__init__c                 C   s   d| j | jf S )Nz%s = %s)r   r   r'   r   r   r   r)     s    zAssign.__str__Nr	  r   r   r   r   r    s   r  c                   @   s    e Zd ZdZdd Zdd ZdS )Printz
    Print some values.
    c                 C   sZ   t dd |D st|d ks,t|ts,tt|ts:tt|| _|| _i | _|| _	d S )Nc                 s   s   | ]}t |tV  qd S r!   )r   r   r   r1   r   r   r   r     s     z!Print.__init__.<locals>.<genexpr>)
allr   r   r   r   rp   r   r   r   rr   )r   r   r   rr   r   r   r   r     s    
zPrint.__init__c                 C   s   dd dd | jD  S )Nz	print(%s)r   c                 s   s   | ]}t |V  qd S r!   rk   r   r   r   r   r   r     s     z Print.__str__.<locals>.<genexpr>)rU   r   r'   r   r   r   r)     s    zPrint.__str__Nr	  r   r   r   r   r    s   
r  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )Yieldc                 C   s2   t |tstt |tst|| _|| _|| _d S r!   )r   r   r   r   r   rr   rW   )r   r   rr   rW   r   r   r   r     s
    zYield.__init__c                 C   s   d| j f S )Nzyield %sr   r'   r   r   r   r)     s    zYield.__str__c                 C   s   | j gS r!   r   r'   r   r   r   r     s    zYield.list_varsN)r`   ra   rb   r   r)   r   r   r   r   r   r    s   r  c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )		EnterWithzEnter a "with" context
    c                 C   s8   t |tstt |tst|| _|| _|| _|| _dS )z
        Parameters
        ----------
        contextmanager : IR value
        begin, end : int
            The beginning and the ending offset of the with-body.
        loc : ir.Loc instance
            Source location
        N)r   r   r   r   contextmanagerbeginendrr   )r   r  r  r   rr   r   r   r   r     s    
zEnterWith.__init__c                 C   s   d | jS )Nzenter_with {})formatr  r'   r   r   r   r)     s    zEnterWith.__str__c                 C   s   | j gS r!   )r  r'   r   r   r   r     s    zEnterWith.list_varsN)r`   ra   rb   rc   r   r)   r   r   r   r   r   r    s   r  c                   @   s    e Zd ZdZdd Zdd ZdS )PopBlockz(Marker statement for a pop block op codec                 C   s   t |tst|| _d S r!   )r   r   r   rr   )r   rr   r   r   r   r     s    zPopBlock.__init__c                 C   s   dS )NZ	pop_blockr   r'   r   r   r   r)     s    zPopBlock.__str__Nr	  r   r   r   r   r"    s   r"  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )Argc                 C   s@   t |tstt |tstt |ts*t|| _|| _|| _d S r!   )r   rE   r   r   r   rj   rW   rr   )r   rj   rW   rr   r   r   r   r     s    zArg.__init__c                 C   s   d| j | jf S )Nzarg(%d, name=%s))rW   rj   r'   r   r   r   r(     s    zArg.__repr__c                 C   s   t d|  | jdd S r   r   r'   r   r   r   r     s    zArg.infer_constantN)r`   ra   rb   r   r(   r   r   r   r   r   r#    s   r#  c                   @   s.   e Zd ZdddZdd Zdd Zdd	 Zd
S )ConstTc                 C   s$   t |tst|| _|| _|| _d S r!   )r   r   r   r   rr   use_literal_type)r   r   rr   r%  r   r   r   r     s    zConst.__init__c                 C   s   dt | jj| jf S )Nzconst(%s, %s))r   r   r`   r'   r   r   r   r(     s    zConst.__repr__c                 C   s   | j S r!   r   r'   r   r   r   r     s    zConst.infer_constantc                 C   s   t | j| j| jdS )N)r   rr   r%  )r$  r   rr   r%  r   memor   r   r   __deepcopy__  s
     zConst.__deepcopy__N)T)r`   ra   rb   r   r(   r   r(  r   r   r   r   r$    s   
r$  c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
Globalc                 C   s$   t |tst|| _|| _|| _d S r!   )r   r   r   rj   r   rr   )r   rj   r   rr   r   r   r   r     s    zGlobal.__init__c                 C   s   d| j | jf S )Nzglobal(%s: %s)rj   r   r'   r   r   r   r)     s    zGlobal.__str__c                 C   s   | j S r!   r   r'   r   r   r   r     s    zGlobal.infer_constantc                 C   s   t | j| jt| jS r!   )r)  rj   r   copydeepcopyrr   r&  r   r   r   r(    s    zGlobal.__deepcopy__N)r`   ra   rb   r   r)   r   r(  r   r   r   r   r)    s   r)  c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )FreeVarzm
    A freevar, as loaded by LOAD_DECREF.
    (i.e. a variable defined in an enclosing non-global scope)
    c                 C   sF   t |tstt |tstt |ts*t|| _|| _|| _|| _d S r!   )	r   r   r   rE   r   rW   rj   r   rr   )r   rW   rj   r   rr   r   r   r   r     s    zFreeVar.__init__c                 C   s   d| j | jf S )Nzfreevar(%s: %s)r*  r'   r   r   r   r)   )  s    zFreeVar.__str__c                 C   s   | j S r!   r   r'   r   r   r   r   ,  s    zFreeVar.infer_constantc                 C   s   t | j| j| j| jdS )N)rW   rj   r   rr   )r-  rW   rj   r   rr   r&  r   r   r   r(  /  s    zFreeVar.__deepcopy__N)r`   ra   rb   rc   r   r)   r   r(  r   r   r   r   r-    s
   r-  c                   @   sX   e Zd Z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dS )r   zt
    Attributes
    -----------
    - scope: Scope

    - name: str

    - loc: Loc
        Definition location
    c                 C   sH   |d kst |tstt |ts$tt |ts2t|| _|| _|| _d S r!   )r   Scoper   rE   r   rs   rj   rr   )r   rs   rj   rr   r   r   r   r   B  s    zVar.__init__c                 C   s   d| j | j f S )NzVar(%s, %s))rj   rr   r_   r'   r   r   r   r(   K  s    zVar.__repr__c                 C   s   | j S r!   )rj   r'   r   r   r   r)   N  s    zVar.__str__c                 C   s   | j dS )N$)rj   r/   r'   r   r   r   is_tempQ  s    zVar.is_tempc                 C   s.   | j j D ]\}}| j|kr|  S q| jS )zIThe unversioned name of this variable, i.e. SSA renaming removed
        )rs   var_redefinitionsr   rj   )r   r   Z	redef_setr   r   r   unversioned_nameU  s    

zVar.unversioned_namec                 C   s   | j | jS )zKnown versioned names for this variable, i.e. known variable names in
        the scope that have been formed from applying SSA to this variable
        )rs   get_versions_ofr2  r'   r   r   r   versioned_names^  s    zVar.versioned_namesc                 C   s   | j | jhB S )zDAll known versioned and unversioned names for this variable
        )r4  r2  r'   r   r   r   	all_namese  s    zVar.all_namesN)r`   ra   rb   rc   r   r(   r)   propertyr0  r2  r4  r5  r   r   r   r   r   6  s   	


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dZ	dd Z
dd Zedd Zdd ZdS )r.  z
    Attributes
    -----------
    - parent: Scope
        Parent scope

    - localvars: VarMap
        Scope-local variable map

    - loc: Loc
        Start of scope location

    c                 C   sP   |d kst |tstt |ts$t|| _t | _|| _tt	| _
tt| _d S r!   )r   r.  r   r   parentr{   	localvarsrr   r   r   	redefinedsetr1  )r   r7  rr   r   r   r   r   {  s    
zScope.__init__c                 C   s"   t | ||d}| j|j| |S )z#
        Define a variable
        rs   rj   rr   )r   r8  r   rj   )r   rj   rr   r   r   r   r   r     s    zScope.definec                 C   s&   || j krd|| j | f }| |S )zC
        Refer to a variable.  Returns the latest version.
        %s.%d)r9  	get_exactr   r   r   r   r     s    
z	Scope.getc                 C   s@   z| j |W S  tk
r:   | jr4| j| Y S  Y nX dS )zr
        Refer to a variable.  The returned variable has the exact
        name (exact variable version).
        N)r8  r   r   
has_parentr7  r   r   r   r   r=    s    zScope.get_exactc                 C   sB   || j krd|| j | f }|| jkr2| ||S | j|S d S )Nr<  )r9  r8  r   r   )r   rj   rr   r   r   r   get_or_define  s
    

zScope.get_or_defineTc                 C   s   || j kr| ||S |s&| j |S | j| }|d | j|< d||d f }z| ||}W n tk
rv   Y q&Y nX | j| | |S dS )z9
        Redefine if the name is already defined
        r*   r<  N)r8  r   r   r9  r   r1  add)r   rj   rr   renamectZnewnameresr   r   r   redefine  s    


zScope.redefinec                    s"   t   fdd| S )z9
        Gets all known versions of a given name
        c                    s2    j | d }|r.|D ]}| | qd S r!   )r1  r   r@  )ZthenameZredefsr   r   verswalkr   r   rG    s
    
z#Scope.get_versions_of.<locals>.walk)r:  r   r   rE  r   r3    s    zScope.get_versions_ofc                 C   s0   t | j}t| d| |d}| j|j| |S )Nz$%dr;  )r   r8  r   r   rj   )r   rr   nr   r   r   r   	make_temp  s    
zScope.make_tempc                 C   s
   | j d k	S r!   )r7  r'   r   r   r   r>    s    zScope.has_parentc                 C   s   d| j t| j| jf S )Nz%Scope(has_parent=%r, num_vars=%d, %s))r>  r   r8  rr   r'   r   r   r   r(     s    zScope.__repr__N)T)r`   ra   rb   rc   r   r   r   r=  r?  rD  r3  rI  r6  r>  r(   r   r   r   r   r.  l  s   		

r.  c                   @   s   e Zd ZdZdd Zdd Zd#ddZd$d	d
Zdd Zdd Z	dd Z
dd Zdd Zd%ddZedd Zedd Zdd Zdd Zdd  Zd!d" ZdS )&BlockzA code block

    c                 C   s2   t |tstt |tst|| _g | _|| _d S r!   )r   r.  r   r   rs   bodyrr   )r   rs   rr   r   r   r   r     s
    zBlock.__init__c                 C   s"   t | j| j}| jd d  |_|S r!   )rJ  rs   rr   rK  r   blockr   r   r   r+    s    z
Block.copyNc                 c   sB   | j D ]6}t|tr|j}t|tr|dks6|j|kr|V  qdS )zE
        Iterate over exprs of the given *op* in this block.
        N)rK  r   r  r   r   r   )r   r   instexprr   r   r   
find_exprs  s    


zBlock.find_exprsc                 c   s    | j D ]}t||r|V  qdS )zF
        Iterate over insts of the given class in this block.
        N)rK  r   )r   r$   rN  r   r   r   
find_insts  s    

zBlock.find_instsc                 C   s*   | j tdD ]}|jj|kr|  S qdS )zr
        Returns the assignment inst associated with variable "name", None if
        it cannot be found.
        )r$   N)rQ  r  r   rj   )r   rj   r1   r   r   r   find_variable_assignment  s    
zBlock.find_variable_assignmentc                 C   s    t |tst| jd| d S r3   )r   r   r   rK  insertr   rN  r   r   r   prepend  s    zBlock.prependc                 C   s   t |tst| j| d S r!   )r   r   r   rK  rP   rT  r   r   r   rP     s    zBlock.appendc                 C   s"   t |tst| j| j|= d S r!   )r   r   r   rK  rW   rT  r   r   r   remove  s    zBlock.removec                 C   s   | j d d = d S r!   rK  r'   r   r   r   clear  s    zBlock.clearc                 C   sZ   |pt j}| jD ]D}t|dr*|| qtdd | D }td||f |d qd S )Ndumpc                 s   s   | ]}t |V  qd S r!   rk   r  r   r   r   r   #  s     zBlock.dump.<locals>.<genexpr>z    %-40s %sfile)sysstdoutrK  hasattrrY  r   r   print)r   r[  rN  Z	inst_varsr   r   r   rY    s    


z
Block.dumpc                 C   s
   | j d S NrL   rW  r'   r   r   r   
terminator&  s    zBlock.terminatorc                 C   s   | j o| j d jS r`  )rK  r   r'   r   r   r   is_terminated*  s    zBlock.is_terminatedc                 C   s4   | j std| jd d D ]}|jrtdqd S )NzMissing block terminatorrL   z&Terminator before the last instruction)rb  r   rK  r   rT  r   r   r   verify.  s
    zBlock.verifyc                 C   s"   | j |}| j |d | dS )z.
        Insert *stmt* after *other*.
        r*   N)rK  rW   rS  )r   stmtr   rW   r   r   r   insert_after7  s    zBlock.insert_afterc                 C   s*   t |tst| jst| jd| d S r`  )r   r   r   rb  rK  rS  )r   rd  r   r   r   insert_before_terminator>  s    
zBlock.insert_before_terminatorc                 C   s   d| j f S )Nz<ir.Block at %s>r   r'   r   r   r   r(   C  s    zBlock.__repr__)N)N)N)r`   ra   rb   rc   r   r+  rP  rQ  rR  rU  rP   rV  rX  rY  r6  ra  rb  rc  re  rf  r(   r   r   r   r   rJ    s&   






	rJ  c                   @   s$   e Zd ZdZdZdd Zdd ZdS )LoopzDescribes a loop-block
    entryexitc                 C   s   || _ || _d S r!   rh  r   ri  rj  r   r   r   r   L  s    zLoop.__init__c                 C   s   | j | jf}d| S )NzLoop(entry=%s, exit=%s)rh  r  r   r   r   r(   P  s    zLoop.__repr__Nr`   ra   rb   rc   rh   r   r(   r   r   r   r   rg  G  s   rg  c                   @   s$   e Zd ZdZdZdd Zdd ZdS )WithzDescribes a with-block
    rh  c                 C   s   || _ || _d S r!   rh  rk  r   r   r   r   Z  s    zWith.__init__c                 C   s   | j | jf}d| S )NzWith(entry=%s, exit=%s)rh  r  r   r   r   r(   ^  s    zWith.__repr__Nrl  r   r   r   r   rm  U  s   rm  c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd!ddZdd Zdd Z	dd Z
d"ddZd#ddZd$ddZdd Zd%ddZd&dd Zd	S )'
FunctionIRc                 C   s6   || _ || _|| _|| _|| _|| _|| _|   d S r!   )blocksis_generatorr%   rr   	arg_count	arg_names_definitions_reset_analysis_variables)r   ro  rp  r%   rr   Zdefinitionsrq  rr  r   r   r   r   e  s    zFunctionIR.__init__c                 C   s    t | t |kr| j|jkS dS )aD   Checks that the IR contained within is equal to the IR in other.
        Equality is defined by being equal in fundamental structure (blocks,
        labels, IR node type and the order in which they are defined) and the
        IR nodes being equal. IR node equality essentially comes down to
        ensuring a node's `.__dict__` or `.__slots__` is equal, with the
        exception of ignoring 'loc' and 'scope' entries. The upshot is that the
        comparison is essentially location and scope invariant, but otherwise
        behaves as unsurprisingly as possible.
        F)r   ro  r   r   r   r   equal_irr  s    
zFunctionIR.equal_irc              
      s  g }| j  D ]\}}|j |d}|dk	r||kr|d| dd dd |jD }dd |jD }||krt|t|kr|d|  t|jt|jkr|d	 nt|jt|jk r|d
 g  tt	|j|jD ]"\}}	|	\}
}|
|kr | q fdd}t
t|jt|j}t }d|fd|fg}|D ]p\}}|d |j|d |  }	||j|}d||f }||dd |dd t	||	D  qHW 5 Q R X q|g kr|d d|S )zw
        Compute a human readable difference in the IR, returns a formatted
        string ready for printing.
        NzBlock %s differsP   -c                 S   s   g | ]}t |tr|qS r   r   r   r  r   r   r   
<listcomp>  s     
 z'FunctionIR.diff_str.<locals>.<listcomp>c                 S   s   g | ]}t |tr|qS r   rx  r  r   r   r   ry    s     
 z<Block %s contains the same dels but their order is differentz#This block contains more statementsz$Other block contains more statementsc                    sX   d}t |d }g }t | }t|D ].}| kr6|}n||krD|}n|}|| q$|S )Nz-> rJ   )r   rangerP   )ZablocklZpointersppadZnstmtiitemr[   r   r   get_pad  s    z$FunctionIR.diff_str.<locals>.get_padr   r   r   rZ  z%s: block %sc                 S   s   g | ]\}}d  ||qS )z{0}{1}r!  )r   r   br   r   r   ry    s     zIR is considered equivalent.
)ro  r   r   rP   centerrK  r   r   rO   zipminr   truncaterY  getvalue
splitlinesrQ   rU   )r   r   msglabelrM  Z	other_blkZ	block_delZoth_delrX   ZstmtsZb_sZo_sr  Zmin_stmt_lenbufitrj   _blockr}  titler   r  r   diff_str  sR    




zFunctionIR.diff_strc                 C   s"   t | | _d | _d | _i | _d S r!   )r   ZConstantInference_constsgenerator_infoZvariable_lifetimeblock_entry_varsr'   r   r   r   rt    s    z$FunctionIR._reset_analysis_variablesNFc                 C   sb   |t | }t| }||_|j|_|r.d|_|dk	r<||_|dk	rJ||_|  |j	 |_|S )z
        Derive a new function IR from this one, using the given blocks,
        and possibly modifying the argument count and generator flag.

        Post-processing will have to be run again on the new IR.
        FN)
r  r+  ro  rr   rp  rq  rr  rt  r%   derive)r   ro  rq  rr  Zforce_non_generatorZ
firstblocknew_irr   r   r   r    s    
zFunctionIR.derivec                 C   s^   t  | }i }i }| j D ]0\}}|  }|||< || jkr| j| ||< q||_||_|S r!   )r+  ro  r   r  )r   r  ro  r  r  rM  Z	new_blockr   r   r   r+    s    

zFunctionIR.copyc                 C   s
   | j | S )zf
        Return a set of variable names possibly alive at the beginning of
        the block.
        )r  rL  r   r   r   get_block_entry_vars  s    zFunctionIR.get_block_entry_varsc                 C   s   t |tr|j}| j|S )zF
        Try to infer the constant value of a given variable.
        )r   r   rj   r  r   r   r   r   r   r     s    
zFunctionIR.infer_constantc                 C   s   |}t |tr|}|j}n t |tr.|}|}n|r6|S |S | j| }t|dkr^td|f t|dkrxtd|f |d }qdS )z
        Get the definition site for the given variable name or instance.
        A Expr instance is returned by default, but if lhs_only is set
        to True, the left-hand-side variable is returned instead.
        r   zno definition for %rr*   zmore than one definition for %rN)r   r   rj   rE   rs  r   r   )r   r   Zlhs_onlyr   rj   Zdefsr   r   r   get_definition  s$    


zFunctionIR.get_definitionc                    s   |dkr j  }n.t|tr, j | g}n fddt|D }t|tsPt|D ],}|tD ]}|j	|krb|j
    S qbqTtd| dS )z
        Finds the assignee for a given RHS value. If in_blocks is given the
        search will be limited to the specified blocks.
        Nc                    s   g | ]} j | qS r   )ro  )r   blkr'   r   r   ry  "  s     z+FunctionIR.get_assignee.<locals>.<listcomp>z!Could not find an assignee for %s)ro  r   r   r   r   r   r   rQ  r  r   r   r>   )r   	rhs_valueZ	in_blocksro  r  Zassignr   r'   r   get_assignee  s    

zFunctionIR.get_assigneec                 C   s   |d k}|pt  }t| j D ]&\}}td|f |d |j|d q |r| }tjrzdd l	}W n  t
k
r   d}t|Y qX ddl	m} ddlm}	 ddlm}
 ddlm} t|||	 ||
 d	 nt| d S )
Nz	label %s:rZ  r   z0Please install pygments to see highlighted dumps)rS   )NumbaIRLexer)by_colorscheme)Terminal256Formatter)style)r   r   ro  r   r_  rY  r  r   ZHIGHLIGHT_DUMPSpygmentsImportErrorr>   rS   Znumba.misc.dump_styler  r  Zpygments.formattersr  )r   r[  ZnofileoffsetrM  textr  r  rS   lexerr  r  r   r   r   rY  .  s*    
zFunctionIR.dumpc              
   C   s2   t  "}| j|d | W  5 Q R  S Q R X d S )NrZ  )r   rY  r  )r   sbr   r   r   dump_to_stringH  s    zFunctionIR.dump_to_stringc                 C   sb   |pt j}| j}tdt|j|d t|j D ]*\}}td|t|jt|j	f |d q2d S )Nzgenerator state variables:rZ  z>yield point #%d: live variables = %s, weak live variables = %s)
r\  r]  r  r_  r   Z
state_varsZyield_pointsr   Z	live_varsZweak_live_vars)r   r[  girW   Zypr   r   r   dump_generator_infoM  s    
zFunctionIR.dump_generator_infonumba_irTc              
   C   s  zddl }W n tk
r(   tdY nX |jd|| jjd}| j D ]\}}t }|	| |
 }W 5 Q R X |rddd | D }d	|| }|jt||d
d qLd|}|jt||dd qL| j D ],\}	}|j D ]}
|t|	t|
 qq|S )zRender the CFG of the IR 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`z{}{}.dot)r   rA   c                 S   s   g | ]}d  |qS )z  {}\lr  r  r   r   r   ry  t  s     z)FunctionIR.render_dot.<locals>.<listcomp>z
block {}\lrect)r  shapez{}\lcircle)graphvizr  ZDigraphr!  r%   Zunique_namero  r   r   rY  r  rU   r  noderE   ra  r   edge)r   Zfilename_prefixZ
include_irgvgr   r  r  r  srcdstr   r   r   
render_dotV  s8    



zFunctionIR.render_dot)NNF)F)N)N)N)r  T)r`   ra   rb   r   ru  r  rt  r  r+  r  r   r  r  rY  r  r  r  r   r   r   r   rn  c  s    A
  




	rn  c                   @   s    e Zd ZdZdd Zdd ZdS )UndefinedTypeNc                 C   s&   | j }|d k	r|S t| }|| _ |S r!   )
_singletonobject__new__)r$   objr   r   r   r    s    
zUndefinedType.__new__c                 C   s   dS )N	Undefinedr   r'   r   r   r   r(     s    zUndefinedType.__repr__)r`   ra   rb   r  r  r(   r   r   r   r   r    s   	r  )Mcollectionsr   r+  rC   r;   r8   r   rd   r\  r   typesr   r   	functoolsr   ior   Z
numba.corer   r   Znumba.core.utilsr	   r
   r   r   Znumba.core.errorsr   r   r   r   r   Z	termcolorrR   r  r   Zunknown_locrg   rq   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.  rJ  rg  rm  rn  r  r   r   r   r   r   <module>   s    9)! l
6sh  "