U
    |eC                     @   sX   d Z ddlmZmZmZ ddlmZ ddlmZ edd Z	edd Z
ed	d
 ZdS )z
This file provides internal compiler utilities that support certain special
operations with tuple and workarounds for limitations enforced in userland.
    )typestypingerrors)alloca_once)	intrinsicc                 C   s   dd }||||j }||fS )a  Return a copy of the tuple with item at *idx* replaced with *val*.

    Operation: ``out = tup[:idx] + (val,) + tup[idx + 1:]

    **Warning**

    - No boundchecking.
    - The dtype of the tuple cannot be changed.
      *val* is always cast to the existing dtype of the tuple.
    c           	      S   sR   |\}}}t ||j}||| |j||d|gdd}||| ||S )Nr   T)inbounds)r   typestoregepload)	contextbuilder	signatureargstupidxvalstackZoffptr r   W/var/www/website-v5/atlas_env/lib/python3.8/site-packages/numba/cpython/unsafe/tuple.pycodegen   s    
ztuple_setitem.<locals>.codegen)dtype)	typingctxr   r   r   r   sigr   r   r   tuple_setitem   s    	r   c                    sN   t |tjst|t|j tjtj d|} fdd}||fS )z"Creates a sz-tuple of full slices.)r   countc                    sX   dd }t jg}tjf| }| t j}| }| |g}	| ||||	}
|
S )Nc                 S   s(   |}t | D ]}t||td d }q|S )N)ranger   slice)lengthempty_tupleoutir   r   r   impl/   s    z5build_full_slice_tuple.<locals>.codegen.<locals>.impl)r   intpr   r   get_value_typeget_constant_undefcompile_internal)r   r   r   r   r"   Zinner_argtypesZ	inner_sigZll_idx_typer   
inner_argsressizeZ
tuple_typer   r   r   .   s    

z'build_full_slice_tuple.<locals>.codegen)	
isinstancer   IntegerLiteralr   RequireLiteralValueintliteral_valueUniTupleslice2_type)tyctxszr   r   r   r)   r   build_full_slice_tuple$   s    

r4   c                 C   s8   t |tjs d| }t|||}dd }||fS )aR  This exists to handle the situation y = (*x,), the interpreter injects a
    call to it in the case of a single value unpack. It's not possible at
    interpreting time to differentiate between an unpack on a variable sized
    container e.g. list and a fixed one, e.g. tuple. This function handles the
    situation should it arise.
    zBOnly tuples are supported when unpacking a single item, got type: c                 S   s   |d S )Nr   r   )r   r   r   r   r   r   r   r   R   s    z$unpack_single_tuple.<locals>.codegen)r+   r   	BaseTupler   UnsupportedError)r2   r   msgr   r   r   r   r   unpack_single_tupleB   s    	

r8   N)__doc__
numba.corer   r   r   numba.core.cgutilsr   numba.core.extendingr   r   r4   r8   r   r   r   r   <module>   s   

