
    xKgQ                          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Z
d	 Z G d
 de      Z G d de      Z G d de      Zy)z
Function descriptors.
    )defaultdictN)typesitanium_mangler)_dynamic_modname_dynamic_module abi_tagsuidc                4    t        j                  | |||      S )Nr	   )r   mangle)nameargtypesr
   r   s       W/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/core/funcdesc.pydefault_manglerr      s    !!$8MM    c                 .    | rdj                  | |      S |S )zS
    Returns a new string that is used for the first half of the mangled name.
    z{}.{})format)modnamequalnames     r   qualifying_prefixr      s    
 187>>'8,EXEr   c                       e Zd ZdZdZ	 	 	 ddZd Zd Zd Ze	d        Z
e	d	        Ze	d
        Zd Zed        Ze	 	 dd       Zy)FunctionDescriptora"  
    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".
    )nativer   r   doctypemap	calltypesargskwsrestyper   mangled_nameunique_nameenv_nameglobal_dictinlinenoaliasr
   r   Nc                 2    | _         | _        | _        | _        | _        | _        | _        | _        |	 _        |
 _	        | _
        |t        |t              sJ |       | _        nt         fd|	D               _        |t        n|}t         j                   j                        }| _         || j                  ||       _        |% |dj%                  |       j                  ||      }| _        | _        | _        | _        y )Nc              3   B   K   | ]  }j                   d |z        yw)zarg.N)r   ).0aselfs     r   	<genexpr>z.FunctionDescriptor.__init__.<locals>.<genexpr>>   s     !IDq$,,vz":Ds   r	   z.NumbaEnv.{})r   r   r$   r   r"   r   r   r   r   r   r    
isinstancetupler   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   
qualprefixs   `                   r   __init__zFunctionDescriptor.__init__&   s    & & "	h.88.$DM "!ID!IIDM%,_/' 't||T]]C
#c
 ~44Z@#}}xSJH  r   c                 R    | j                   xs | j                         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+   s    r   lookup_globalsz!FunctionDescriptor.lookup_globalsO   s$     @4#5#5#7#@#@@r   c                     | j                   t        k(  rt        S 	 t        j                  | j                         S # t
        $ r	 t        cY S w xY w)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.
        )r   r   r   	importlibimport_moduleImportErrorr5   s    r   r3   z FunctionDescriptor.lookup_moduleW   sF     <<++""' ..t||<< '&&'s   : AAc                 J    t        | j                         | j                        S )zO
        Return the original function object described by this object.
        )getattrr3   r   r5   s    r   lookup_functionz"FunctionDescriptor.lookup_functionf   s     t))+T]];;r   c                     | j                   S )z@
        The LLVM-registered name for the raw function.
        r!   r5   s    r   llvm_func_namez!FunctionDescriptor.llvm_func_namel   s    
    r   c                 D    t        j                  | j                  d      S )z
        The LLVM-registered name for a CPython-compatible wrapper of the
        raw function (i.e. a PyCFunctionWithKeywords).
        cpython)ns)r   prepend_namespacer!   r5   s    r   llvm_cpython_wrapper_namez,FunctionDescriptor.llvm_cpython_wrapper_nameu   s"     001B1B4=? 	?r   c                      d| j                   z   S )zb
        The LLVM-registered name for a C-compatible wrapper of the
        raw function.
        zcfunc.r?   r5   s    r   llvm_cfunc_wrapper_namez*FunctionDescriptor.llvm_cfunc_wrapper_name~   s     $++++r   c                      d| j                   z  S )Nz<function descriptor %r>)r"   r5   s    r   __repr__zFunctionDescriptor.__repr__   s    )T-=-=>>r   c                 R   |j                   j                  }|j                   j                  }|j                  }|j                  xs d}t        |j                        }d}d}|&t        }|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_irrM   r   r   r   r   r   r$   r"   s
             r   _get_function_infoz%FunctionDescriptor._get_function_info   s     ##??00//ll bW&&'?&G "//..::Koo11gsD#{JJr   c
                     | j                  |      \  }
}}}}}} | |||
||||||||||||	|j                  j                        }|S )N)r/   r%   r&   r$   r
   r   )rU   rL   	unique_id)rS   rT   r   r    r   r   r/   r%   r&   r
   r   r"   r   r   r   r   r$   r+   s                     r   _from_python_functionz(FunctionDescriptor._from_python_function   sf    
 ##G,	;dC 67Hk3GYgfg*X00	2
 r   )NNFFNNr   N)NFFr   )__name__rO   __qualname__rP   	__slots__r1   r6   r3   r=   propertyr@   rE   rG   rI   classmethodrU   rX   r   r   r   r   r      s    9I BFFJ48'!RA'< ! ! ? ? , ,? K K8 9=DF r   r   c                   4    e Zd ZdZdZed        Zed        Zy)PythonFunctionDescriptorzE
    A FunctionDescriptor subclass for Numba-compiled functions.
    r   c	                 6    | j                  ||||d||||	      S )zx
        Build a FunctionDescriptor for a given specialization of a Python
        function (in nopython mode).
        T)r   r/   r%   r&   r
   )rX   )	rS   rT   r   r    r   r/   r%   r&   r
   s	            r   from_specialized_functionz2PythonFunctionDescriptor.from_specialized_function   s1     (('7I04g062: ) < 	<r   c                     t        d       }|j                         }t        j                  }| j	                  ||||d      S )ze
        Build a FunctionDescriptor for an object mode variant of a Python
        function.
        c                  "    t         j                  S N)r   pyobjectr   r   r   <lambda>zDPythonFunctionDescriptor.from_object_mode_function.<locals>.<lambda>   s    ennr   F)r   )r   copyr   re   rX   )rS   rT   r   r   r    s        r   from_object_mode_functionz2PythonFunctionDescriptor.from_object_mode_function   sF     45LLN	..(('7I05 ) 7 	7r   N)rY   rO   rZ   rP   r[   r]   ra   rh   r   r   r   r_   r_      s4     I	< 	< 	7 	7r   r_   c                   &     e Zd ZdZdZ fdZ xZS )ExternalFunctionDescriptorza
    A FunctionDescriptor subclass for opaque external functions
    (e.g. raw C functions).
    r   c                     t        t        |            D cg c]  }d|z  	 }}dd}t        t        |   dd ||dd |d |d ||       y c c}w )Nzarg%dc                     | S rd   r   )r*   xr
   r   s       r   r/   z4ExternalFunctionDescriptor.__init__.<locals>.mangler   s    Hr   TrK   )r   r   r   r"   r   r   r    r   r   r   r/   r   rd   )rangelensuperrj   r1   )r+   r   r    r   ir   r/   	__class__s          r   r1   z#ExternalFunctionDescriptor.__init__   se    %*3x=%9:%9!%9:	($ 	 $dT%)r4!(Dt!!("*  , ;s   A
)rY   rO   rZ   rP   r[   r1   __classcell__)rr   s   @r   rj   rj      s     I, ,r   rj   )rP   collectionsr   r8   
numba.corer   r   numba.core.utilsr   r   r   r   objectr   r_   rj   r   r   r   <module>rx      sT    $  - > 13 NFZ Zz71 7>,!3 ,r   