o
    Y۷iV                     @   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      t jS N)r   true_bitcontextbuildersigargs r   I/home/ubuntu/vllm_env/lib/python3.10/site-packages/numba/core/optional.pyalways_return_true_impl
      r   c                 C   r
   r   )r   	false_bitr   r   r   r   always_return_false_impl   r   r   c                 C   sj   |j \}}|\}}|tjkr||}}||}}|}|}	| |||	}
|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rtylvalrvalopt_type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   r0   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,   basetyvaltytargetr.   target_typenewsigr/   r   r   r   optional_setattr9   s   
r8   c           
   	   C   s   | j |||d}t||j}|  ||}||W\}}	| tj|_| ||j|j|j|_W d   n1 s:w   Y  |	 tj	|_t
|jj|_W d   n1 sXw   Y  W d   | S W d   | S 1 stw   Y  | 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+   N)r   r   r   r   if_elser   r(   datar'   r   get_null_value	_getvalue)
r   r   fromtytotyr.   optvalvalidbit	outoptvalis_validis_not_validr   r   r   optional_to_optionalH   s.   



rE   c                 C   s:   |t jkr| ||jS | ||||j}| ||j|S r   )r   r   make_optional_noner'   r(   make_optional_value)r   r   r>   r?   r.   r   r   r   any_to_optionalg   s   
rH   c                 C   s   | j |||d}t||j}|j||dd d|jf }| j|t	|f W d    n1 s3w   Y  | 
||j|j|S )Nr9   F)likelyzexpected %s, got None)r   r   r   r   if_thenr   r'   	call_convreturn_user_exc	TypeErrorr(   r;   )r   r   r>   r?   r.   r@   rA   msgr   r   r   optional_to_anyp   s   rO   )operator
numba.corer   r   r   numba.core.imputilsr   r   r   r   r	   r   r   r&   is_r   Optionalr0   r8   rE   AnyrH   BooleanrO   r   r   r   r   <module>   s(    




