
    xKgC                     d    d Z ddlmZmZmZ ddlmZ ddlmZ ed        Z	ed        Z
ed        Zy)	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                 8    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                     |\  }}}t        ||j                        }|j                  ||       |j                  ||j                  d      |gd      }|j                  ||       |j	                  |      S )Nr   T)inbounds)r   typestoregepload)	contextbuilder	signatureargstupidxvalstackoffptrs	            ^/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/cpython/unsafe/tuple.pycodegenztuple_setitem.<locals>.codegen   si    S#GSXX.c5!USXXa[#$6Fc6"||E""    )dtype)	typingctxr   r   r   r   sigs         r   tuple_setitemr      s%    # c3		
"C<r   c                     t        |t        j                        st        j                  |      t        |j                        t        j                  t        j                         |      }fd}||fS )z"Creates a sz-tuple of full slices.)r   countc                     d }t         j                  g}t        j                  g| }| j	                  t         j                        }| j                        } |      |g}	| j                  ||||	      }
|
S )Nc           	      X    |}t        |       D ]  }t        ||t        d d             } |S )N)ranger   slice)lengthempty_tupleoutis       r   implz5build_full_slice_tuple.<locals>.codegen.<locals>.impl/   s/    C6]#CE$,=> #Jr   )r   intpr   r   get_value_typeget_constant_undefcompile_internal)r   r   r   r   r)   inner_argtypes	inner_sigll_idx_typer&   
inner_argsressize
tuple_types              r   r   z'build_full_slice_tuple.<locals>.codegen.   s{    	  **j1$$ZA.A	,,UZZ800<!$'5
&&wiL
r   )	
isinstancer   IntegerLiteralr   RequireLiteralValueintliteral_valueUniTupleslice2_type)tyctxszr   r   r3   r4   s       @@r   build_full_slice_tupler>   $   sf     b%../((,,r De&7&7tDJ
R.C" <r   c                     t        |t        j                        sd| }t        j                  |       ||      }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                     |d   S )Nr    )r   r   r   r   s       r   r   z$unpack_single_tuple.<locals>.codegenR   s    Awr   )r5   r   	BaseTupler   UnsupportedError)r<   r   msgr   r   s        r   unpack_single_tuplerE   B   sL     c5??+5"%%c**
c(C<r   N)__doc__
numba.corer   r   r   numba.core.cgutilsr   numba.core.extendingr   r   r>   rE   rA   r   r   <module>rJ      sT   
 - , * *  0  :  r   