U
    ?h                     @   s   d dl Z d dlmZ d dlmZ d dlmZmZmZm	Z	 G dd de
ZG dd deZed	ZG d
d dejZG dd dejZdS )    N)cached_property)TargetDescriptor)utilstyping
dispatchercpuc                   @   s"   e Zd ZdZdZejdd ZdS )_NestedContextNc              	   c   s6   | j | jf}z|| _ || _d V  W 5 |\| _ | _X d S N)_typing_context_target_context)selftyping_contexttarget_contextZ
old_nested r   E/var/www/html/venv/lib/python3.8/site-packages/numba/core/registry.pynested   s    
z_NestedContext.nested)__name__
__module____qualname__r
   r   
contextlibcontextmanagerr   r   r   r   r   r   
   s   r   c                   @   sP   e Zd ZejZe Zedd Z	edd Z
edd Zedd Zd	d
 ZdS )	CPUTargetc                 C   s   t | j| jS r	   )r   Z
CPUContextr   Z_target_namer   r   r   r   _toplevel_target_context   s    z"CPUTarget._toplevel_target_contextc                 C   s   t  S r	   )r   Contextr   r   r   r   _toplevel_typing_context"   s    z"CPUTarget._toplevel_typing_contextc                 C   s   | j j}|dk	r|S | jS dS )z5
        The target context for CPU targets.
        N)_nestedr   r   r   r   r   r   r   r   '   s    zCPUTarget.target_contextc                 C   s   | j j}|dk	r|S | jS dS )z5
        The typing context for CPU targets.
        N)r   r
   r   r   r   r   r   r   2   s    zCPUTarget.typing_contextc                 C   s   | j ||S )z
        A context manager temporarily replacing the contexts with the
        given ones, for the current thread of execution.
        )r   r   )r   r   r   r   r   r   nested_context=   s    zCPUTarget.nested_contextN)r   r   r   r   ZCPUTargetOptionsoptionsr   r   r   r   r   propertyr   r   r   r   r   r   r   r      s   





r   r   c                   @   s   e Zd ZeZdS )CPUDispatcherN)r   r   r   
cpu_targetZtargetdescrr   r   r   r   r!   I   s   r!   c                       s8   e Zd ZdZ fddZ fddZ fddZ  ZS )DelayedRegistrya#  
    A unique dictionary but with deferred initialisation of the values.

    Attributes
    ----------
    ondemand:

        A dictionary of key -> value, where value is executed
        the first time it is is used.  It is used for part of a deferred
        initialization strategy.
    c                    sJ   t  | _|dd | _|dd | _| jp0| j| _tt| j	|| d S )Nkey_type
value_type)
r   
UniqueDictondemandpopr$   r%   _type_checksuperr#   __init__)r   argskws	__class__r   r   r+   Y   s
    
zDelayedRegistry.__init__c                    s2   || j kr"| j |  | |< | j |= tt| |S r	   )r'   r*   r#   __getitem__)r   itemr.   r   r   r0   `   s    
zDelayedRegistry.__getitem__c                    sL   | j r:dd }| jd k	r$||| j | jd k	r:||| j tt| ||S )Nc                 S   s<   t |tr"|| jks8t| |fnt | |s8t| |fd S r	   )
isinstancetype__mro__AssertionError)xZty_xr   r   r   checkh   s    
z*DelayedRegistry.__setitem__.<locals>.check)r)   r$   r%   r*   r#   __setitem__)r   keyvaluer7   r.   r   r   r8   f   s    

zDelayedRegistry.__setitem__)r   r   r   __doc__r+   r0   r8   __classcell__r   r   r.   r   r#   M   s   r#   )r   	functoolsr   Znumba.core.descriptorsr   Z
numba.corer   r   r   r   objectr   r   r"   Z
Dispatcherr!   r&   r#   r   r   r   r   <module>   s   -