U
    ö¾|e‚   ã                   @   s„   d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	 dddœdd	„Z
d
d„ ZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )z
Function descriptors.
é    )ÚdefaultdictN)ÚtypesÚitanium_mangler)Ú_dynamic_modnameÚ_dynamic_module© ©Úabi_tagsÚuidc                C   s   t j| |||d�S )Nr   )r   Zmangle)ÚnameÚargtypesr	   r
   r   r   úP/var/www/website-v5/atlas_env/lib/python3.8/site-packages/numba/core/funcdesc.pyÚdefault_mangler   s    r   c                 C   s   | rd  | |¡S |S )zS
    Returns a new string that is used for the first half of the mangled name.
    z{}.{})Úformat)ÚmodnameÚqualnamer   r   r   Úqualifying_prefix   s    r   c                   @   s|   e Zd ZdZdZddd„Zdd	„ Zd
d„ Zdd„ Ze	dd„ ƒZ
e	dd„ ƒZe	dd„ ƒZdd„ Zedd„ ƒZeddd„ƒZdS )ÚFunctionDescriptoraS  
    Base class for function descriptors: an object used to carry
    useful metadata about a natively callable function.

    Note that while `FunctionIdentity` denotes a Python function
    which is being concretely compiled by Numba, `FunctionDescriptor`
    may be more "abstract": e.g. a function decorated with `@generated_jit`.
    )Únativer   r   ÚdocÚtypemapÚ	calltypesÚargsÚkwsÚrestyper   Úmangled_nameÚunique_nameÚenv_nameÚglobal_dictÚinlineÚnoaliasr	   r
   NFr   c                    sð   |ˆ _ |ˆ _|ˆ _|ˆ _|ˆ _|ˆ _|ˆ _|ˆ _|	ˆ _|
ˆ _	|ˆ _
|d k	rdt|tƒs\t|ƒ‚|ˆ _nt‡ fdd„|	D ƒƒˆ _|d krˆtn|}tˆ jˆ jƒ}|ˆ _||ˆ j||d�ˆ _|d krÔ|d |¡ˆ j||d�}|ˆ _|ˆ _|ˆ _|ˆ _d S )Nc                 3   s   | ]}ˆ j d |  V  qdS )zarg.N)r   )Ú.0Úa©Úselfr   r   Ú	<genexpr>>   s     z.FunctionDescriptor.__init__.<locals>.<genexpr>r   z.NumbaEnv.{})r   r   r   r   r   r   r   r   r   r   r   Ú
isinstanceÚtupleÚAssertionErrorr   r   r   r
   r   r   r   r   r    r	   )r$   r   r   r   r   r   r   r   r   r   r   Úmanglerr   r   r    r   r   r	   r
   Z
qualprefixr   r#   r   Ú__init__&   sD       ÿ
  ÿzFunctionDescriptor.__init__c                 C   s   | j p|  ¡ jS )z¨
        Return the global dictionary of the function.
        It may not match the Module's globals if the function is created
        dynamically (i.e. exec)
        )r   Úlookup_moduleÚ__dict__r#   r   r   r   Úlookup_globalsO   s    z!FunctionDescriptor.lookup_globalsc                 C   s:   | j tkrtS zt | j ¡W S  tk
r4   t Y S X dS )zÃ
        Return the module in which this function is supposed to exist.
        This may be a dummy module if the function was dynamically
        generated or the module can't be found.
        N)r   r   r   Ú	importlibÚimport_moduleÚImportErrorr#   r   r   r   r+   W   s    
z FunctionDescriptor.lookup_modulec                 C   s   t |  ¡ | jƒS )zO
        Return the original function object described by this object.
        )Úgetattrr+   r   r#   r   r   r   Úlookup_functionf   s    z"FunctionDescriptor.lookup_functionc                 C   s   | j S )z@
        The LLVM-registered name for the raw function.
        ©r   r#   r   r   r   Úllvm_func_namel   s    z!FunctionDescriptor.llvm_func_namec                 C   s   t j| jdd�S )z‰
        The LLVM-registered name for a CPython-compatible wrapper of the
        raw function (i.e. a PyCFunctionWithKeywords).
        Úcpython)Úns)r   Zprepend_namespacer   r#   r   r   r   Úllvm_cpython_wrapper_nameu   s    ÿz,FunctionDescriptor.llvm_cpython_wrapper_namec                 C   s
   d| j  S )zb
        The LLVM-registered name for a C-compatible wrapper of the
        raw function.
        zcfunc.r3   r#   r   r   r   Úllvm_cfunc_wrapper_name~   s    z*FunctionDescriptor.llvm_cfunc_wrapper_namec                 C   s
   d| j  S )Nz<function descriptor %r>)r   r#   r   r   r   Ú__repr__†   s    zFunctionDescriptor.__repr__c           
      C   sb   |j j}|j j}|j}|jpd}t|jƒ}d}d}|dkrHt}|j jj}|j j	}	||	|||||fS )z™
        Returns
        -------
        qualname, unique_name, modname, doc, args, kws, globals

        ``unique_name`` must be a unique name.
        Ú r   N)
Úfunc_idÚfuncÚfunc_qualnameÚ
__module__Ú__doc__r'   Ú	arg_namesr   Ú__globals__r   )
ÚclsÚfunc_irr<   r   r   r   r   r   r   r   r   r   r   Ú_get_function_info‰   s    	


z%FunctionDescriptor._get_function_infoc
                 C   sH   |   |¡\}
}}}}}}| |||
||||||||||||	|jjd�}|S )N)r)   r   r    r   r	   r
   )rD   r;   Z	unique_id)rB   rC   r   r   r   r   r)   r   r    r	   r   r   r   r   r   r   r   r$   r   r   r   Ú_from_python_function¦   s     ÿ       üz(FunctionDescriptor._from_python_function)NNFFNNr   N)NFFr   )Ú__name__r>   Ú__qualname__r?   Ú	__slots__r*   r-   r+   r2   Úpropertyr4   r7   r8   r9   ÚclassmethodrD   rE   r   r   r   r   r      s:                ý
)



      þr   c                   @   s,   e Zd ZdZdZedd„ ƒZedd„ ƒZdS )ÚPythonFunctionDescriptorzE
    A FunctionDescriptor subclass for Numba-compiled functions.
    r   c	           	      C   s   | j ||||d||||d�	S )zx
        Build a FunctionDescriptor for a given specialization of a Python
        function (in nopython mode).
        T)r   r)   r   r    r	   )rE   )	rB   rC   r   r   r   r)   r   r    r	   r   r   r   Úfrom_specialized_function»   s      ýz2PythonFunctionDescriptor.from_specialized_functionc                 C   s.   t dd„ ƒ}| ¡ }tj}| j||||dd�S )ze
        Build a FunctionDescriptor for an object mode variant of a Python
        function.
        c                   S   s   t jS ©N)r   Úpyobjectr   r   r   r   Ú<lambda>Í   ó    zDPythonFunctionDescriptor.from_object_mode_function.<locals>.<lambda>F)r   )r   Úcopyr   rN   rE   )rB   rC   r   r   r   r   r   r   Úfrom_object_mode_functionÇ   s    ÿz2PythonFunctionDescriptor.from_object_mode_functionN)rF   r>   rG   r?   rH   rJ   rL   rR   r   r   r   r   rK   µ   s   
rK   c                       s$   e Zd ZdZdZ‡ fdd„Z‡  ZS )ÚExternalFunctionDescriptorza
    A FunctionDescriptor subclass for opaque external functions
    (e.g. raw C functions).
    r   c                    sL   dd„ t t|ƒƒD ƒ}ddd„}tt| ƒjdd ||dd |d |d ||d� d S )	Nc                 S   s   g | ]}d | ‘qS )zarg%dr   )r!   Úir   r   r   Ú
<listcomp>Ü   s     z7ExternalFunctionDescriptor.__init__.<locals>.<listcomp>c                 S   s   | S rM   r   )r"   Úxr	   r
   r   r   r   r)   Þ   s    z4ExternalFunctionDescriptor.__init__.<locals>.manglerTr:   )r   r   r   r   r   r   r   r   r   r   r)   r   )N)ÚrangeÚlenÚsuperrS   r*   )r$   r   r   r   r   r)   ©Ú	__class__r   r   r*   Û   s     

      úz#ExternalFunctionDescriptor.__init__)rF   r>   rG   r?   rH   r*   Ú__classcell__r   r   rZ   r   rS   Ô   s   rS   )r?   Úcollectionsr   r.   Ú
numba.corer   r   Znumba.core.utilsr   r   r   r   Úobjectr   rK   rS   r   r   r   r   Ú<module>   s    