
    sh):                     2   S r SSKrSSKrSSKrSSKrSSKJr  SSKJrJ	r	J
r
Jr  SSKJr   " S S\5      r " S S	\5      r\" S
5      r\R$                  r\R(                  r\R*                  r\R,                  r\R.                  r\R0                  r\R2                  rS rS rS rS rS rS r " S S\5      r  " S S\5      r!S!S jr"S r#S r$S r%\RL                  " SS5      r'\RP                  S 5       r)S r*S r+S r,\RP                  S"S j5       r-S  r.g)#z<
Utilities to simplify the boilerplate for native lowering.
    N)Enum)typingtypesutilscgutils)BaseRegistryLoaderc                   X    \ rS rSrSrSS jrS rS rS rS r	S r
S	 rS
 rS rS rSrg)Registry   z7
A registry of function and attribute implementations.
c                 V    Xl         / U l        / U l        / U l        / U l        / U l        g N)name	functionsgetattrssetattrscasts	constants)selfr   s     g/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/core/imputils.py__init__Registry.__init__   s*    	
    c                    ^ ^^ UUU 4S jnU$ )a  
Decorate an implementation of *func* for the given argument types.
*func* may be an actual global function object, or any
pseudo-function supported by Numba, such as "getitem".

The decorated implementation has the signature
(context, builder, sig, args).
c                 D   > TR                   R                  U TT45        U $ r   )r   append)implargtysfuncr   s    r   decorate Registry.lower.<locals>.decorate%   s!    NN!!4v"67Kr    )r   r   r   r   s   ``` r   lowerRegistry.lower   s    	 r   c                 R    U" XU5      nUR                  XcUR                  45        U$ r   )r   	signature)r   r   tyattr	impl_list	decorator	real_impls          r   _decorate_attrRegistry._decorate_attr*   s,    d-	)9+>+>?@r   c                    ^ ^^ UU U4S jnU$ )z
Decorate an implementation of __getattr__ for type *ty* and
the attribute *attr*.

The decorated implementation will have the signature
(context, builder, typ, val).
c                 J   > TR                  U TTTR                  [        5      $ r   )r+   r   _decorate_getattrr   r'   r   r&   s    r   r   (Registry.lower_getattr.<locals>.decorate7   %    &&tRt}}'8: :r   r!   r   r&   r'   r   s   ``` r   lower_getattrRegistry.lower_getattr/       	: r   c                 &    U R                  US5      $ )a
  
Decorate the fallback implementation of __getattr__ for type *ty*.

The decorated implementation will have the signature
(context, builder, typ, val, attr).  The implementation is
called for attributes which haven't been explicitly registered
with lower_getattr().
N)r4   r   r&   s     r   lower_getattr_genericRegistry.lower_getattr_generic<        !!"d++r   c                    ^ ^^ UU U4S jnU$ )z
Decorate an implementation of __setattr__ for type *ty* and
the attribute *attr*.

The decorated implementation will have the signature
(context, builder, sig, args).
c                 J   > TR                  U TTTR                  [        5      $ r   )r+   r   _decorate_setattrr0   s    r   r   (Registry.lower_setattr.<locals>.decorateO   r2   r   r!   r3   s   ``` r   lower_setattrRegistry.lower_setattrG   r6   r   c                 &    U R                  US5      $ )a  
Decorate the fallback implementation of __setattr__ for type *ty*.

The decorated implementation will have the signature
(context, builder, sig, args, attr).  The implementation is
called for attributes which haven't been explicitly registered
with lower_setattr().
N)r@   r8   s     r   lower_setattr_genericRegistry.lower_setattr_genericT   r;   r   c                    ^ ^^ UU U4S jnU$ )z
Decorate the implementation of implicit conversion between
*fromty* and *toty*.

The decorated implementation will have the signature
(context, builder, fromty, toty, val).
c                 F   > TR                   R                  U TT445        U $ r   )r   r   )r   fromtyr   totys    r   r   %Registry.lower_cast.<locals>.decorateg   s#    JJtfd^45Kr   r!   )r   rG   rH   r   s   ``` r   
lower_castRegistry.lower_cast_   s    	 r   c                    ^ ^ U U4S jnU$ )z
Decorate the implementation for creating a constant of type *ty*.

The decorated implementation will have the signature
(context, builder, ty, pyval).
c                 D   > TR                   R                  U T445        U $ r   )r   r   )r   r   r&   s    r   r   )Registry.lower_constant.<locals>.decorates   s     NN!!4"-0Kr   r!   )r   r&   r   s   `` r   lower_constantRegistry.lower_constantl   s    	 r   c                 "    SU R                    S3$ )NzLowering Registry<>)r   r   s    r   __repr__Registry.__repr__x   s    #DII;a00r   )r   r   r   r   r   r   N)unspecified)__name__
__module____qualname____firstlineno____doc__r   r"   r+   r4   r9   r@   rC   rJ   rO   rT   __static_attributes__r!   r   r   r
   r
      s9    
	,	,
1r   r
   c                       \ rS rSrSrSrSrg)RegistryLoader|   z.
An incremental loader for a target registry.
)r   r   r   r   r   r!   N)rW   rX   rY   rZ   r[   registry_itemsr\   r!   r   r   r^   r^   |   s     QNr   r^   builtin_registryc                 H   ^ U mUb  U4S jnOU4S jnU4Ul         X#l        U$ )Nc                    > T" XX#5      $ r   r!   contextbuildertypvaluer'   r*   s        r   res_decorate_getattr.<locals>.res   s    Ws::r   c                    > T" XX#U5      $ r   r!   rd   s        r   ri   rj      s    Ws4@@r   )r%   r'   r   r&   r'   ri   r*   s       @r   r/   r/      s.    I	;	A ECMHJr   c                 f   ^ U mUb  U4S jnOU4S jnU[         R                  4Ul        X#l        U$ )Nc                    > T" XX#5      $ r   r!   re   rf   sigargsr'   r*   s        r   ri   _decorate_setattr.<locals>.res   s    Ws99r   c                    > T" XX#U5      $ r   r!   ro   s        r   ri   rr      s    Ws$??r   )r   Anyr%   r'   rl   s       @r   r>   r>      s4    I	:	@ OCMHJr   c                    [        UR                  [        R                  5      (       a  UR                  R                  nU R                  X5      n[        R                  " X5      nUR                  UR                  UR                  5      5         U R                  XU5      nUR                  X5        S S S 5        UR                  U5      nU$ ! , (       d  f       N!= fr   )
isinstancereturn_typer   Optionaltypemake_optional_noner   alloca_once_valueif_thennot_is_nonemake_optional_valuestoreload)	re   rf   rp   statusretval
value_typeoptional_none	retvalptroptional_values	            r   fix_returning_optionalr      s    #//5>>22__))
227G--gE	__W\\&..9:$88VN MM.4	 ;
 i(M ;:s   $C
Cc                 V   ^  U 4S jnT R                   Ul        [        U5      Ul        U$ )z;
A wrapper inserting code calling Numba-compiled *fndesc*.
c                   > U R                  UR                  T5      nU R                  R                  XTR                  TR
                  U5      u  pV[        R                  " XR                  5         U R                  R                  X5        S S S 5        UR                  TR                  :X  d   e[        XX%U5      nUR                  U R                  UR                  5      :w  a1  Sn[        UR                  UR                  UR                  5      5      e[!        XTR                  U5      $ ! , (       d  f       N= f)Nz$function returned {0} but expect {1})declare_functionmodule	call_convcall_functionrestypeargtypesr   if_unlikelyis_errorreturn_status_propagaterw   r   ry   get_value_type	TypeErrorformatimpl_ret_new_ref)	re   rf   rp   rq   r   r   r   msgfndescs	           r   impuser_function.<locals>.imp   s    ''? **886>>6??DB  //:55gF ;&..000'#vN;;'00AA8CCJJv{{COODEE&..&II ;:s   2D00
D>)r   r%   tuplelibs)r   r   r   s   `  r   user_functionr      s&    
J" OOCMT{CHJr   c                 4   ^  U 4S jn[        U5      Ul        U$ )z<
A wrapper inserting code calling Numba-compiled *gendesc*.
c                    > U R                  UR                  T5      nU R                  R                  XTR                  TR
                  U5      u  pVXV4$ r   )r   r   r   r   r   r   )re   rf   rp   rq   r   r   r   gendescs          r   r   user_generator.<locals>.imp   sO    ''@ **887??G,<,<dD ~r   )r   r   )r   r   r   s   `  r   user_generatorr      s    
 T{CHJr   c                    ^ U4S jnU$ )z`
Decorator a given class as implementing *iterator_type*
(by providing an `iternext()` method).
c                    >^ ^ T R                   m[        [        R                  5      U U4S j5       n[	        ST5      " U5        T $ )Nc                 0   > Uu  nT" XU5      nT" X`X5      $ r   r!   )	re   rf   rp   rq   resultrh   iterobjclsiternexts	          r   iternext_wrapper8iterator_impl.<locals>.wrapper.<locals>.iternext_wrapper   s#    HU'E2GGg>>r   r   )r   iternext_implRefTypeBORROWEDlower_builtin)r   r   r   iterator_types   ` @r   wrapperiterator_impl.<locals>.wrapper   s@    <<	w''	(	? 
)	?
 	j-01AB
r   r!   )iterable_typer   r   s    ` r   iterator_implr      s     Nr   c                   D    \ rS rSrSrSrS rS rSS jrS r	S r
S	 rS
rg)_IternextResult   zV
A result wrapper for iteration, passed by iternext_impl() into the
wrapped function.
_context_builder_pairobjc                 (    Xl         X l        X0l        g r   r   )r   re   rf   pairobjs       r   r   _IternextResult.__init__  s    r   c                 v    U R                   R                  [        R                  S5      U R                  l        g)z!
Mark the iterator as exhausted.
FNr   get_constantr   booleanr   secondrS   s    r   set_exhausted_IternextResult.set_exhausted	  s%      $}}99%--Or   c                     US;   a*  U R                   R                  [        R                  U5      nXR                  l        g)zl
Mark the iterator as valid according to *is_valid* (which must
be either a Python boolean or a LLVM inst).
)FTNr   )r   is_valids     r   	set_valid_IternextResult.set_valid  s0    
 }$}}11%--JH'r   c                 $    XR                   l        g)z@
Mark the iterator as yielding the given *value* (a LLVM inst).
Nr   first)r   rh   s     r   yield__IternextResult.yield_  s     $r   c                     U R                   R                  U R                  [        R                  U R
                  R                  5      $ )z.
Return whether the iterator is marked valid.
)r   get_argument_valuer   r   r   r   r   rS   s    r   r   _IternextResult.is_valid  s7     }}//05040D0DF 	Fr   c                 .    U R                   R                  $ )z.
Return the iterator's yielded value, if any.
r   rS   s    r   yielded_value_IternextResult.yielded_value&  s     }}"""r   )r   r   r   N)T)rW   rX   rY   rZ   r[   	__slots__r   r   r   r   r   r   r\   r!   r   r   r   r      s.     5I 
P($F#r   r   c                   *    \ rS rSrSr Sr Sr SrSrg)r   i,  z
Enumerate the reference type
         r!   N)	rW   rX   rY   rZ   r[   NEWr   	UNTRACKEDr\   r!   r   r   r   r   ,  s+     C H Ir   r   c                 h   ^  T [          Vs/ s H  oPM     sn;  a  [        S5      eU 4S jnU$ s  snf )a~  
Wrap the given iternext() implementation so that it gets passed
an _IternextResult() object easing the returning of the iternext()
result pair.

ref_type: a numba.targets.imputils.RefType value, the reference type used is
that specified through the RefType enum.

The wrapped function will be called with the following signature:
    (context, builder, sig, args, iternext_result)
z3ref_type must be an enum member of imputils.RefTypec                    >^  U U4S jnU$ )Nc                 L  > UR                   nU R                  X5      nT" XX#[        XU5      5        T[        R                  :X  a  [
        nOAT[        R                  :X  a  [        nO&T[        R                  :X  a  [        nO[        S5      eU" XXER                  5       5      $ )NzUnknown ref_type encountered)rw   make_helperr   r   r   r   r   impl_ret_borrowedr   impl_ret_untracked
ValueError	_getvalue)	re   rf   rp   rq   	pair_typer   impl_retr   ref_types	          r   r   -iternext_impl.<locals>.outer.<locals>.wrapperM  s    I))'=G3':<7;;&+W---,W...- !?@@G$-/@/@/BD Dr   r!   )r   r   r   s   ` r   outeriternext_impl.<locals>.outerL  s    	D r   )r   r   )r   xr   s   `  r   r   r   =  s9     7+7a7++NOO" L) ,s   /c                 z    [         R                  " UR                  U5      nU R                  SU5      nU" X45      $ )z{
Call the `getiter()` implementation for the given *iterable_type*
of value *val*, and return the corresponding LLVM inst.
getiter)r   r%   r   get_function)re   rf   r   valgetiter_siggetiter_impls         r   call_getiterr   `  s;    
 ""=#>#>NK''	;?L((r   c                    UR                   n[        R                  " U[        R                  5      n[        R
                  " XR5      nU R                  SU5      nU" X45      nU R                  XU5      n[        XU5      $ )z
Call the `iternext()` implementation for the given *iterator_type*
of value *val*, and return a convenience _IternextResult() object
reflecting the results.
r   )	
yield_typer   Pairr   r   r%   r   r   r   )	re   rf   r   r   itemtyr   iternext_sigr   r   s	            r   call_iternextr   j  sp     %%F

65==1I##I=L((\BM

(C!!'c:G7W55r   c                      U R                  [        [        R                  " [        R
                  U5      5      nU" X45      $ ! [         a     gf = f)zR
Call len() on the given value.  Return None if len() isn't defined on
this type.
N)r   lenr   r%   r   intpNotImplementedError)re   rf   r&   r   len_impls        r   call_lenr   y  sM    
)''V-=-=ejj"-NO ((  s   9A 
AA_ForIterLoop)rh   do_breakc              #     ^^	#    UR                   n[        U TX#5      nTR                  S5      nTR                  S5      m	U	U4S jnTR                  U5        TR	                  U5         [        U TXE5      nTR                  TR                  UR                  5       5      SS9   TR                  T	5        SSS5        [        UR                  5       U5      v   TR                  U5        SSS5        TR                  T	5        U R                  (       a  U R                  R                  TXE5        gg! , (       d  f       N= f! , (       d  f       N_= f7f)z
Simulate a for loop on the given iterable.  Yields a namedtuple with
the given members:
- `value` is the value being yielded
- `do_break` is a callable to early out of the loop
zfor_iter.bodyzfor_iter.endc                  (   > TR                  T 5        g r   )branch)bb_endrf   s   r   r   for_iter.<locals>.do_break  s    vr   F)likelyN)r   r   append_basic_blockr  
goto_blockr   r|   r}   r   r   r   position_at_end
enable_nrtnrtdecref)
re   rf   r   r   r   itervalbb_bodyr   ri   r  s
    `       @r   for_iterr    s     "//M7G]@G((9G''7F NN7			G	$GWmE__W\\#,,.9%_HNN6" I3,,.99w 
% F#7M;  IH 
%	$s7   A%E);E$D365E+AE3
E	=E
EEc                     U$ )z-
The implementation returns a new reference.
r!   ctxrf   rettyrets       r   r   r     	     Jr   c                 `    U R                   (       a  U R                  R                  XU5        U$ )z
The implementation returns a borrowed reference.
This function automatically incref so that the implementation is
returning a new reference.
)r
  r  increfr  s       r   r   r     s"     ~~ws+Jr   c                     U$ )z&
The return type is not a NRT object.
r!   r  s       r   r   r     r  r   c              #      #    SSK Jn  U R                  nUR                  X5      U l         Sv   X0l        g! X0l        f = f7f)z/
Temporarily change the context's error model.
r   )callconvN)
numba.corer  error_modelcreate_error_model)re   
model_namer  old_error_models       r   force_error_modelr     s<     
 $))O"55jJG.-os   )A7 A?Ac                      [        S5      e)zHA stub for use internally by Numba when a call is emitted
on a TypeRef.
z%This function should not be executed.)r   )rq   kwargss     r   numba_typeref_ctorr#    s     E
FFr   r   )numpy)/r[   collections
contextlibinspect	functoolsenumr   r  r   r   r   r   numba.core.typing.templatesr   objectr
   r^   ra   r"   r   r4   r9   r@   rC   rJ   rO   r/   r>   r   r   r   r   r   r   r   r   r   r   
namedtupler   contextmanagerr  r   r   r   r   r#  r!   r   r   <module>r.     sK  
      4 4 :i1v i1XQ' Q ./  && ..(>>  ..(>> ((
!006",-#f -#^d " F)6
) %%n&;= < << . .Gr   