
    sh                     J    S SK Jr  S SKrS SKJrJr  S SKJr   " S S\5      r	g)    )
ModuleTypeN)ConstantInferenceError
NumbaError)irc                   F    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rSrg)ConstantInference	   z
A constant inference engine for a given interpreter.
Inference inspects the IR to try and compute a compile-time constant for
a variable.

This shouldn't be used directly, instead call Interpreter.infer_constant().
c                 H    [         R                  " U5      U l        0 U l        g N)weakrefproxy_func_ir_cache)selffunc_irs     e/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/core/consts.py__init__ConstantInference.__init__   s      g.    Nc                 ^   XR                   ;  a!   SU R                  U5      4U R                   U'   U R                   U   u  pEU(       a  U$ Uu  p6[        U[        5      (       a  U" USU06eU" U6 e! [         a1  nSUR                  UR                  44U R                   U'    SnANvSnAff = f)z
Infer a constant value for the given variable *name*.
If no value can be inferred, numba.errors.ConstantInferenceError
is raised.
TFNloc)r   	_do_inferr   	__class__args
issubclassr   )r   namer   excsuccessvalr   s          r   infer_constant ConstantInference.infer_constant   s     {{"G%)4>>$+?$@D!
 {{4(JIC#z**4)S))4j  * G &+S]]CHH,E$FD!Gs    A1 1
B,;'B''B,c                     [        SU< 3S S9e)Nz%Constant inference not possible for: r   )r   )r   r   s     r   _failConstantInference._fail/   s     %9<>DJ 	Jr   c                    [        U[        5      (       d  [        SU< 35      e U R                  R	                  U5      n UR                  5       nU$ ! [
         a    [        SU< 35      ef = f! [         aG    [        U[        R                  5      (       a  U R                  U5      s $ U R                  U5         W$ f = f)Nz%infer_constant() called with non-str zno single definition for )
isinstancestr	TypeErrorr   get_definitionKeyErrorr   r    r   Expr_infer_exprr$   )r   r   defnconsts       r   r   ConstantInference._do_infer8   s    $$$#& ' '	9==//5D	'')E
   	9(1579 9	9
 & 	$((''--JJt		s#   A A1 A.1:C-CCc                 r  ^ ^ TR                   S:X  a@  T R                  TR                  R                  TR                  S9nT R                  UT5      $ TR                   S:X  a@  T R                  TR                  R                  TR                  S9nT R                  UT5      $ TR                   S:X  a?  TR                   Vs/ s H'  nT R                  UR                  TR                  S9PM)     sn$ TR                   S:X  a   [        UU 4S jTR                   5       5      $ T R                  T5        g s  snf )Ncallr#   getattr
build_listbuild_tuplec              3   l   >#    U  H)  nTR                  UR                  TR                  S 9v   M+     g7f)r#   N)r    r   r   ).0iexprr   s     r   	<genexpr>0ConstantInference._infer_expr.<locals>.<genexpr>U   s2      %# HI,,QVV,B#s   14)opr    funcr   r   _infer_callvalue_infer_getattritemstupler$   )r   r9   r=   r?   r8   s   ``   r   r-   ConstantInference._infer_exprI   s   77f&&tyy~~488&DD##D$//WW	!''

TXX'FE&&ud33WW$JJ  CDD''DHH'=   WW% %% % %

4 s   .D4c                    UR                   (       d  UR                  (       a  U R                  U5        U[        4;   n[	        U[
        5      =(       a    [        U[        5      nU(       d  U(       aZ  UR                   Vs/ s H&  oPR                  UR                  UR                  S9PM(     nnU(       a  U" U6 $ U(       a  X4$  S5       eU R                  U5        g s  snf )Nr#   Unreachable)kwsvarargr$   slicer'   typer   BaseExceptionr   r    r   r   )r   r=   r9   _slice_excar   s          r   r>   ConstantInference._infer_callY   s    88t{{JJt%!$%I*T=*ITII CD''DHH'=  T{"
 z!'-'q

4s   -Cc                     [        U[        [        45      (       a   [        XR                  5      $ U R                  U5        g ! [
         a     Nf = fr   )r'   r   rI   r3   attrAttributeErrorr$   )r   r?   r9   s      r   r@    ConstantInference._infer_getattro   sJ    ej$/00uii00 	

4 " s   A 
AA)r   r   r   )__name__
__module____qualname____firstlineno____doc__r   r    r$   r   r-   r>   r@   __static_attributes__ r   r   r   r   	   s+    !.J" ,r   r   )
typesr   r   numba.core.errorsr   r   
numba.corer   objectr   rY   r   r   <module>r^      s      @ m mr   