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   

