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&   




