
    J/PhC                     x    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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                 4    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                  }|                    ||           |                    ||                    d          |gd          }|                    ||           |                    |          S )Nr   T)inbounds)r   typestoregepload)	contextbuilder	signatureargstupidxvalstackoffptrs	            Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/cpython/unsafe/tuple.pycodegenztuple_setitem.<locals>.codegen   s~    S#GSX..c5!!!USXXa[[#$6FFc6"""||E"""    )dtype)	typingctxr   r   r   r   sigs         r   tuple_setitemr      s2    # # # #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|R  }|                     t           j                  }|                               } |          |g}	|                     ||||	          }
|
S )Nc           	      l    |}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AA	,,UZ8800<<!k$''5
&&wiLL
r   )	
isinstancer   IntegerLiteralr   RequireLiteralValueintliteral_valueUniTupleslice2_type)tyctxszr   r   r3   r4   s       @@r   build_full_slice_tupler>   $   s     b%.// -(,,,r  De&7tDD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   sc     c5?++ +"" "%c***
#c((C  <r   N)__doc__
numba.corer   r   r   numba.core.cgutilsr   numba.core.extendingr   r   r>   rE   rA   r   r   <module>rJ      s    
 - , , , , , , , , , * * * * * * * * * * * *   0   :     r   