U
    ñ¾|eV  ã                   @   s
  d dl Z d dlmZmZmZ d dlmZmZmZm	Z	m
Z
 dd„ Zdd„ Zdd	„ Zee jejejƒeƒ ee jejejƒeƒ ee jejejƒeƒ eejƒd
d„ ƒZe
ejƒdd„ ƒZeejejƒdd„ ƒZeejejƒdd„ ƒZeejejƒeejejƒdd„ ƒƒZdS )é    N)ÚtypesÚtypingÚcgutils)Ú
lower_castÚlower_builtinÚlower_getattr_genericÚimpl_ret_untrackedÚlower_setattr_genericc                 C   s   t jS ©N)r   Útrue_bit©ÚcontextÚbuilderÚsigÚargs© r   úP/var/www/website-v5/atlas_env/lib/python3.8/site-packages/numba/core/optional.pyÚalways_return_true_impl
   s    r   c                 C   s   t jS r
   )r   Ú	false_bitr   r   r   r   Úalways_return_false_impl   s    r   c                 C   sj   |j \}}|\}}|tjkr0|| }}|| }}|}|}	|  |||	¡}
| t ||
j¡¡}t| ||j	|ƒS )z/
    Check if an Optional value is invalid
    )
r   r   ÚnoneÚmake_helperÚnot_r   Úas_bool_bitÚvalidr   Úreturn_type)r   r   r   r   ÚltyÚrtyZlvalÚrvalZopt_typeZopt_valÚoptÚresr   r   r   Úoptional_is_none   s    



r!   c                 C   s2   |j }|  ||||¡}|  ||¡}|| ||||ƒS )z?
    Optional.__getattr__ => redirect to the wrapped type.
    )ÚtypeÚcastÚget_getattr)r   r   ÚtypÚvalueÚattrÚ
inner_typeÚvalÚimpr   r   r   Úoptional_getattr.   s    r+   c                 C   sR   |j \}}|\}}|j}	|  ||||	¡}t |j|	|¡}
|  ||
¡}||||fƒS )z?
    Optional.__setattr__ => redirect to the wrapped type.
    )r   r"   r#   r   Ú	signaturer   Úget_setattr)r   r   r   r   r'   ZbasetyÚvaltyÚtargetr)   Útarget_typeZnewsigr*   r   r   r   Úoptional_setattr9   s    
r1   c           
   
   C   s¤   | j |||d�}t ||j¡}|   ||¡}| |¡�b\}}	|�& tj|_|  ||j|j|j¡|_W 5 Q R X |	� tj	|_t 
|jj¡|_W 5 Q R X W 5 Q R X | ¡ S )a«  
    The handling of optional->optional cast must be special cased for
    correct propagation of None value.  Given type T and U. casting of
    T? to U? (? denotes optional) should always succeed.   If the from-value
    is None, the None value the casted value (U?) should be None; otherwise,
    the from-value is casted to U. This is different from casting T? to U,
    which requires the from-value must not be None.
    ©r&   )r   r   r   r   Úif_elser   r#   Údatar"   r   Úget_null_valueÚ	_getvalue)
r   r   ÚfromtyÚtotyr)   ÚoptvalÚvalidbitZ	outoptvalÚis_validZis_not_validr   r   r   Úoptional_to_optionalH   s     

 ÿÿr<   c                 C   s>   |t jkr|  ||j¡S |  ||||j¡}|  ||j|¡S d S r
   )r   r   Úmake_optional_noner"   r#   Úmake_optional_value)r   r   r7   r8   r)   r   r   r   Úany_to_optionalg   s    
r?   c              	   C   sp   | j |||d�}t ||j¡}|j| |¡dd��$ d|jf }| j |t	|f¡ W 5 Q R X |  
||j|j|¡S )Nr2   F)Úlikelyzexpected %s, got None)r   r   r   r   Úif_thenr   r"   Ú	call_convÚreturn_user_excÚ	TypeErrorr#   r4   )r   r   r7   r8   r)   r9   r:   Úmsgr   r   r   Úoptional_to_anyp   s    rF   )ÚoperatorÚ
numba.corer   r   r   Únumba.core.imputilsr   r   r   r   r	   r   r   r!   Úis_r   ÚOptionalr+   r1   r<   ÚAnyr?   ÚBooleanrF   r   r   r   r   Ú<module>   s&   




