
    shY&                         S r SSKrSSKrSSKrSSKJr  SSKJr   " S S5      r " S S\R                  S	S
9r
 " S S5      r " S S\5      r " S S5      r\" 5       r " S S\S9rg)z[
This module contains utils for manipulating target configurations such as
compiler flags.
    N)MappingProxyType)utilsc                   R    \ rS rSrSrSrS r\S 5       r\S 5       r	\S 5       r
Srg	)
Option   z.An option to be used in ``TargetConfig``.
    _type_default_docc                (    Xl         X l        X0l        g)z
Parameters
----------
type :
    Type of the option value. It can be a callable.
    The setter always calls ``self._type(value)``.
default :
    The default value for the option.
doc : str
    Docstring for the option.
Nr   )selftypedefaultdocs       k/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/core/targetconfig.py__init__Option.__init__   s     
	    c                     U R                   $ N)r	   r   s    r   r   Option.type"   s    zzr   c                     U R                   $ r   )r
   r   s    r   r   Option.default&   s    }}r   c                     U R                   $ r   )r   r   s    r   r   
Option.doc*   s    yyr   )r
   r   r	   N)__name__
__module____qualname____firstlineno____doc__	__slots__r   propertyr   r   r   __static_attributes__ r   r   r   r      sM    +I       r   r   c                       \ rS rSrSrg)_FlagsStack/   r%   N)r   r   r   r    r$   r%   r   r   r'   r'   /   s    r   r'   flags)
stack_namec                   @    \ rS rSrSr\S 5       rS rS rS r	S r
Srg	)
ConfigStack3   zA stack for tracking target configurations in the compiler.

It stores the stack in a thread-local class attribute. All instances in the
same thread will see the same stack.
c                 J    U " 5       nU(       a  UR                  5       nU$ SnU$ )z8Get the TOS or return None if no config is set.
        N)top)clsr   r)   s      r   top_or_noneConfigStack.top_or_none9   s,     uHHJE  Er   c                 "    [        5       U l        g r   )r'   _stkr   s    r   r   ConfigStack.__init__E   s    M	r   c                 6    U R                   R                  5       $ r   )r4   r/   r   s    r   r/   ConfigStack.topH   s    yy}}r   c                 ,    [        U R                  5      $ r   )lenr4   r   s    r   __len__ConfigStack.__len__K   s    499~r   c                 8    U R                   R                  U5      $ )zWReturns a contextmanager that performs ``push(flags)`` on enter and
``pop()`` on exit.
)r4   enter)r   r)   s     r   r=   ConfigStack.enterN   s     yyu%%r   )r4   N)r   r   r   r    r!   classmethodr1   r   r/   r:   r=   r$   r%   r   r   r,   r,   3   s/    
 	 	"&r   r,   c                   $    \ rS rSrSrS rS rSrg)_MetaTargetConfigU   zMetaclass for ``TargetConfig``.

When a subclass of ``TargetConfig`` is created, all ``Option`` defined
as class members will be parsed and corresponding getters, setters, and
delters will be inserted.
c           	      2   0 n[        U5       H  nUR                  UR                  5        M      UR                  U R                  U5      5        [	        U5      U l        S nU R                  R                  5        H  u  p[        XU" X5      5        M     g)zInvoked when subclass is created.

Insert properties for each ``Option`` that are class members.
All the options will be grouped inside the ``.options`` class
attribute.
c                 \   ^ ^ U U4S jnU U4S jnU 4S jn[        X#UTR                  5      $ )Nc                 P   > U R                   R                  TTR                  5      $ r   )_valuesgetr   )r   nameoptions    r   getter=_MetaTargetConfig.__init__.<locals>.make_prop.<locals>.gettero   s    ||''fnn==r   c                 B   > TR                  U5      U R                  T'   g r   )r   rF   )r   valrH   rI   s     r   setter=_MetaTargetConfig.__init__.<locals>.make_prop.<locals>.setterr   s    %+[[%5T"r   c                     > U R                   T	 g r   rF   r   rH   s    r   delter=_MetaTargetConfig.__init__.<locals>.make_prop.<locals>.delteru   s    LL&r   )r#   r   )rH   rI   rJ   rN   rS   s   ``   r   	make_prop-_MetaTargetConfig.__init__.<locals>.make_propn   s'    >6' FFFJJ??r   N)reversedupdateoptionsfind_optionsr   itemssetattr)r0   rH   basesdctoptsbase_clsrU   rI   s           r   r   _MetaTargetConfig.__init__\   s~      !HKK(() (C$$S)*&t,
	@  KK--/LDCy67 0r   c                     UR                  5        VVs0 s H  u  p#[        U[        5      (       d  M  X#_M      snn$ s  snnf )zKReturns a new dict with all the items that are a mapping to an
``Option``.
)r[   
isinstancer   )r0   r^   kvs       r   rZ   _MetaTargetConfig.find_options}   s1     "%F
1f0EFFFs   ==r%   N)r   r   r   r    r!   r   rZ   r$   r%   r   r   rA   rA   U   s    8BGr   rA   c                       \ rS rSrS rSrg)_NotSetType   c                     g)Nz<NotSet>r%   r   s    r   __repr___NotSetType.__repr__   s    r   r%   N)r   r   r   r    rk   r$   r%   r   r   rh   rh      s    r   rh   c                       \ rS rSrSrS/rSS0rSS jrS rS	 r	S
 r
S rS rS r\4S jrS rS\4S jrS rS r\S\4S j5       rS\4S jr\S\S\4S j5       rSrg)TargetConfig   a  Base class for ``TargetConfig``.

Subclass should fill class members with ``Option``. For example:

>>> class MyTargetConfig(TargetConfig):
>>>     a_bool_option = Option(type=bool, default=False, doc="a bool")
>>>     an_int_option = Option(type=int, default=0, doc="an int")

The metaclass will insert properties for each ``Option``. For example:

>>> tc = MyTargetConfig()
>>> tc.a_bool_option = True  # invokes the setter
>>> print(tc.an_int_option)  # print the default
rF   wbitsiNc                     0 U l         Ub=  [        U[        5      (       d   eU R                   R                  UR                   5        gg)z
Parameters
----------
copy_from : TargetConfig or None
    if None, creates an empty ``TargetConfig``.
    Otherwise, creates a copy.
N)rF   rc   rn   rX   )r   	copy_froms     r   r   TargetConfig.__init__   sA      i6666LL	 1 12 !r   c                 B   / n/ nU R                    HM  nU S[        X5       3nU R                  U5      (       d  UR                  U5        M<  UR                  U5        MO     U R                  R
                  nU SSR                  U5       SSR                  U5       S3$ )N=(, z, [z]))rY   getattris_setappend	__class__r   join)r   argsdefsrd   msgclsnames         r   rk   TargetConfig.__repr__   s     ACq)*+C;;q>>C C   ..))!DIIdO,C		$/@CCr   c                 X    [        [        [        U R                  5       5      5      5      $ r   )hashtuplesortedvaluesr   s    r   __hash__TargetConfig.__hash__   s    E&/011r   c                 z    [        U[        5      (       a!  U R                  5       UR                  5       :H  $ [        $ r   )rc   rn   r   NotImplemented)r   others     r   __eq__TargetConfig.__eq__   s,    e\**;;=ELLN22!!r   c                 X    U R                    Vs0 s H  o[        X5      _M     sn$ s  snf )z)Returns a dict of all the values
        )rY   rx   )r   rd   s     r   r   TargetConfig.values   s(     .2\\:\74##\:::s   'c                 @    U R                  U5        XR                  ;   $ )zIs the option set?
        )_guard_optionrF   rR   s     r   ry   TargetConfig.is_set   s     	4 ||##r   c                 ^    U R                  U5        U R                  R                  US5        g)ztRemove the option by name if it is defined.

After this, the value for the option will be set to its default value.
N)r   rF   poprR   s     r   discardTargetConfig.discard   s&    
 	4 t$r   c                     U R                  U5        U R                  U5      (       dN  [        5       nU(       a&  UR                  5       n[	        X[        XA5      5        gU[        La  [	        XU5        ggg)a  Inherit flag from ``ConfigStack``.

Parameters
----------
name : str
    Option name.
default : optional
    When given, it overrides the default value.
    It is only used when the flag is not defined locally and there is
    no entry in the ``ConfigStack``.
N)r   ry   r,   r/   r\   rx   _NotSet)r   rH   r   cstkr/   s        r   inherit_if_not_setTargetConfig.inherit_if_not_set   sa     	4 {{4  =DhhjGC$67'G, ( !r   c                 $    [        U 5      " U 5      $ )zClone this instance.
        )r   r   s    r   copyTargetConfig.copy   s     Dz$r   returnc                     U R                  5        VVs/ s H  u  pU SU 3PM     nnnU R                  R                  nU SSR                  U5       S3$ s  snnf )zReturns a ``str`` that summarizes this instance.

In contrast to ``__repr__``, only options that are explicitly set will
be shown.
ru   rv   rw   ))_summary_argsr{   r   r|   )r   rd   re   r}   r   s        r   summaryTargetConfig.summary   s_     (,'9'9';<';tq1#Qqc
';<..))!DIIdO,A.. =s   Ac                 Z    XR                   ;  a  U< S[        U 5       3n[        U5      eg )Nz is not a valid option for )rY   r   
ValueError)r   rH   r   s      r   r   TargetConfig._guard_option   s0    ||#H7T
|DCS/! $r   c                     / n[        U R                  5       H[  nU R                  U   nU R                  U5      (       d  M*  [        X5      nUR                  U:w  d  MG  X$4nUR                  U5        M]     U$ )zreturns a sorted sequence of 2-tuple containing the
``(flag_name, flag_value)`` for flag that are set with a non-default
value.
)r   rY   ry   rx   r   rz   )r   r}   rd   optflagvalre   s         r   r   TargetConfig._summary_args  se    
 %A,,q/C{{1~~!$*;;')AKKN & r   c                    / nUR                  S5        UR                  U R                  R                  5        UR                  SS/5        U R                  R                  5        H:  u  p#UR                  U5        UR                  [        UR                  5      5        M<     SR                  U5      R                  5       $ )zMReturns a ``bytes`` object suitable for use as a dictionary for
compression.
numbaTrueFalse )
rz   r{   r   extendrY   r[   strr   r|   encode)r0   bufrd   r   s       r   _make_compression_dictionary)TargetConfig._make_compression_dictionary  s    
 

7

3==))*

FG$%kk'')FAJJqMJJs3;;'( * wws|""$$r   c                    U R                  5       n[        R                  " SU[        R                  S.U R                  D6nUR                  U R                  5       R                  5       5      /nUR                  UR                  5       5        [        R                  " SR                  U5      5      R                  5       $ )z6Return a string suitable for symbol mangling.
        )zdictlevelr   r%   )r   zlibcompressobjZ_BEST_COMPRESSION_ZLIB_CONFIGcompressr   r   rz   flushbase64	b64encoder|   decode)r   r   compr   s       r   get_mangle_stringTargetConfig.get_mangle_string#  s     113 5e43J3J 5"&"3"35 }}T\\^22456

4::< .5577r   mangledc                    S n[         R                  " SX!5      n[        R                  " U5      nU R	                  5       n[
        R                  " SSU0U R                  D6n/ nU(       a5  UR                  UR                  U5      5        UR                  nU(       a  M5  UR                  UR                  5       5        SR                  U5      R                  5       $ )zCReturns the demangled result from ``.get_mangle_string()``
        c                 V    [        [        SU R                  S5      SS  -   S5      5      $ )N0xr         )chrintgroup)xs    r   repl#TargetConfig.demangle.<locals>.repl5  s'    s4!''!*QR.0"566r   z_[a-zA-Z0-9][a-zA-Z0-9]r   r   r%   )resubr   	b64decoder   r   decompressobjr   rz   
decompressunconsumed_tailr   r|   r   )r0   r   r   	unescapedrawr   dcr   s           r   demangleTargetConfig.demangle0  s    
	7FF5tE	y)002@e@s/?/?@JJr}}S)*$$C c 	

288:xx}##%%r   rQ   r   )r   r   r   r    r!   r"   r   r   rk   r   r   r   ry   r   r   r   r   r   r   r   r   r?   bytesr   r   r   r$   r%   r   r   rn   rn      s     I S>L3D2";
$% 07 -, 
/ /"
 %U % %"83 8 &s &s & &r   rn   )	metaclass)r!   r   r   r   typesr   
numba.corer   r   ThreadLocalStackr'   r,   r   rA   rh   r   rn   r%   r   r   <module>r      sv    
   "  D	%((W 	& &D,G ,G^ 
 -v&. v&r   