
    xKgY                     >   d Z ddlmZ ddlmZ ddlZddlZddlmZ ddl	m
Z
mZmZ ddlmZmZ  edd	d
g      Z edd      Z ej$                  d      Z ej$                  d      ZeZd Z ed      Z ed      Z ed      Z ed      ZdZ ee      Z G d de      Z G d de      Z G d de      Z dZ!dZ"dZ#dZ$dZ% ejL                  eeeeeg      Z' ejP                  e'      Z) G d de      Z* G d d e      Z+ G d! d"e+      Z, G d# d$e+      Z-e,e-d%Z.d& Z/y)'z3
Calling conventions for Numba-compiled functions.
    )
namedtuple)IterableN)ir)typescgutilserrors)PYOBJECTGENERIC_POINTER	TryStatusin_tryexcinfoStatus)codeis_okis_noneis_erroris_stop_iterationis_python_excis_user_exc
excinfoptr    @   c                 6    t        j                  t        |       S N)r   Constant	errcode_t)r   s    W/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/core/callconv.py
_const_intr   +   s    ;;y$''       c                   T    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zy)BaseCallConvc                     || _         y r   )context)selfr'   s     r   __init__zBaseCallConv.__init__<   s	    r   c                    |t         j                  k(  r| j                  |       y ||k(  r| j                  j	                  |||      }t        j                  ||j                        }|j                  |      5  | j                  j                  ||j                  |j                        }| j                  ||       d d d        | j                  |       y t        |t         j                        sr||j                  k7  r)| j                  j                  ||||j                        }| j                  j                  ||j                  |      }| j                  ||       y t!        dj#                  ||            # 1 sw Y   xY w)N)value)fromtytotyzreturning {0} for {1})r   nonereturn_native_noner'   make_helperr   as_bool_bitvalidif_thenget_return_valuetypedatareturn_value
isinstanceOptionalcastNotImplementedErrorformat)r(   builderrettyvaltyr+   optvalvalidbitretvals           r   return_optional_valuez"BaseCallConv.return_optional_value?   sC   EJJ##G,e^\\--guE-JF**7FLLAH*66w

7={{D!!'62 +
 ##G,E5>>2

"))'5/4zz * ;\\227EJJNFgv. &&=&D&DUEJ'L M M! +*s   :AE??Fc                 0    | j                  |t               y r   )_return_errcode_rawRETCODE_NONEr(   r=   s     r   r/   zBaseCallConv.return_native_none\   s      ,7r   c                 0    | j                  |t               y r   )rE   RETCODE_EXCrG   s     r   
return_exczBaseCallConv.return_exc_   s      +6r   c                 0    | j                  |t               y r   )rE   RETCODE_STOPITrG   s     r   return_stop_iterationz"BaseCallConv.return_stop_iterationb   s      .9r   c                 p    | j                   j                  |   j                         }|j                         S )zQ
        Get the actual type of the return argument for Numba type *ty*.
        )r'   data_model_managerget_return_type
as_pointer)r(   tyrestypes      r   rP   zBaseCallConv.get_return_typee   s0     ,,11"5EEG!!##r   c                 6    | j                  |      }||_        |S )zS
        Initialize and return a call helper object for the given builder.
        )_make_call_helper_BaseCallConv__call_helper)r(   r=   chs      r   init_call_helperzBaseCallConv.init_call_helperl   s!     ##G, "	r   c                     |j                   S r   )rV   rG   s     r   _get_call_helperzBaseCallConv._get_call_helpert   s    $$$r   c                 8    |j                  |j                        S r   )unserializer   )r(   r=   pyapistatuss       r   unpack_exceptionzBaseCallConv.unpack_exceptionw   s      !2!233r   c                 .   |j                   j                         }|j                  |j                        5  |j	                          | j                  |||      }t        j                  |t        j                  ||            5  |j                  |       ddd       |j                  |       ddd       |j                  |j                        5  |j                  d       |j                  |       ddd       |j                  |j                        5  |j                  |       ddd       |j                  dd       |j                  |       |j                  |       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   bxY w)zT
        Given a non-ok *status*, raise the corresponding Python exception.
        NPyExc_StopIterationPyExc_SystemErrorz*unknown error when calling native function)functionappend_basic_blockr3   r   	err_clearr_   r   	if_likelyis_not_nullraise_objectbranchr   err_set_noner   err_set_stringposition_at_end)r(   r=   r]   r^   bbendexcs         r   raise_errorzBaseCallConv.raise_errorz   sD      335__V//0 OO''?C""7#*#6#6w#DF""3'F NN5! 1 __V55645NN5! 7 __V112NN5! 3 	0I	Ku&#F F 10 76 32s<   AE3E'E3#E?F'E0	,E33E<?FFc                 j    | j                  |      }| j                  |      }|j                  ||      S )z
        Get the decoded (unpacked) Python arguments with *argtypes*
        from LLVM function *func*.  A tuple of LLVM values is returned.
        )get_arguments_get_arg_packerfrom_arguments)r(   r=   argtypesfuncraw_argsarginfos         r   decode_argumentszBaseCallConv.decode_arguments   s7    
 %%d+&&x0%%gx88r   c                 8    | j                   j                  |      S )zF
        Get an argument packer for the given argument types.
        )r'   get_arg_packer)r(   rt   s     r   rr   zBaseCallConv._get_arg_packer   s     ||**844r   N)__name__
__module____qualname__r)   rC   r/   rJ   rM   rP   rX   rZ   r_   ro   rx   rr    r   r   r%   r%   :   s?    M:87:$%4'<95r   r%   c                   T    e Zd ZdZd Zd Z	 	 ddZd Zd Zd Z	d	 Z
dd
Zd Zd Zy)MinimalCallConva  
    A minimal calling convention, suitable for e.g. GPU targets.
    The implemented function signature is:

        retcode_t (<Python return type>*, ... <Python arguments>)

    The return code will be one of the RETCODE_* constants or a
    function-specific user exception id (>= RETCODE_USEREXC).

    Caller is responsible for allocating a slot for the return value
    (passed as a pointer in the first argument).
    c                     t               S r   )_MinimalCallHelperrG   s     r   rU   z!MinimalCallConv._make_call_helper   s    !##r   c                 >   |j                   j                  d   }|j                  |j                  j                  k(  s9J t	        |j                        t	        |j                  j                        f       |j                  ||       | j                  |t               y Nr   )rc   argsr5   pointeestrstorerE   
RETCODE_OKr(   r=   rB   retptrs       r   r7   zMinimalCallConv.return_value   sy    !!&&q){{fkk111 	9s6;;#6#678	91ff%  *5r   Nc                 r   |t        |t              st        d|      |t        |t              st        d|      |4|j                         }||}||j                  |j                  f}d |v rd }nd }| j                  |      }|j                  |||      }	| j                  |t        |	             y )N+exc should be None or exception class, got &exc_args should be None or tuple, got )
issubclassBaseException	TypeErrorr8   tuple_raw_function_namefilenamelinerZ   _add_exceptionrE   r   )
r(   r=   rn   exc_argsloc	func_namefnamelocinfocall_helperexc_ids
             r   return_user_exczMinimalCallConv.return_user_exc   s    ?:c=#A"% & &
8U(C'* + + ?**,E}!cllCHH5GwG++G4++C7C  *V*<=r   c                 <    | j                  ||j                         y r   )rE   r   )r(   r=   r^   s      r   return_status_propagatez'MinimalCallConv.return_status_propagate   s      &++6r   c                 \    t        |t              rt        |      }|j                  |       y r   )r8   intr   retr(   r=   r   s      r   rE   z#MinimalCallConv._return_errcode_raw   s"    dC d#DDr   c           
      X   |j                  d|t              }|j                  d|t              }|j                  ||      }|j	                  |      }|j                  d|t
              }|j                  d|t              }|j                  d|t              }	t        ||||||	|d      }
|
S )z?
        Given a return *code*, get a Status instance.
        ==>=Nr   r   r   r   r   r   r   r   )	icmp_signedr   rF   or_not_rI   rL   RETCODE_USEREXCr   )r(   r=   r   normr.   okerrrn   r   r   r^   s              r   _get_return_statusz"MinimalCallConv._get_return_status   s     ""4z:""4|<[[t$ll2!!$k:#//dNK))$oFT !$&) $$/*;#') r   c                     | j                  |      }t        |j                        }| j                  |      }t	        j
                  t        |g|z         }|S zQ
        Get the implemented Function type for *restype* and *argtypes*.
        )rr   listargument_typesrP   r   FunctionTyper   r(   rS   rt   rw   resptrfntys         r   get_function_typez!MinimalCallConv.get_function_type   sP     &&x0../%%g.y6(X*=>r   c                     |rJ | j                  |      }|j                  | j                  |      |D cg c]  }d|z   	 c}       d|j                  d   _        yc c}w )zA
        Set names and attributes of function arguments.
        arg.z.retr   N)rr   assign_namesrq   r   name)r(   fnr   fe_argtypesnoaliasrw   as          r   decorate_functionz!MinimalCallConv.decorate_function  sa     {&&{3T//3267$Qfqj$7	9 
 8s   A
c                      |j                   dd S )@
        Get the Python-level arguments of LLVM *func*.
        r#   Nr   r(   ru   s     r   rq   zMinimalCallConv.get_arguments       yy}r   c                    |j                   d   j                  j                  }t        j                  ||      }|j                  t        j                  |      |       | j                  |      }|j                  ||      }|gt        |      z   }	|j                  ||	      }
| j                  ||
      }|j                  |      }| j                  j                  |||      }||fS )z3
        Call the Numba-compiled *callee*.
        r   )r   r5   r   r   alloca_oncer   get_null_valuerr   as_argumentsr   callr   loadr'   get_returned_value)r(   r=   calleerestyargtysr   r>   	retvaltmprw   realargsr   r^   rB   outs                 r   call_functionzMinimalCallConv.call_function  s     A##++''7	g,,U3Y?&&v.##GT2;d+||FH-(($7i(ll--gufEs{r   NNNF)r{   r|   r}   __doc__rU   r7   r   r   rE   r   r   r   rq   r   r~   r   r   r   r      sC    $6 @D"&>47
,!r   r   c                   "    e Zd ZdZd Zd Zd Zy)r   z
    A call helper object for the "minimal" calling convention.
    User exceptions are represented as integer codes and stored in
    a mapping for retrieval from the caller.
    c                     i | _         y r   )
exceptions)r(   s    r   r)   z_MinimalCallHelper.__init__,  s	    r   c                 b    t        | j                        t        z   }|||f| j                  |<   |S )aV  
        Add a new user exception to this helper. Returns an integer that can be
        used to refer to the added exception in future.

        Parameters
        ----------
        exc :
            exception type
        exc_args : None or tuple
            exception args
        locinfo : tuple
            location information
        )lenr   FIRST_USEREXC)r(   rn   r   r   r   s        r   r   z!_MinimalCallHelper._add_exception/  s1     T__%5"%x"8r   c                 j    	 | j                   |   S # t        $ r d|z  }t        }|f}d}|||fcY S w xY w)z
        Get information about a user exception. Returns a tuple of
        (exception type, exception args, location information).

        Parameters
        ----------
        id : integer
            The ID of the exception to look up
        z#unknown error %d in native functionN)r   KeyErrorSystemError)r(   r   msgrn   r   r   s         r   get_exceptionz _MinimalCallHelper.get_exceptionA  sM    	*??6** 	*7&@CCvHG'))	*s    22N)r{   r|   r}   r   r)   r   r   r~   r   r   r   r   %  s    $*r   r            c                       e Zd ZdZ ej
                  d      Zd Zd Zd Z		 	 ddZ
	 	 ddZd	 Zd
 Zd Zd Z	 	 ddZ	 ddZd Zd Zd Zd Zd Zd Zd Zd ZddZd Zd Zd Z	 ddZy) CPUCallConva  
    The calling convention for CPU targets.
    The implemented function signature is:

        retcode_t (<Python return type>*, excinfo **, ... <Python arguments>)

    The return code will be one of the RETCODE_* constants.
    If RETCODE_USEREXC, the exception info pointer will be filled with
    a pointer to a constant struct describing the raised exception.

    Caller is responsible for allocating slots for the return value
    and the exception info pointer (passed as first and second arguments,
    respectively).
    r#   c                      y r   r~   rG   s     r   rU   zCPUCallConv._make_call_helperr  s    r   c                 B   | j                  |j                        }|j                  |j                  j                  k(  s9J t	        |j                        t	        |j                  j                        f       |j                  ||       | j                  |t               y r   )_get_return_argumentrc   r5   r   r   r   rE   r   r   s       r   r7   zCPUCallConv.return_valueu  sy    **7+;+;<{{fkk111 	9s6;;#6#678	91ff%  *5r   c                     |4|j                         }||}||j                  |j                  f}d |v rd }nd }|||f}|S r   )r   r   r   )r(   rn   r   r   r   r   r   s          r   build_excinfo_structz CPUCallConv.build_excinfo_struct|  sU    ?**,E}!cllCHH5GwGHg&
r   Nc                    |t        |t              st        d|      |t        |t              st        d|      |
t	               }| j
                  j                  |      }| j                  ||||      }|j                  |      }| j                  |j                        }|j                  ||      }	|j                  j                   t        j                  d      d      g      }
|	j!                  d|
       y )Nr   r   r#   numba_exception_output)r   r   r   r8   r   r'   get_python_apir   serialize_object_get_excinfo_argumentrc   r   moduleadd_metadatar   IntTypeset_metadata)r(   r=   rn   r   r   r   r]   	struct_gvexcptrr   mds              r   set_static_user_exczCPUCallConv.set_static_user_exc  s    ?:c=#A"% & &
8U(C'* + +
 wHJ ++G4''XsIF**3/	++G,<,<=i0^^((-"**Q-*:);<3R8r   c                     t        |dd      }| j                  |||||       | j                  |       |r|j                  |d          y | j	                  |t
               y )N_in_try_blockF)r   r   r   target)getattrr   check_try_statusri   rE   r   )r(   r=   rn   r   r   r   try_infos          r   r   zCPUCallConv.return_user_exc  sd    7OU;  #%(I 	! 	?g& NN8H-. $$Wo>r   c                    |j                   }|j                  |j                  |      t              }|j                  |j                  |      t              }|j                  ||j                  ||j                              }|j                  |j                  |      t              }|j                  |j                  |      t              }	t        j                  t        t        g      }
|j                  |	|
j                               }|j!                  ||g      }t#        j$                  ||      }t#        j&                  ||      5  d}|j)                  d|       |j*                  j,                  }
t/        |
j0                  t        j2                        s/|j5                  t#        j6                  |
j0                               n|j9                          d d d        |j;                  ||      }| j<                  j>                  r@| j<                  j@                  jC                  ||j                  ||jD                               |S # 1 sw Y   sxY w)Nz<Error creating Python tuple from runtime exception argumentsPyExc_RuntimeError)#r   extract_valuer   PICKLE_BUF_IDXPICKLE_BUFSZ_IDXbytes_from_string_and_sizesext
py_ssize_tHASH_BUF_IDXUNWRAP_FUNC_IDXr   r   r	   r
   bitcastrQ   r   r   is_nullif_unlikelyrk   rc   function_typer8   return_typeVoidTyper   r   ret_voidbuild_dynamic_excinfo_structr'   
enable_nrtnrtfreevoidptr)r(   r=   r]   r^   excinfo_ptr	picklebufpicklebuf_szstatic_exc_bytesdyn_argsfunc_ptrr   r   py_tuplefailedr   r   s                   r   unpack_dynamic_exceptionz$CPUCallConv.unpack_dynamic_exception  s   '' ))LL%~7	,,LL%'79 ;;w||L%2B2BCE ((LL%|5((LL%8 x/):;__Xt'89<<XJ/
 (3  &1C  !5s;##11Dd..<G2243C3CDE  " 2 445ExP <<"" LL!!emmDF+ 21s   BIIc                 D   |j                   }|j                  |j                  |      t              }|j	                  d|t        d            }|j                  |      5 \  }}|5  | j                  |||      }	|j                  }
d d d        |5  |j                  |      }|j                  }d d d        d d d        |j                  j                        }|j                  	
       |j                  |       |S # 1 sw Y   zxY w# 1 sw Y   ^xY w# 1 sw Y   bxY w)N>r   )r   r  r   ALLOC_FLAG_IDXr   int32_tif_elser  blockr\   phir5   add_incoming)r(   r=   r]   r^   r  
alloc_flaggtthen	otherwisedyn_excbb_then
static_excbb_elser&  s                 r   r_   zCPUCallConv.unpack_exception  s     ''**7<<+D+9;
  j'!*=__R $5T977O!--  "..{;
!-- 	 ! kk*//*'*W-
  	 ! s<   D% C>
DD
-D>D	D
D	DDc                    t        j                  t        |      j                               j	                         }d| }||j
                  v r|j
                  j                  |      S t        j                  t        t        g      }t        j                  |||      }|j                  j                  d       |j                  j                  d       |j                  d      }t        j                  |      }	| j                  j!                  |	      }
|j#                         }|	j%                  |j&                  d   |      }|D cg c]  }||	 }}g }| j                  j)                  |	d      }t+        |      D ]  \  }}|	j-                  |	j/                  |      |      }|
j1                  |||      }|t3        j4                  |j6                        k(  rd	| d
}t9        j:                  |      |j=                  |        | j                  j>                  jA                  |	| jC                  |	jD                               |
jG                  |      }|	jI                  |       |S c c}w )N__excinfo_unwrap_argsnounwindnoinline r   T)return_pyobject)env_managerzCannot convert native z to a Python object.)%hashlibsha1r   encode	hexdigestglobalsgetr   r   r
   Function
attributesaddrd   	IRBuilderr'   r   rQ   r  r   get_env_manager	enumerater  r   from_native_valuer   r   r5   r   TypingErrorappendr  r  r   rc   
tuple_packr   )r(   r   st_typenb_types_hashr   r   r   bb_entryr=   r]   st_type_ptrst_ptrtypobjsr6  ivalobjr   tups                        r    emit_unwrap_dynamic_exception_fnz,CPUCallConv.emit_unwrap_dynamic_exception_fn   s     S\0023==?&ug.6>>!>>%%d++0AB[[t, 	*%
*%((,,,x(++G4 ((*[9#+?8CsC8? ll227CG 3 I)FAs''V(<a@C))#s)LC g,,SXX66.se3GH((--KK * 	g"778H8HI	K t$C	5 @s   	I/I/c                    |j                  | j                  j                  |            }|j                  | j                  j                  j                  ||      |j                               }|D cg c]  }t        |t        j                        s|! }}t        d      }t        |      D ]2  \  }	}|j                  ||j                  ||t        |	      g             4 |S c c}w )zP
        Create an anonymous struct containing the given LLVM *values*.
        r   )r  r'   get_abi_sizeofr  r  allocaterQ   r8   r   Valuer#  rB  r   gep)
r(   r=   r]   struct_typer   st_sizerL  argzeroidxs
             r   emit_wrap_args_instsz CPUCallConv.emit_wrap_args_insts`  s     ""4<<#>#>{#KLLL%%gw7""$&
 $,I8Cz#rxx/HC8Iqz!(+HCMM#w{{6D'#,3GHI ,  Js   3C&C&c                    t        |t              st        d|      |t        |t              st        d|      | j
                  j                  |      }| j                  ||||      }| j                  |j                        }|j                  |j                  |            }	t        j                  |D 
cg c](  }
t        |
t        j                        r|
j                  * c}
      }| j!                  ||||      }| j#                  |j$                  ||      }|j'                  | j
                  j)                  t*                    }|j-                  | j
                  j.                  j1                  ||      t2              }t5        d      }|j7                  |	t8              |j7                  |	t:              |j-                  |t<              |j-                  |t<              t5        t?        |            f}tA        |      D ]2  \  }}
|jC                  |
|jE                  ||t5        |      g             4 |jC                  ||       yc c}
w )zf
        Compute the required bits to emit an exception with dynamic (runtime)
        values
        z&exc should be an exception class, got Nr   r   )#r   r   r   r8   r   r'   r   r   r   rc   r   r   r   LiteralStructTyperW  r5   r^  rS  r   r  rU  	excinfo_tr  r  rV  excinfo_ptr_tr#  r  r  r  r
   r   rB  r   rX  )r(   r=   rn   r   rH  r   r   r]   
excinfo_ppr   r[  rY  rL  	unwrap_fnexc_size	excinfo_pr\  
exc_fieldsr]  s                      r   set_dynamic_user_excz CPUCallConv.set_dynamic_user_excs  s	    #}-"% & &
8U(C'* + +b ++G4''XsIF//0@0@A
LL!7!7!<=	 ** ,G,6sBHH,E -0HH ,G H**7E;+3599NNK3	 ##DLL$?$?	$JKOOLL%%gx8	
 qz++I~F++I7GHoofo>ooiAc+./	1

 "*-HCMM#w{{9tWS\6JKL .i,-,Gs   <-Ic                 ^    | j                  ||||||       | j                  |t               y)zF
        Same as ::return_user_exc but for dynamic exceptions
        )r   r   N)rh  rE   r   )r(   r=   rn   r   rH  r   r   s          r   return_dynamic_user_excz#CPUCallConv.return_dynamic_user_exc  s5    
 	!!'3(&)Y 	" 	@  /:r   c                     	 |j                   S # t        $ r3 t        j                  |t        j                  dd      }||_         |cY S w xY w)N	try_stateT)r   zfill)_CPUCallConv__eh_try_stateAttributeErrorr   r   intp_t)r(   r=   ptrs      r   _get_try_statezCPUCallConv._get_try_state  sN    	))) 	%%kC &)G"J	s    9A
	A
c                     | j                  |      }|j                  |      }|j                  d||j                  d            }| j	                  |j
                        }|j                  |      }t        ||      S )Nr!  r   )r   r   )rr  r   icmp_unsignedr5   r   rc   r   )r(   r=   try_state_ptr	try_depthr   r   r   s          r   r   zCPUCallConv.check_try_status  sn    ++G4LL/	&&sIy~~a7HI//0@0@A
,,z*88r   c                     | j                  |      }|j                  |      }|j                  ||j                  d            }|j	                  ||       y Nr#   )rr  r   r?  r5   r   )r(   r=   ru  oldnews        r   set_try_statuszCPUCallConv.set_try_status  sF    ++G4ll=)kk#sxx{+c=)r   c                 Z   | j                  |      }|j                  |      }|j                  ||j                  d            }|j	                  ||       | j                  |j                        }t        j                  |j                  j                        }|j	                  ||       y rx  )
rr  r   subr5   r   r   rc   r   r   r   )r(   r=   ru  ry  rz  r   nulls          r   unset_try_statuszCPUCallConv.unset_try_status  s    ++G4ll=)kk#sxx{+c=) //0@0@A
%%joo&=&=>dJ'r   c                 J   | j                  |      }| j                  |j                        }|j                  |j                  |       |j                  |j                  |j                              5  | j                  ||j                         d d d        y # 1 sw Y   y xY wr   )
r   r   rc   r   r   r3   r   r   rE   r   )r(   r=   r^   	trystatusr   s        r   r   z#CPUCallConv.return_status_propagate  sw    ))'2	++G,<,<=f''0__W\\)*:*:;<$$Wfkk: =<<s   3BB"c                 &    |j                  |       y r   )r   r   s      r   rE   zCPUCallConv._return_errcode_raw  s    Dr   c           
         |j                  d|t              }|j                  d|t              }|j                  d|t              }|j                  d|t              }|j                  ||      }|j                  |      }	|j                  d|t              }
|j                  |
|t        j                  t        t        j                              }t        |||	|||
||      }|S )zP
        Given a return *code* and *excinfoptr*, get a Status instance.
        r   r   r   )r   r   rF   rI   rL   r   r   r   selectr   r   rb  	Undefinedr   )r(   r=   r   r   r   r.   rn   r   r   r   r   r^   s               r   r   zCPUCallConv._get_return_status	  s     ""4z:""4|<!!$k:#//dNK[[t$ll2))$oF^^K$&KKr||$LN
 T !$&) $$/*;#-/ r   c                     | j                  |      }t        |j                        }| j                  |      }t	        j
                  t        |t	        j                  t              g|z         }|S r   )	rr   r   r   rP   r   r   r   PointerTyperb  r   s         r   r   zCPUCallConv.get_function_type!  sd     &&x0../%%g.y &}(EF!) *+ r   c                      j                  |      }|j                   j                  |      |D cg c]  }d|z   	 c}        j                  |      }d|_        |j                  d       |j                  d        j                  |      }d|_        |j                  d       |j                  d       |r_ j                  |      }|D ]I  }t        |j                  t        j                        s(|j                  d       |j                  d       K  fd}	t        t        |	|            }
|
rG|j                  j                  d      }|j                  |j                  j!                  |g             yyc c}w )	zU
        Set names of function arguments, and add useful attributes to them.
        r   r   	nocapturer   r   c                     t        | t        j                        s*j                  j                  }||    j                         ryyNTF)r8   r   Arrayr'   rO   contains_nrt_meminfo)rR   dmmr(   s     r   type_may_always_need_nrtz?CPUCallConv.decorate_function.<locals>.type_may_always_need_nrtF  s6    b%++.ll55r7//1r   numba_args_may_always_need_nrtN)rr   r   rq   r   r   add_attributer   r8   r5   r   r  anymapr   add_named_metadatar?  r   )r(   r   r   r   r   rw   r   retargexcargr  args_may_always_need_nrtnmds   `           r   r   zCPUCallConv.decorate_function-  sU    &&{3T//3267$Qfqj$7	9**2.[)Y'++B/[)Y'%%b)Daffbnn5OOK0OOI. 	 $'(+6$
  $))..0C GGBII**B401	 $? 8s   E>
c                      |j                   dd S )r   r   Nr   r   s     r   rq   zCPUCallConv.get_argumentsX  r   r   c                      |j                   d   S r   r   r   s     r   r   z CPUCallConv._get_return_argument^      yy|r   c                      |j                   d   S rx  r   r   s     r   r   z!CPUCallConv._get_excinfo_argumenta  r  r   c                    | j                  |j                        j                  }t        j                  ||      }|j                  t        j                  |      |       t        j                  |t        j                  t              d      }	| j                  |      }
t        |
j                  ||            }||	g|z   }|d}n7t        |t              rt        |t              st!        |      }nt#        d      |j%                  |||      }| j'                  |||j)                  |	            }|j)                  |      }| j*                  j-                  |||      }||fS )aU  
        Call the Numba-compiled *callee*.
        Parameters:
        -----------
        attrs: LLVM style string or iterable of individual attributes, default
               is None which specifies no attributes. Examples:
               LLVM style string: "noinline fast"
               Equivalent iterable: ("noinline", "fast")
        r   )r   r~   z,attrs must be an iterable of strings or None)attrs)r   r  r   r   r   r   r   r   r  ra  rr   r   r   r8   r   r   r   r   r   r   r   r'   r   )r(   r=   r   r   r   r   r  r>   r   r   rw   r   _attrsr   r^   rB   r   s                    r   r   zCPUCallConv.call_functiond  s<    ))&*>*>?GG''7	g,,U3Y?(("..2K.79
 &&v.G(($78z*T1 =Fx(E31G5\FJKK||FHF|;(($)0j)ACi(ll--gufEs{r   r   NNr   r   )r{   r|   r}   r   	itertoolscount_status_idsrU   r7   r   r   r   r  r_   rS  r^  rh  rj  rr  r   r{  r  r   rE   r   r   r   rq   r   r   r   r~   r   r   r   r   a  s     ")//!$K6" DH&*79r @D"&?2h0>@& JN'+X-v 59;	9*(;0
)2V !'r   r   c                       e Zd Zd ZddZy)
ErrorModelc                     || _         y r   )	call_conv)r(   r  s     r   r)   zErrorModel.__init__  s	    "r   Nc                 b    | j                   r#| j                  j                  |t        ||       yyr  )raise_on_fp_zero_divisionr  r   ZeroDivisionError)r(   r=   r   r   s       r   fp_zero_divisionzErrorModel.fp_zero_division  s-    ))NN**74Ex+.0r   r  )r{   r|   r}   r)   r  r~   r   r   r  r    s    #r   r  c                       e Zd ZdZdZy)PythonErrorModelzL
    The Python error model.  Any invalid FP input raises an exception.
    TNr{   r|   r}   r   r  r~   r   r   r  r    s     !%r   r  c                       e Zd ZdZdZy)NumpyErrorModela6  
    In the Numpy error model, floating-point errors don't raise an
    exception.  The FPU exception state is inspected by Numpy at the
    end of a ufunc's execution and a warning is raised if appropriate.

    Note there's no easy way to set the FPU exception state from LLVM.
    Instructions known to set an FP exception can be optimized away:
        https://llvm.org/bugs/show_bug.cgi?id=6050
        http://lists.llvm.org/pipermail/llvm-dev/2014-September/076918.html
        http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140929/237997.html
    FNr  r~   r   r   r  r    s    
 !&r   r  )pythonnumpyc                 2    t        |    |j                        S )zF
    Create an error model instance for the given target context.
    )error_modelsr  )
model_namer'   s     r   create_error_modelr    s     
#G$5$566r   )0r   collectionsr   collections.abcr   r  r7  llvmliter   
numba.corer   r   r   numba.core.baser	   r
   r   r   r   r#  int64_tr   r   r   rI   rF   rL   r   r   objectr%   r   r   r  r  r	  r
  r"  r`  ra  r  rb  r   r  r  r  r  r  r~   r   r   <module>r     sh   # $    - - 5 {Xy$9:	 
H
& "**R.
"**R.	( ]
n"~B]+k56 k5\zl zz-* -*d   B  gIK	y)j, jZ %z %&j &  7r   