U
    ð¾|e~‘  ã                   @   sx  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 d¡Ze d¡ZeZdd„ ZedƒZedƒZedƒZedƒZdZeeƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZ dZ!dZ"dZ#dZ$dZ%e &eeeeeg¡Z'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-e,e-d&œZ.d'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                 C   s   t  t| ¡S ©N)r   ÚConstantÚ	errcode_t)r   © r   úP/var/www/website-v5/atlas_env/lib/python3.8/site-packages/numba/core/callconv.pyÚ
_const_int+   s    r   éÿÿÿÿéþÿÿÿéýÿÿÿé   c                   @   sl   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d„ Zdd„ ZdS )ÚBaseCallConvc                 C   s
   || _ d S r   )Úcontext)Úselfr#   r   r   r   Ú__init__<   s    zBaseCallConv.__init__c              	   C   sà   |t jkr|  |¡ nÆ||kr€| jj|||d�}t ||j¡}| |¡�& | j 	||j
|j¡}|  ||¡ W 5 Q R X |  |¡ n\t|t jƒsÌ||j
kr¬| jj||||j
d�}| j 	||j
|¡}|  ||¡ ntd ||¡ƒ‚d S )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&   ZoptvalZvalidbitÚretvalr   r   r   Úreturn_optional_value?   s*    
ÿ
ÿÿz"BaseCallConv.return_optional_valuec                 C   s   |   |t¡ d S r   )Ú_return_errcode_rawÚRETCODE_NONE©r$   r8   r   r   r   r*   \   s    zBaseCallConv.return_native_nonec                 C   s   |   |t¡ d S r   )r=   ÚRETCODE_EXCr?   r   r   r   Ú
return_exc_   s    zBaseCallConv.return_excc                 C   s   |   |t¡ d S r   )r=   ÚRETCODE_STOPITr?   r   r   r   Úreturn_stop_iterationb   s    z"BaseCallConv.return_stop_iterationc                 C   s   | 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Úrestyper   r   r   rE   e   s    zBaseCallConv.get_return_typec                 C   s   |   |¡}||_|S )zS
        Initialize and return a call helper object for the given builder.
        )Ú_make_call_helperÚ_BaseCallConv__call_helper)r$   r8   Úchr   r   r   Úinit_call_helperl   s    
zBaseCallConv.init_call_helperc                 C   s   |j S r   )rJ   r?   r   r   r   Ú_get_call_helpert   s    zBaseCallConv._get_call_helperc                 C   s   |  |j¡S r   )Úunserializer   )r$   r8   ÚpyapiÚstatusr   r   r   Úunpack_exceptionw   s    zBaseCallConv.unpack_exceptionc              
   C   sÞ   |j  ¡ }| |j¡�P | ¡  |  |||¡}t |t ||¡¡� | 	|¡ W 5 Q R X | 
|¡ W 5 Q R X | |j¡� | d¡ | 
|¡ W 5 Q R X | |j¡� | 
|¡ W 5 Q R X | dd¡ | 
|¡ | |¡ dS )zT
        Given a non-ok *status*, raise the corresponding Python exception.
        ZPyExc_StopIterationZPyExc_SystemErrorz*unknown error when calling native functionN)ÚfunctionÚappend_basic_blockr.   r   Ú	err_clearrQ   r   Ú	if_likelyÚis_not_nullÚraise_objectÚbranchr   Úerr_set_noner   Úerr_set_stringÚposition_at_end)r$   r8   rO   rP   ÚbbendÚexcr   r   r   Úraise_errorz   s&    

ÿ
ÿ
zBaseCallConv.raise_errorc                 C   s    |   |¡}|  |¡}| ||¡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$   r8   ÚargtypesÚfuncZraw_argsÚarginfor   r   r   Údecode_arguments˜   s    

zBaseCallConv.decode_argumentsc                 C   s   | j  |¡S )zF
        Get an argument packer for the given argument types.
        )r#   Zget_arg_packer)r$   rb   r   r   r   r`   ¡   s    zBaseCallConv._get_arg_packerN)Ú__name__Ú
__module__Ú__qualname__r%   r<   r*   rA   rC   rE   rL   rM   rQ   r^   re   r`   r   r   r   r   r"   :   s   	r"   c                   @   sd   e Zd ZdZdd„ Zdd„ Zd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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                 C   s   t ƒ S r   )Ú_MinimalCallHelperr?   r   r   r   rI   ¶   s    z!MinimalCallConv._make_call_helperc                 C   sP   |j jd }|j|jjks4tt|jƒt|jjƒfƒ‚| ||¡ |  |t¡ d S ©Nr   )	rR   Úargsr0   ÚpointeeÚAssertionErrorÚstrÚstorer=   Ú
RETCODE_OK©r$   r8   r;   Úretptrr   r   r   r2   ¹   s    ÿzMinimalCallConv.return_valueNc           
      C   s¨   |d k	r t |tƒs td|f ƒ‚|d k	r@t|tƒs@td|f ƒ‚|d k	rx| ¡ }|d kr\|}||j|jf}d |kr|d }nd }|  |¡}| 	|||¡}	|  
|t|	ƒ¡ d S )Nú-exc should be None or exception class, got %rú(exc_args should be None or tuple, got %r)Ú
issubclassÚBaseExceptionÚ	TypeErrorr3   ÚtupleÚ_raw_function_nameÚfilenameÚlinerM   Ú_add_exceptionr=   r   )
r$   r8   r]   Úexc_argsÚlocÚ	func_nameÚfnameÚlocinfoÚcall_helperÚexc_idr   r   r   Úreturn_user_excÀ   s&    ÿÿ
zMinimalCallConv.return_user_excc                 C   s   |   ||j¡ d S r   )r=   r   )r$   r8   rP   r   r   r   Úreturn_status_propagateÚ   s    z'MinimalCallConv.return_status_propagatec                 C   s    t |tƒrt|ƒ}| |¡ d S r   )r3   Úintr   Úret©r$   r8   r   r   r   r   r=   Ý   s    
z#MinimalCallConv._return_errcode_rawc              
   C   sx   |  d|t¡}|  d|t¡}| ||¡}| |¡}|  d|t¡}|  d|t¡}|  d|t¡}	t||||||	|dd�}
|
S )z?
        Given a return *code*, get a Status instance.
        ú==ú>=N©r   r   r   r   r   r   r   r   )	Úicmp_signedrq   r>   Úor_Únot_r@   rB   ÚRETCODE_USEREXCr   )r$   r8   r   Únormr)   ÚokÚerrr]   r   r   rP   r   r   r   Ú_get_return_statusâ   s"    
ùz"MinimalCallConv._get_return_statusc                 C   s4   |   |¡}t|jƒ}|  |¡}t t|g| ¡}|S ©zQ
        Get the implemented Function type for *restype* and *argtypes*.
        )r`   ÚlistÚargument_typesrE   r   ÚFunctionTyper   ©r$   rH   rb   rd   ÚresptrÚfntyr   r   r   Úget_function_typeø   s
    


z!MinimalCallConv.get_function_typeFc                 C   s>   |rt ‚|  |¡}| |  |¡dd„ |D ƒ¡ d|jd _|S )zA
        Set names and attributes of function arguments.
        c                 S   s   g | ]}d | ‘qS ©zarg.r   ©Ú.0Úar   r   r   Ú
<listcomp>	  s     z5MinimalCallConv.decorate_function.<locals>.<listcomp>z.retr   )rn   r`   Úassign_namesr_   rl   Úname)r$   Úfnrl   Úfe_argtypesÚnoaliasrd   r   r   r   Údecorate_function  s    
ÿz!MinimalCallConv.decorate_functionc                 C   s   |j dd… S )ú@
        Get the Python-level arguments of LLVM *func*.
        r!   N©rl   ©r$   rc   r   r   r   r_     s    zMinimalCallConv.get_argumentsc                 C   sŠ   |j d jj}t ||¡}| t |¡|¡ |  |¡}| ||¡}|gt	|ƒ }	| 
||	¡}
|  ||
¡}| |¡}| j |||¡}||fS )z3
        Call the Numba-compiled *callee*.
        r   )rl   r0   rm   r   Úalloca_oncerp   Úget_null_valuer`   Úas_argumentsr–   Úcallr”   Úloadr#   Úget_returned_value)r$   r8   ÚcalleeÚrestyÚargtysrl   r9   Ú	retvaltmprd   Úrealargsr   rP   r;   Úoutr   r   r   Úcall_function  s    

zMinimalCallConv.call_function)NNN)F)rf   rg   rh   Ú__doc__rI   r2   r…   r†   r=   r”   rœ   r§   r_   r·   r   r   r   r   ri   ¨   s     ÿ


ri   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	rj   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                 C   s
   i | _ d S r   )Ú
exceptions©r$   r   r   r   r%   -  s    z_MinimalCallHelper.__init__c                 C   s"   t | jƒt }|||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$   r]   r~   r‚   r„   r   r   r   r}   0  s    z!_MinimalCallHelper._add_exceptionc                 C   sF   z| j | W S  tk
r@   d| }t}|f}d}|||f Y S X dS )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„   Úmsgr]   r~   r‚   r   r   r   Úget_exceptionB  s    
z _MinimalCallHelper.get_exceptionN)rf   rg   rh   r¸   r%   r}   rÀ   r   r   r   r   rj   &  s   rj   é   é   é   c                   @   sæ   e Zd ZdZe d¡Zdd„ Zdd„ Zdd„ Z	d5d
d„Z
d6dd„Zdd„ Zdd„ Zdd„ Zdd„ Zd7dd„Zd8d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d9d+d,„Zd-d.„ Zd/d0„ Zd1d2„ Zd:d3d4„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                 C   s   d S r   r   r?   r   r   r   rI   s  s    zCPUCallConv._make_call_helperc                 C   sP   |   |j¡}|j|jjks4tt|jƒt|jjƒfƒ‚| ||¡ |  |t¡ d S r   )	Ú_get_return_argumentrR   r0   rm   rn   ro   rp   r=   rq   rr   r   r   r   r2   v  s    ÿzCPUCallConv.return_valuec                 C   sJ   |d k	r8|  ¡ }|d kr|}||j|jf}d |kr<d }nd }|||f}|S r   )rz   r{   r|   )r$   r]   r~   r   r€   r�   r‚   r   r   r   Úbuild_excinfo_struct}  s    
z CPUCallConv.build_excinfo_structNc                 C   s´   |d k	r t |tƒs td|f ƒ‚|d k	r@t|tƒs@td|f ƒ‚|d krNtƒ }| j |¡}|  ||||¡}| |¡}|  	|j
¡}| ||¡}	|j t d¡dƒg¡}
|	 d|
¡ d S )Nrt   ru   r!   Znumba_exception_output)rv   rw   rx   r3   ry   r#   Úget_python_apirÆ   Úserialize_objectÚ_get_excinfo_argumentrR   rp   ÚmoduleÚadd_metadatar   ÚIntTypeÚset_metadata)r$   r8   r]   r~   r   r€   rO   Ú	struct_gvÚexcptrrp   Úmdr   r   r   Úset_static_user_excŽ  s"    ÿÿ%
zCPUCallConv.set_static_user_excc                 C   sN   t |ddƒ}| j|||||d� |  |¡ |r>| |d ¡ n|  |t¡ d S )NÚ_in_try_blockF)r~   r   r€   Útarget)ÚgetattrrÑ   Úcheck_try_statusrX   r=   r�   )r$   r8   r]   r~   r   r€   Ztry_infor   r   r   r…   Ç  s    
 ÿ
zCPUCallConv.return_user_excc              	   C   s*  |j }| | |¡t¡}| | |¡t¡}| || ||j¡¡}| | |¡t¡}| | |¡t	¡}	t
 ttg¡}
| |	|
 ¡ ¡}| ||g¡}t ||¡}t ||¡�H d}| d|¡ |jj}
t|
jt
jƒsä| t |
j¡¡ n| ¡  W 5 Q R X | ||¡}| jj�r&| 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	   ÚbitcastrF   r®   r   Úis_nullÚif_unlikelyrZ   rR   Úfunction_typer3   Úreturn_typeÚVoidTyperˆ   r¬   Úret_voidÚbuild_dynamic_excinfo_structr#   Ú
enable_nrtÚnrtÚfreeÚvoidptr)r$   r8   rO   rP   Úexcinfo_ptrZ	picklebufZpicklebuf_szZstatic_exc_bytesZdyn_argsÚfunc_ptrr›   r¤   Zpy_tupleÚfailedr¿   r   r   r   r   Úunpack_dynamic_exceptionÕ  sN     ÿ ÿ ÿ ÿ ÿ
 ÿz$CPUCallConv.unpack_dynamic_exceptionc              
   C   s°   |j }| | |¡t¡}| d|tdƒ¡}| |¡�N\}}|� |  |||¡}	|j}
W 5 Q R X |� | 	|¡}|j}W 5 Q R X W 5 Q R X | 
|j¡}| |	|
¡ | ||¡ |S )Nú>r   )r   r×   r¯   ÚALLOC_FLAG_IDXr�   Úint32_tÚif_elserî   ÚblockrN   Úphir0   Úadd_incoming)r$   r8   rO   rP   rë   Z
alloc_flagÚgtÚthenÚ	otherwiseZdyn_excZbb_thenÚ
static_excZbb_elserô   r   r   r   rQ   	  s     ÿ
zCPUCallConv.unpack_exceptionc                 C   s\  t  t|ƒ ¡ ¡ ¡ }d|› �}||jkr6|j |¡S t t	t	g¡}t 
|||¡}|j d¡ |j d¡ | d¡}t |¡}	| j |	¡}
| ¡ }|	 |jd |¡}dd„ |D ƒ}g }| jj|	dd	�}t|ƒD ]\\}}|	 |	 |¡|¡}|
j|||d
�}|t |j¡k�r d|› d�}t |¡‚| |¡ qÎ| jj  |	|  !|	j"¡¡ |
 #|¡}|	 $|¡ |S )NZ__excinfo_unwrap_argsÚnounwindÚnoinlineÚ r   c                 S   s   g | ]}|d k	r|‘qS r   r   )rŸ   Útypr   r   r   r¡   E  s      z@CPUCallConv.emit_unwrap_dynamic_exception_fn.<locals>.<listcomp>T)Úreturn_pyobject)Úenv_managerzCannot convert native z to a Python object.)%ÚhashlibÚsha1ro   ÚencodeÚ	hexdigestÚglobalsÚgetr   r˜   r	   ÚFunctionÚ
attributesÚaddrS   Ú	IRBuilderr#   rÇ   rF   rß   rl   Úget_env_managerÚ	enumerater×   r¯   Úfrom_native_valuer   r¬   r0   r   ÚTypingErrorÚappendrè   ré   rÅ   rR   Ú
tuple_packrˆ   )r$   rÊ   Zst_typeÚnb_typesÚ_hashr£   r›   r¤   Zbb_entryr8   rO   Zst_type_ptrÚst_ptrÚobjsrÿ   Úirý   ÚvalÚobjr¿   Útupr   r   r   Ú emit_unwrap_dynamic_exception_fn!  s>    



ÿ


ÿ

z,CPUCallConv.emit_unwrap_dynamic_exception_fnc           
   
   C   sv   |  | j |¡¡}| | jj ||¡| ¡ ¡}dd„ |D ƒ}tdƒ}t|ƒD ]$\}}	| 	|	| 
||t|ƒg¡¡ qL|S )zP
        Create an anonymous struct containing the given LLVM *values*.
        c                 S   s   g | ]}t |tjƒr|‘qS r   )r3   r   ÚValue©rŸ   Úargr   r   r   r¡   l  s      z4CPUCallConv.emit_wrap_args_insts.<locals>.<listcomp>r   )rÜ   r#   Úget_abi_sizeofrß   rè   ÚallocaterF   rñ   r  rp   Úgep)
r$   r8   rO   Ústruct_typer~   Úst_sizer  ÚzeroÚidxr  r   r   r   Úemit_wrap_args_instsa  s    þz CPUCallConv.emit_wrap_args_instsc              
   C   sL  t |tƒstd|f ƒ‚|dk	r8t|tƒs8td|f ƒ‚| j |¡}|  ||||¡}|  |j	¡}| 
| |¡¡}	t dd„ |D ƒ¡}
|  |||
|¡}|  |j|
|¡}| | j t¡¡}| | jj ||¡t¡}tdƒ}| |	t¡| |	t¡| |t¡| |t¡tt|
ƒƒf}t|ƒD ]&\}}| ||  ||t|ƒg¡¡ �q| ||¡ dS )zf
        Compute the required bits to emit an exception with dynamic (runtime)
        values
        z(exc should be an exception class, got %rNru   c                 S   s   g | ]}t |tjƒr|j‘qS r   )r3   r   r  r0   r  r   r   r   r¡   ¶  s    ÿz4CPUCallConv.set_dynamic_user_exc.<locals>.<listcomp>r   )!rv   rw   rx   r3   ry   r#   rÇ   rÆ   rÉ   rR   r¯   rÈ   r   ÚLiteralStructTyper#  r  rÊ   rÜ   r  Ú	excinfo_trß   rè   r  Úexcinfo_ptr_trñ   r×   rØ   rÙ   r	   r»   r  rp   r  )r$   r8   r]   r~   r  r   r€   rO   Z
excinfo_pprÎ   r  r  Z	unwrap_fnZexc_sizeZ	excinfo_pr!  Z
exc_fieldsr"  r  r   r   r   Úset_dynamic_user_exct  sH    
ÿÿ1
ÿ  ÿþ




ü z CPUCallConv.set_dynamic_user_excc                 C   s&   | j ||||||d� |  |t¡ dS )zF
        Same as ::return_user_exc but for dynamic exceptions
        )r   r€   N)r'  r=   r�   )r$   r8   r]   r~   r  r   r€   r   r   r   Úreturn_dynamic_user_excÎ  s
     ÿz#CPUCallConv.return_dynamic_user_excc              	   C   s@   z|j W S  tk
r:   tj|tjddd�}||_ | Y S X d S )NZ	try_stateT)r£   Úzfill)Z_CPUCallConv__eh_try_stateÚAttributeErrorr   r«   Úintp_t)r$   r8   Úptrr   r   r   Ú_get_try_state×  s       ÿzCPUCallConv._get_try_statec                 C   sJ   |   |¡}| |¡}| d|| d¡¡}|  |j¡}| |¡}t||d�S )Nrï   r   )r   r   )r-  r¯   Úicmp_unsignedr0   rÉ   rR   r
   )r$   r8   Útry_state_ptrZ	try_depthr   r   r   r   r   r   rÕ   á  s    


zCPUCallConv.check_try_statusc                 C   s6   |   |¡}| |¡}| || d¡¡}| ||¡ d S ©Nr!   )r-  r¯   r  r0   rp   )r$   r8   r/  ÚoldÚnewr   r   r   Úset_try_statusì  s    

zCPUCallConv.set_try_statusc                 C   s\   |   |¡}| |¡}| || d¡¡}| ||¡ |  |j¡}t |jj	¡}| ||¡ d S r0  )
r-  r¯   Úsubr0   rp   rÉ   rR   r   r¬   rm   )r$   r8   r/  r1  r2  r   Únullr   r   r   Úunset_try_statusó  s    

zCPUCallConv.unset_try_statusc              	   C   sT   |   |¡}|  |j¡}| |j|¡ | | |j¡¡� |  ||j	¡ W 5 Q R X d S r   )
rÕ   rÉ   rR   rp   r   r.   r�   r   r=   r   )r$   r8   rP   Z	trystatusrÏ   r   r   r   r†      s
    
z#CPUCallConv.return_status_propagatec                 C   s   |  |¡ d S r   )rˆ   r‰   r   r   r   r=     s    zCPUCallConv._return_errcode_rawc              
   C   s�   |  d|t¡}|  d|t¡}|  d|t¡}|  d|t¡}| ||¡}| |¡}	|  d|t¡}
| |
|t	 
tt	j¡¡}t|||	|||
||d�}|S )zP
        Given a return *code* and *excinfoptr*, get a Status instance.
        rŠ   r‹   rŒ   )r�   rq   r>   r@   rB   rŽ   r�   r�   Úselectr   r   r&  Ú	Undefinedr   )r$   r8   r   r   r‘   r)   r]   r   r’   r“   r   rP   r   r   r   r”   
  s(    
ÿùzCPUCallConv._get_return_statusc                 C   s<   |   |¡}t|jƒ}|  |¡}t t|t t¡g| ¡}|S r•   )	r`   r–   r—   rE   r   r˜   r   ÚPointerTyper&  r™   r   r   r   rœ   "  s    


ÿÿzCPUCallConv.get_function_typeFc                    sê   ˆ   |¡}| ˆ  |¡dd„ |D ƒ¡ ˆ  |¡}d|_| d¡ | d¡ ˆ  |¡}d|_| d¡ | d¡ |r¨ˆ  |¡}|D ]&}t|jt	j
ƒr€| d¡ | d¡ q€‡ fdd„}	tt|	|ƒƒ}
|
ræ|j d	¡}| |j |g¡¡ |S )
zU
        Set names of function arguments, and add useful attributes to them.
        c                 S   s   g | ]}d | ‘qS r�   r   rž   r   r   r   r¡   4  s     z1CPUCallConv.decorate_function.<locals>.<listcomp>rs   Ú	nocapturer¦   r   c                    s(   t | tjƒs$ˆ jj}||   ¡ r$dS dS ©NTF)r3   r   ÚArrayr#   rD   Úcontains_nrt_meminfo)rG   Údmmrº   r   r   Útype_may_always_need_nrtG  s
    z?CPUCallConv.decorate_function.<locals>.type_may_always_need_nrtÚnumba_args_may_always_need_nrt)r`   r¢   r_   rÅ   r£   Úadd_attributerÉ   r3   r0   r   r9  ÚanyÚmaprÊ   Úadd_named_metadatar  rË   )r$   r¤   rl   r¥   r¦   rd   ZretargZexcargr    r?  Zargs_may_always_need_nrtÚnmdr   rº   r   r§   .  s8    
ÿ







ÿÿzCPUCallConv.decorate_functionc                 C   s   |j dd… S )r¨   rÁ   Nr©   rª   r   r   r   r_   [  s    zCPUCallConv.get_argumentsc                 C   s
   |j d S rk   r©   rª   r   r   r   rÅ   a  s    z CPUCallConv._get_return_argumentc                 C   s
   |j d S r0  r©   rª   r   r   r   rÉ   d  s    z!CPUCallConv._get_excinfo_argumentc                 C   sâ   |   |j¡j}t ||¡}| t |¡|¡ tj|t t	¡dd�}	|  
|¡}
t|
 ||¡ƒ}||	g| }|dkrvd}n&t|tƒr”t|tƒs”t|ƒ}ntdƒ‚|j|||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")
        r   )r£   Nr   z,attrs must be an iterable of strings or None)Úattrs)rÅ   râ   rm   r   r«   rp   r¬   r   r9  r%  r`   r–   r­   r3   r   ro   ry   rx   r®   r”   r¯   r#   r°   )r$   r8   r±   r²   r³   rl   rF  r9   r´   r   rd   rµ   Z_attrsr   rP   r;   r¶   r   r   r   r·   g  s*    ÿ

ÿ
zCPUCallConv.call_function)NNN)NNN)NN)NN)F)N)rf   rg   rh   r¸   Ú	itertoolsÚcountZ_status_idsrI   r2   rÆ   rÑ   r…   rî   rQ   r  r#  r'  r(  r-  rÕ   r3  r6  r†   r=   r”   rœ   r§   r_   rÅ   rÉ   r·   r   r   r   r   rÄ   b  sF   
  ÿ
9  ÿ
4@  ÿ
[   ÿ
	

- ÿrÄ   c                   @   s   e Zd Zdd„ Zddd„ZdS )Ú
ErrorModelc                 C   s
   || _ d S r   )Ú	call_conv)r$   rJ  r   r   r   r%   “  s    zErrorModel.__init__Nc                 C   s$   | j r| j |t||¡ dS dS d S r;  )Úraise_on_fp_zero_divisionrJ  r…   ÚZeroDivisionError)r$   r8   r~   r   r   r   r   Úfp_zero_division–  s    ÿzErrorModel.fp_zero_division)NN)rf   rg   rh   r%   rM  r   r   r   r   rI  ‘  s   rI  c                   @   s   e Zd ZdZdZdS )ÚPythonErrorModelzL
    The Python error model.  Any invalid FP input raises an exception.
    TN©rf   rg   rh   r¸   rK  r   r   r   r   rN  Ÿ  s   rN  c                   @   s   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
    FNrO  r   r   r   r   rP  ¦  s   rP  )ÚpythonÚnumpyc                 C   s   t |  |jƒS )zF
    Create an error model instance for the given target context.
    )Úerror_modelsrJ  )Ú
model_namer#   r   r   r   Úcreate_error_model»  s    rU  )0r¸   Úcollectionsr   Úcollections.abcr   rG  r   Úllvmliter   Ú
numba.corer   r   r   Znumba.core.baser   r	   r
   r   rÌ   rñ   Úint64_tr   r   rq   r@   r>   rB   r¼   r�   Úobjectr"   ri   rj   rØ   rÙ   rÝ   rÞ   rð   r$  r%  r9  r&  rÄ   rI  rN  rP  rS  rU  r   r   r   r   Ú<module>   sZ   ÿ

n~2ÿ
    3þ