
    J/Ph?                        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j&        eeeeeg          Z' ej(        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/dS )'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    S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/core/callconv.py
_const_intr   +   s    ;y$'''       c                   V    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dS )BaseCallConvc                     || _         d S r   )context)selfr'   s     r   __init__zBaseCallConv.__init__<   s    r   c                    |t           j        k    r|                     |           d S ||k    r| j                            |||          }t          j        ||j                  }|                    |          5  | j        	                    ||j
        |j                  }|                     ||           d d d            n# 1 swxY w Y   |                     |           d S t          |t           j                  sg||j
        k    r#| j                            ||||j
                  }| j        	                    ||j
        |          }|                     ||           d S t!          d                    ||                    )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?   s   EJ##G,,,,,e^^\--guE-JJF*7FLAAH** 3 366w
7={D D!!'62223 3 3 3 3 3 3 3 3 3 3 3 3 3 3
 ##G,,,,,E5>22 
	M
""))'5/4z * ; ;\227EJNNFgv..... &&=&D&DUEJ'L 'L M M Ms   :=CC
Cc                 <    |                      |t                     d S r   )_return_errcode_rawRETCODE_NONEr(   r=   s     r   r/   zBaseCallConv.return_native_none\   s      ,77777r   c                 <    |                      |t                     d S r   )rE   RETCODE_EXCrG   s     r   
return_exczBaseCallConv.return_exc_   s      +66666r   c                 <    |                      |t                     d S r   )rE   RETCODE_STOPITrG   s     r   return_stop_iterationz"BaseCallConv.return_stop_iterationb   s      .99999r   c                 r    | 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   s1     ,1"5EEGG!!###r   c                 >    |                      |          }||_        |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                 6    |                     |j                  S r   )unserializer   )r(   r=   pyapistatuss       r   unpack_exceptionzBaseCallConv.unpack_exceptionw   s      !2333r   c                    |j                                         }|                    |j                  5  |                                 |                     |||          }t          j        |t          j        ||                    5  |	                    |           ddd           n# 1 swxY w Y   |
                    |           ddd           n# 1 swxY w Y   |                    |j                  5  |                    d           |
                    |           ddd           n# 1 swxY w Y   |                    |j                  5  |
                    |           ddd           n# 1 swxY w Y   |                    dd           |
                    |           |                    |           dS )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   s     3355__V/00 	" 	" OO''??C"7#*#6w#D#DF F ( (""3'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( NN5!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" __V566 	" 	"4555NN5!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" __V122 	" 	"NN5!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	0I	K 	K 	Ku&&&&&sZ   ACB*C*B.	.C1B.	2CCC;+D22D69D6E99E= E=c                     |                      |          }|                     |          }|                    ||          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   s@    
 %%d++&&x00%%gx888r   c                 6    | 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44r   N)__name__
__module____qualname__r)   rC   r/   rJ   rM   rP   rX   rZ   r_   ro   rx   rr    r   r   r%   r%   :   s          M M M:8 8 87 7 7: : :$ $ $  % % %4 4 4' ' '<9 9 95 5 5 5 5r   r%   c                   V    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dS )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    s5J t	          |j                  t	          |j        j                  f            |                    ||           |                     |t                     d S Nr   )rc   argsr5   pointeestrstorerE   
RETCODE_OKr(   r=   rB   retptrs       r   r7   zMinimalCallConv.return_value   s    !&q){fk1111s6;#6778 211ff%%%  *55555r   Nc                    |'t          |t                    st          d|          |'t          |t                    st          d|          |.|                                }||}||j        |j        f}d |v rd }nd }|                     |          }|	                    |||          }	| 
                    |t          |	                     d S )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#A?)"s% & & &
8U(C(C)'x* + + + ?**,,E}!clCH5GwG++G44++C7CC  *V*<*<=====r   c                 <    |                      ||j                   d S r   )rE   r   )r(   r=   r^   s      r   return_status_propagatez'MinimalCallConv.return_status_propagate   s       &+66666r   c                 x    t          |t                    rt          |          }|                    |           d S r   )r8   intr   retr(   r=   r   s      r   rE   z#MinimalCallConv._return_errcode_raw   s9    dC   	$d##DDr   c           
         |                     d|t                    }|                     d|t                    }|                    ||          }|                    |          }|                     d|t
                    }|                     d|t                    }|                     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K))$oFFT !$&) $$/*;#') ) ) r   c                     |                      |          }t          |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   sW     &&x00.//%%g..y6(X*=>>r   Fc                     |rJ |                      |          }|                    |                     |          d |D                        d|j        d         _        dS )zA
        Set names and attributes of function arguments.
        c                     g | ]}d |z   S zarg.r~   .0as     r   
<listcomp>z5MinimalCallConv.decorate_function.<locals>.<listcomp>	      777Qfqj777r   z.retr   N)rr   assign_namesrq   r   name)r(   fnr   fe_argtypesnoaliasrw   s         r   decorate_functionz!MinimalCallConv.decorate_function  sm     &&{33T//3377$777	9 	9 	9 
r   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       y}r   c                    |j         d         j        j        }t          j        ||          }|                    t          j        |          |           |                     |          }|                    ||          }|gt          |          z   }	|
                    ||	          }
|                     ||
          }|                    |          }| 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7	g,U33Y???&&v..##GT22;d+||FH--(($77i((l--gufEEs{r   NNNF)r{   r|   r}   __doc__rU   r7   r   r   rE   r   r   r   rq   r   r~   r   r   r   r      s         $ $ $6 6 6 @D"&> > > >47 7 7  
  ,  ! ! ! !      r   r   c                   $    e Zd ZdZd Zd Zd ZdS )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 | _         d S r   )
exceptions)r(   s    r   r)   z_MinimalCallHelper.__init__,  s    r   c                 X    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/  s0     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  s]    	*?6** 	* 	* 	*7&@CCvHG'))))	*s     22N)r{   r|   r}   r   r)   r   r   r~   r   r   r   r   %  sK             $* * * * *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dS )!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                     d S r   r~   rG   s     r   rU   zCPUCallConv._make_call_helperr  s    tr   c                 0   |                      |j                  }|j        |j        j        k    s5J t	          |j                  t	          |j        j                  f            |                    ||           |                     |t                     d S r   )_get_return_argumentrc   r5   r   r   r   rE   r   r   s       r   r7   zCPUCallConv.return_valueu  s    **7+;<<{fk1111s6;#6778 211ff%%%  *55555r   c                 t    |.|                                 }||}||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|  sW    ?**,,E}!clCH5GwGHg&
r   Nc                 P   |'t          |t                    st          d|          |'t          |t                    st          d|          |t	                      }| j                            |          }|                     ||||          }|                    |          }| 	                    |j
                  }|                    ||          }	|j                             t          j        d          d          g          }
|	                    d|
           d S )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#A?)"s% & & &
8U(C(C)'x* + + +
 wwHJ ++G44''XsIFF**3//	++G,<==i00^((-"*Q--*:*:);<<3R88888r   c                     t          |dd          }|                     |||||           |                     |           |r|                    |d                    d S |                     |t
                     d S )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  s    7OU;;  #%(I 	! 	? 	? 	?g&&& 	? NN8H-..... $$Wo>>>>>r   c                    |j         }|                    |                    |          t                    }|                    |                    |          t                    }|                    ||                    ||j                            }|                    |                    |          t                    }|                    |                    |          t                    }	t          j        t          t          g          }
|                    |	|
                                          }|                    ||g          }t#          j        ||          }t#          j        ||          5  d}|                    d|           |j        j        }
t/          |
j        t          j                  s-|                    t#          j        |
j                             n|                                 d d d            n# 1 swxY w Y   |                    ||          }| j        j        r9| j        j         !                    ||                    ||j"                             |S )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  sq   ' ))LL%%~7 7	,,LL%%'79 9 ;;w||L%2BCCE E ((LL%%|5 5((LL%%8 8 x/):;;__Xt'8'899<<XJ//
 (33 &11 
	# 
	#C  !5s;;;#1Dd.<< #G243CDDEEEE  """
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 
	# 445ExPP <" 	F L!!emDDF F Fs   8BH		HHc                    |j         }|                    |                    |          t                    }|                    d|t          d                    }|                    |          5 \  }}|5  |                     |||          }	|j        }
d d d            n# 1 swxY w Y   |5  |	                    |          }|j        }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |
                    |j                  }|                    |	|
           |                    ||           |S )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+D+9; ;
  j'!**==__R   	($5T9 ( (77OO!-( ( ( ( ( ( ( ( ( ( ( ( ( ( (  ( ("..{;;
!-( ( ( ( ( ( ( ( ( ( ( ( ( ( (		( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( kk*/**'***W---
sZ   /C-5B C- B$	$C-'B$	(C--C
C-C	C-C	C--C14C1c                     t          j        t          |                                                                                    }d| }||j        v r|j                            |          S t          j        t          t          g          }t          j
        |||          }|j                            d           |j                            d           |                    d          }t          j        |          }	| j                            |	          }
|                                }|	                    |j        d         |          }d |D             }g }| j                            |	d          }t+          |          D ]\  }}|	                    |	                    |          |          }|
                    |||	          }|t3          j        |j                  k    rd
| d}t9          j        |          |                    |           | j        j                             |	| !                    |	j"                             |
#                    |          }|	$                    |           |S )N__excinfo_unwrap_argsnounwindnoinline r   c                     g | ]}||S r   r~   )r   typs     r   r   z@CPUCallConv.emit_unwrap_dynamic_exception_fn.<locals>.<listcomp>D  s    ???CsC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objsr=  ir;  valobjr   tups                        r    emit_unwrap_dynamic_exception_fnz,CPUCallConv.emit_unwrap_dynamic_exception_fn   s`     S\\002233==??.u..6>!!>%%d+++0ABB[t,, 	*%%%
*%%%((,,,x((++G44 ((**[99??8??? l227CG 3 I I)) 
	 
	FAs''V(<(<a@@C))#s)LLC g,SX6666HsHHH(---KK 	g"778HII	K 	K 	K t$$C	r   c                    |                     | j                            |                    }|                    | j        j                            ||          |                                          }d |D             }t          d          }t          |          D ]>\  }}	|	                    |	|
                    ||t          |          g                     ?|S )zP
        Create an anonymous struct containing the given LLVM *values*.
        c                 F    g | ]}t          |t          j                  |S r~   r8   r   Valuer   args     r   r   z4CPUCallConv.emit_wrap_args_insts.<locals>.<listcomp>k  s)    IIICz#rx/H/HICIIIr   r   )r  r'   get_abi_sizeofr  r  allocaterQ   r(  rI  r   gep)
r(   r=   r]   struct_typer   st_sizerS  zeroidxr_  s
             r   emit_wrap_args_instsz CPUCallConv.emit_wrap_args_insts`  s     ""4<#>#>{#K#KLLL%%gw77""$$& &
 JI8IIIqzz!(++ 	J 	JHCMM#w{{6D'#,,3GHHIIIIr   c                 b   t          |t                    st          d|          |'t          |t                    st          d|          | j                            |          }| j                                        t	          fd|D                       }|                     ||||          }| 	                    |j
                  }	|                    |                    |                    }
t          j        d |D                       }|                     ||||          }|                     |j        ||          }|                    | j                            t(                              }|                    | j        j                            ||          t0                    }t3          d          }|                    |
t6                    |                    |
t8                    |                    |t:                    |                    |t:                    t3          t=          |                    f}t?          |          D ]>\  }}|                     ||!                    ||t3          |          g                     ?|                     ||	           dS )zf
        Compute the required bits to emit an exception with dynamic (runtime)
        values
        z&exc should be an exception class, got Nr   c                 L    g | ] }t          |t          j                  rn|!S r~   r\  )r   r_  dummys     r   r   z4CPUCallConv.set_dynamic_user_exc.<locals>.<listcomp>  s.    MMMSjbh//8UUSMMMr   c                 P    g | ]#}t          |t          j                  |j        $S r~   )r8   r   r]  r5   r^  s     r   r   z4CPUCallConv.set_dynamic_user_exc.<locals>.<listcomp>  sA     ,G ,G ,G,6sBH,E,E,GCH ,G ,G ,Gr   r   )"r   r   r   r8   r   r'   r   get_dummy_valuer   r   rc   r   r   r   LiteralStructTyperg  rY  r   r  r`  	excinfo_tr  r  ra  excinfo_ptr_tr(  r  r	  r
  r
   r   rI  r   rb  )r(   r=   rn   r   rO  r   r   r]   exc_args_static
excinfo_ppr   rc  rS  	unwrap_fnexc_size	excinfo_pre  
exc_fieldsrf  r_  rj  s                       @r   set_dynamic_user_excz CPUCallConv.set_dynamic_user_excs  s    #}-- 	&)"s% & & &
8U(C(C)'x* + + +b ++G44,,..MMMMHMMMO O''_c9MM//0@AA
LL!7!7!<!<==	 * ,G ,G ,G ,G ,G H H**7E;+35 599NK3 3	 ##DL$?$?	$J$JKKOOL%%gx88 	
 qzz++I~FF++I7GHHoofo>>ooiAAc+..//	1

 "*-- 	M 	MHCMM#w{{9tWS\\6JKKLLLLi,,,,,r   c                 r    |                      ||||||           |                     |t                     dS )zF
        Same as ::return_user_exc but for dynamic exceptions
        )r   r   N)rv  rE   r   )r(   r=   rn   r   rO  r   r   s          r   return_dynamic_user_excz#CPUCallConv.return_dynamic_user_exc  sM    
 	!!'3(&)Y 	" 	@ 	@ 	@  /:::::r   c                     	 |j         S # t          $ r. 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  s`    	)) 	 	 	%k  C &)G"JJJ	s   	 5A Ac                 *   |                      |          }|                    |          }|                    d||                    d                    }|                     |j                  }|                    |          }t          ||          S )Nr&  r   )r   r   )r  r   icmp_unsignedr5   r   rc   r   )r(   r=   try_state_ptr	try_depthr   r   r   s          r   r  zCPUCallConv.check_try_status  s    ++G44LL//	&&sIy~~a7H7HII//0@AA
,,z**8888r   c                     |                      |          }|                    |          }|                    ||                    d                    }|                    ||           d S Nr#   )r  r   rF  r5   r   )r(   r=   r  oldnews        r   set_try_statuszCPUCallConv.set_try_status  s]    ++G44ll=))kk#sxx{{++c=)))))r   c                 t   |                      |          }|                    |          }|                    ||                    d                    }|                    ||           |                     |j                  }t          j        |j        j	                  }|                    ||           d S r  )
r  r   subr5   r   r   rc   r   r   r   )r(   r=   r  r  r  r   nulls          r   unset_try_statuszCPUCallConv.unset_try_status  s    ++G44ll=))kk#sxx{{++c=))) //0@AA
%jo&=>>dJ'''''r   c                 \   |                      |          }|                     |j                  }|                    |j        |           |                    |                    |j                            5  |                     ||j	                   d d d            d S # 1 swxY w Y   d S r   )
r  r   rc   r   r   r3   r   r   rE   r   )r(   r=   r^   	trystatusr   s        r   r   z#CPUCallConv.return_status_propagate  s    ))'22	++G,<==f'000__W\\)*:;;<< 	; 	;$$Wfk:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s   8B!!B%(B%c                 0    |                     |           d S r   )r   r   s      r   rE   zCPUCallConv._return_errcode_raw	  s    Dr   c           
         |                     d|t                    }|                     d|t                    }|                     d|t                    }|                     d|t                    }|                    ||          }|                    |          }	|                     d|t                    }
|                    |
|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   ro  	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K[[t$$ll2))$oFF^^K$&Kr|$L$LN N
 T !$&) $$/*;#-/ / / r   c                     |                      |          }t          |j                  }|                     |          }t	          j        t          |t	          j        t                    g|z             }|S r   )	rr   r   r   rP   r   r   r   PointerTypero  r   s         r   r   zCPUCallConv.get_function_type$  sn     &&x00.//%%g..y &}(E(EF!) *+ + r   Fc                 V                          |          }|                                         |          d |D                                             |          }d|_        |                    d           |                    d                                |          }d|_        |                    d           |                    d           |rc                     |          }|D ]K}t          |j        t          j
                  r*|                    d           |                    d           L fd}	t          t          |	|                    }
|
rJ|j                            d          }|                    |j                            |g                     dS dS )	zU
        Set names of function arguments, and add useful attributes to them.
        c                     g | ]}d |z   S r   r~   r   s     r   r   z1CPUCallConv.decorate_function.<locals>.<listcomp>6  r   r   r   	nocapturer   r   c                     t          | t          j                  s(j        j        }||                                          rdS dS 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_nrtI  sC    b%+..  l5r7//11  45r   numba_args_may_always_need_nrtN)rr   r   rq   r   r   add_attributer   r8   r5   r   r  anymapr   add_named_metadatarF  r   )r(   r   r   r   r   rw   retargexcargr   r  args_may_always_need_nrtnmds   `           r   r   zCPUCallConv.decorate_function0  s    &&{33T//3377$777	9 	9 	9**2..[)))Y'''++B//[)))Y''' 	/%%b))D / /afbn55 /OOK000OOI...	 	 	 	 	 $'(+66$
 $
  $ 	2)..0 C GGBI**B40011111		2 	2r   c                      |j         dd         S )r   r   Nr   r   s     r   rq   zCPUCallConv.get_arguments[  r   r   c                     |j         d         S r   r   r   s     r   r   z CPUCallConv._get_return_argumenta      y|r   c                     |j         d         S r  r   r   s     r   r   z!CPUCallConv._get_excinfo_argumentd  r  r   c                    |                      |          j        }|                     |j                  j        }||k    rd| d| }	t	          |	          t          j        ||          }
|                    t          j        |          |
           t          j        |t          j
        t                    d          }|                     |          }t          |                    ||                    }|
|g|z   }|d}nIt          |t                     r%t          |t"                    st%          |          }nt'          d          |                    |||          }|                     |||                    |                    }|                    |
          }| 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")
        zFunction type returns z but resty=r   )r   Nr~   z,attrs must be an iterable of strings or None)attrs)rP   r   r   r  
ValueErrorr   r   r   r   r   r  rn  rr   r   r   r8   r   r   r   r   r   r   r   r'   r   )r(   r=   r   r   r   r   r  r>   actual_rettymr   r   rw   r   _attrsr   r^   rB   r   s                      r   r   zCPUCallConv.call_functiong  s    $$U++3001EFFNL  III%IIAQ--'77	g,U33Y???(".2K2K.79 9 9
 &&v..G(($7788z*T1 =FFx(( 	LE31G1G 	L5\\FFJKKK||FHF|;;(($)0j)A)AC Ci((l--gufEEs{r   r   NNr   r   )r{   r|   r}   r   	itertoolscount_status_idsrU   r7   r   r   r   r$  r_   rY  rg  rv  rx  r  r  r  r  r   rE   r   r   r   rq   r   r   r   r~   r   r   r   r   a  s         ")/!$$K  6 6 6  " DH&*79 79 79 79r @D"&? ? ? ?2 2 2h  0> > >@  & JN'+[- [- [- [-| 59; ; ; ;  	9 	9 	9* * *( ( (; ; ;    0
 
 
)2 )2 )2 )2V       !) ) ) ) ) )r   r   c                       e Zd Zd ZddZdS )
ErrorModelc                     || _         d S r   )	call_conv)r(   r  s     r   r)   zErrorModel.__init__  s    "r   Nc                 \    | j         r$| j                            |t          ||           dS dS r  )raise_on_fp_zero_divisionr  r   ZeroDivisionError)r(   r=   r   r   s       r   fp_zero_divisionzErrorModel.fp_zero_division  s;    ) 	N**74Ex+.0 0 045r   r  )r{   r|   r}   r)   r  r~   r   r   r  r    s7        # # #     r   r  c                       e Zd ZdZdZdS )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dS )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                 6    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666r   )0r   collectionsr   collections.abcr   r  r>  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'  rm  rn  r  ro  r   r  r  r  r  r  r~   r   r   <module>r     s    # " " " " " $ $ $ $ $ $            - - - - - - - - - - 5 5 5 5 5 5 5 5 J{Xy$9::	 
H
 
& "*R..
"*R..	( ( ( Z]]
jnnz"~~B*]++k5 k5 k5 k5 k56 k5 k5 k5\z z z z zl z z zz-* -* -* -* -* -* -* -*d   B gIK K	y))o o o o o, o o od       % % % % %z % % %& & & & &j & & &   7 7 7 7 7r   