ó
    „ñ:i+/  ã                   ó6  • S r SSKrSSKJr  SSKJr  SSKJrJrJ	r	  SSK
JrJr  SSKJrJrJrJrJrJrJrJrJr  SSKJr   " S	 S
5      rS rS rS rS rS r\S 5       r " S S5      r \" \RB                  \RD                  \RD                  5      S 5       r#g)z€Utilities for defining a mutable struct.

A mutable struct is passed by reference;
hence, structref (a reference to a struct).

é    N)Úcreate_struct_proxy)Únjit)ÚtypesÚimputilsÚcgutils)Údefault_managerÚmodels)	Úinfer_getattrÚlower_getattr_genericÚlower_setattr_genericÚlower_builtinÚboxÚunboxÚNativeValueÚ	intrinsicÚoverload)ÚAttributeTemplatec                   ó6   • \ rS rSrSrS rS rS rS rS r	Sr
g	)
Ú_Utilsé   z;Internal builder-code utils for structref definitions.
    c                 ó(   • Xl         X l        X0l        g)zˆ
Parameters
----------
context :
    a numba target context
builder :
    a llvmlite IRBuilder
struct_type : numba.core.types.StructRef
N)ÚcontextÚbuilderÚstruct_type)Úselfr   r   r   s       Ú_/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/numba/experimental/structref.pyÚ__init__Ú_Utils.__init__   s   € ð ŒØŒØ&Õó    c                 ó’   • U R                   nU R                  nU R                  n[        R                  " U5      " X#5      nXl        U$ )zKEncapsulate the MemInfo from a `StructRefPayload` in a `StructRef`
        )r   r   r   r   r   Úmeminfo)r   Úmir   r   r   Ústs         r   Únew_struct_refÚ_Utils.new_struct_ref+   s@   € ð —,‘,ˆØ—,‘,ˆØ×&Ñ&ˆä×(Ò(¨Ô5°gÓGˆØŒ
Øˆ	r   c                 ó€   • U R                   nU R                  nU R                  n[        R                  " U5      " X#US9$ )z6Return a helper for accessing a StructRefType
        ©Úvalue)r   r   r   r   r   )r   Úvalr   r   r   s        r   Úget_struct_refÚ_Utils.get_struct_ref6   s>   € ð —,‘,ˆØ—,‘,ˆØ×&Ñ&ˆä×*Ò*¨;Ô7Ø Cñ
ð 	
r   c                 óZ  • U R                   nU R                  nU R                  nU R                  U5      nUR                  nUR
                  R                  X65      nUR                  5       nUR                  U   n	U	R                  5       n
UR                  XzR                  5       5      nU$ )zDGet the data pointer to the payload from a `StructRefType`.
        )r   r   r   r*   r!   ÚnrtÚmeminfo_dataÚget_data_typeÚdata_model_managerÚget_value_typeÚbitcastÚ
as_pointer)r   r)   r   r   r   Ú	structvalr!   Údata_ptrÚvaltypeÚmodelÚ
alloc_types              r   Úget_data_pointerÚ_Utils.get_data_pointerA   s˜   € ð —,‘,ˆØ—,‘,ˆØ×&Ñ&ˆà×'Ñ'¨Ó,ˆ	Ø×#Ñ#ˆØ—;‘;×+Ñ+¨GÓ=ˆà×+Ñ+Ó-ˆØ×*Ñ*¨7Ñ3ˆØ×)Ñ)Ó+ˆ
Ø—?‘? 8×-BÑ-BÓ-DÓEˆØˆr   c                 óÆ   • U R                   nU R                  nU R                  nU R                  U5      nUR	                  5       n[
        R                  " U5      " X#US9nU$ )zFGet a getter/setter helper for accessing a `StructRefPayload`
        )Úref)r   r   r   r9   r/   r   r   )r   r)   r   r   r   r5   r6   Údatavals           r   Úget_data_structÚ_Utils.get_data_structR   s`   € ð —,‘,ˆØ—,‘,ˆØ×&Ñ&ˆà×(Ñ(¨Ó-ˆØ×+Ñ+Ó-ˆÜ×-Ò-¨gÔ6Ø (ñ
ˆð ˆr   )r   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r$   r*   r9   r>   Ú__static_attributes__© r   r   r   r      s    † ñò'ò	ò	
òõ"r   r   c                 ó€   ^ • [          " U 4S jS[        5      5       n[        T 5      S 5       n[        T 5      S 5       ng)z‚Define attributes on `struct_typeclass`.

Defines both setters and getters in jit-code.

This is called directly in `register()`.
c                   ó"   >• \ rS rSr Y rS rSrg)Ú*define_attributes.<locals>.StructAttributeéh   c                 óD   • X!R                   ;   a  UR                   U   nU$ g ©N)Ú
field_dict)r   ÚtypÚattrÚattrtys       r   Úgeneric_resolveÚ:define_attributes.<locals>.StructAttribute.generic_resolvel   s$   € Ø—~‘~Ó%ØŸ™¨Ñ-�Ø�ð &r   rF   N)r@   rA   rB   rC   ÚkeyrQ   rE   )Ústruct_typeclasss   €r   ÚStructAttributerI   h   s   ø† áˆõ	r   rU   c                 óž   • [        XU5      nUR                  U5      n[        Xd5      nUR                  U   n[        R
                  " XX‡5      $ rL   )r   r>   ÚgetattrrM   r   Úimpl_ret_borrowed)	r   r   rN   r)   rO   Úutilsr=   ÚretÚ	fieldtypes	            r   Ústruct_getattr_implÚ.define_attributes.<locals>.struct_getattr_implq   sI   € ä�w¨Ó-ˆØ×'Ñ'¨Ó,ˆÜ�gÓ$ˆØ—N‘N 4Ñ(ˆ	Ü×)Ò)¨'¸IÓKÐKr   c                 óB  • UR                   u  pVUu  px[        XU5      n	U	R                  U5      n
UR                  U   nU R	                  XXk5      n[        X¤5      nU R                  R                  XU5        U R                  R                  XU5        [        X¤U5        g rL   )
Úargsr   r>   rM   ÚcastrW   r-   ÚincrefÚdecrefÚsetattr)r   r   Úsigr_   rO   Ú	inst_typeÚval_typeÚinstancer)   rY   r=   Ú
field_typeÚcastedÚ	old_values                 r   Ústruct_setattr_implÚ.define_attributes.<locals>.struct_setattr_imply   s�   € à #§¡ÑˆØ‰ˆÜ�w¨Ó3ˆØ×'Ñ'¨Ó1ˆà×)Ñ)¨$Ñ/ˆ
Ø—‘˜g¨HÓAˆä˜GÓ*ˆ	à�‰×Ñ˜7¨fÔ5à�‰×Ñ˜7¨iÔ8ä�˜vÕ&r   N)r
   r   r   r   )rT   rU   r\   rk   s   `   r   Údefine_attributesrm   a   sU   ø€ ô ÷Ô+ó ó ðô Ð+Ó,ñLó -ðLô Ð+Ó,ñ'ó -ñ'r   c                 óÆ   ^• U [         R                  L a  [        S[         R                   35      eUR                  m[	        U 5      U4S j5       n[        U 5      S 5       ng)a|  Define the boxing & unboxing logic for `struct_type` to `obj_class`.

Defines both boxing and unboxing.

- boxing turns an instance of `struct_type` into a PyObject of `obj_class`
- unboxing turns an instance of `obj_class` into an instance of
  `struct_type` in jit-code.


Use this directly instead of `define_proxy()` when the user does not
want any constructor to be defined.
úcannot register c                 óš  >• [        UR                  UR                  U 5      nUR                  U5      nUR                  n[
        R                  " [
        R                  5      nUR                  Xe5      nUR                  R                  UR                  R                  T5      5      nUR                  R                  UR                  R                  U 5      5      n	UR                  R                  X‰U/5      n
UR                  R                  U5        UR                  R                  U	5        UR                  R                  U5        U
$ )z(
Convert a raw pointer to a Python int.
)r   r   r   r*   r!   r   ÚMemInfoPointerÚvoidptrr   ÚpyapiÚunserializeÚserialize_objectÚcall_function_objargsrb   )rN   r)   ÚcrY   Ú
struct_refr!   Úmip_typeÚboxed_meminfoÚctor_pyfuncÚty_pyobjÚresÚobj_ctors              €r   Úbox_struct_refÚ%define_boxing.<locals>.box_struct_refž   sñ   ø€ ô
 �q—y‘y !§)¡)¨SÓ1ˆØ×)Ñ)¨#Ó.ˆ
Ø×$Ñ$ˆä×'Ò'¬¯©Ó6ˆØŸ™˜hÓ0ˆà—g‘g×)Ñ)¨!¯'©'×*BÑ*BÀ8Ó*LÓMˆØ—7‘7×&Ñ& q§w¡w×'?Ñ'?ÀÓ'DÓEˆà�g‰g×+Ñ+Ø MÐ2ó
ˆð 	
�‰�‰�{Ô#Ø	�‰�‰�xÔ Ø	�‰�‰�}Ô%Øˆ
r   c                 óˆ  • UR                   R                  US5      n[        R                  " [        R                  5      nUR                  XC5      R                  n[        UR                  UR                  U 5      nUR                  U5      nUR                  5       nUR                   R                  U5        [        U5      $ )NÚ_meminfo)rs   Úobject_getattr_stringr   rq   rr   r   r(   r   r   r   r$   Ú	_getvaluerb   r   )	rN   Úobjrw   Úmi_objry   r"   rY   rx   Úouts	            r   Úunbox_struct_refÚ'define_boxing.<locals>.unbox_struct_refµ   s�   € à—‘×.Ñ.¨s°JÓ?ˆä×'Ò'¬¯©Ó6ˆà�W‰W�XÓ&×,Ñ,ˆä�q—y‘y !§)¡)¨SÓ1ˆØ×)Ñ)¨"Ó-ˆ
Ø×"Ñ"Ó$ˆà	�‰�‰�vÔÜ˜3ÓÐr   N)r   Ú	StructRefÚ
ValueErrorÚ_numba_box_r   r   )r   Ú	obj_classr   rˆ   r~   s       @r   Údefine_boxingrŽ   Œ   sd   ø€ ð ”e—o‘oÒ%ÜÐ+¬E¯O©OÐ+<Ð=Ó>Ð>à×$Ñ$€HäˆÓôó ðô, ˆ;Óñ ó ñ r   c                 ó*  • SR                  U5      nSn/ nU H  nUR                  SU SU 35        M     SU 3R                  U5      nSU S[        U5       SU S	U S
U S3n[        U[        S9n	[        X‰5        U	S   n
[        U 5      " U
5        g)zÉDefine the jit-code constructor for `struct_typeclass` using the
Python type `py_class` and the required `fields`.

Use this instead of `define_proxy()` if the user does not want boxing
logic defined.
z, z        zst.z = Ú
z

def ctor(z/):
    struct_type = struct_typeclass(list(zip(z, [z])))
    def impl(z)):
        st = new(struct_type)
        z#
        return st
    return impl
)rT   ÚnewÚctorN)ÚjoinÚappendÚlistÚdictr‘   Úexecr   )Úpy_classrT   ÚfieldsÚparamsÚindentÚinit_fields_bufÚkÚinit_fieldsÚsourceÚglbsr’   s              r   Údefine_constructorr¡   Å   sÂ   € ð �Y‰Y�vÓ€FØ€FØ€OÛˆØ×Ñ  Q C s¨1¨#˜Ö/ñ à�v�h�-×$Ñ$ _Ó5€Kð
Ø
ˆð -Ü-1°&«\¨N¸#¸f¸Xð FØˆXð 	à	ˆð ð€Fô Ð!1´sÑ;€DÜˆÔØ�‰<€DäˆXÔ�tÕr   c                 ó2   • [        XU5        [        X5        g)aÃ  Defines a PyObject proxy for a structref.

This makes `py_class` a valid constructor for creating a instance of
`struct_typeclass` that contains the members as defined by `fields`.

Parameters
----------
py_class : type
    The Python class for constructing an instance of `struct_typeclass`.
struct_typeclass : numba.core.types.Type
    The structref type class to bind to.
fields : Sequence[str]
    A sequence of field names.

Returns
-------
None
N)r¡   rŽ   )r˜   rT   r™   s      r   Údefine_proxyr£   å   s   € ô& �x°6Ô:ÜÐ"Õ-r   c                 óÄ   • U [         R                  L a  [        S[         R                   35      e[        R                  " U [
        R                  5        [        U 5        U $ )aP  Register a `numba.core.types.StructRef` for use in jit-code.

This defines the data-model for lowering an instance of `struct_type`.
This defines attributes accessor and mutator for an instance of
`struct_type`.

Parameters
----------
struct_type : type
    A subclass of `numba.core.types.StructRef`.

Returns
-------
struct_type : type
    Returns the input argument so this can act like a decorator.

Examples
--------

.. code-block::

    class MyStruct(numba.core.types.StructRef):
        ...  # the simplest subclass can be empty

    numba.experimental.structref.register(MyStruct)

ro   )r   rŠ   r‹   r   Úregisterr	   ÚStructRefModelrm   )r   s    r   r¥   r¥   ü   sL   € ð8 ”e—o‘oÒ%ÜÐ+¬E¯O©OÐ+<Ð=Ó>Ð>Ü×Ò˜[¬&×*?Ñ*?Ô@Ü�kÔ"ØÐr   c                 óN   ^^• SSK Jm  UR                  mUU4S jnT" U5      nX24$ )zùnew(struct_type)

A jit-code only intrinsic. Used to allocate an **empty** mutable struct.
The fields are zero-initialized and must be set manually after calling
the function.

Example:

    instance = new(MyStruct)
    instance.field = field_value
r   )Úimp_dtorc           	      ó(  >• U R                   TR                  5          nUR                  5       nU R                  U5      nU R                  R                  UU R                  [        R                  U5      T
" XR                  T5      5      nU R                  R                  X5      nUR                  X…R                  5       5      nUR                  [        R                  " U5      U5        U R!                  UT5      n	Xyl        U	R%                  5       $ rL   )r0   r/   r1   Úget_abi_sizeofr-   Úmeminfo_alloc_dtorÚget_constantr   ÚuintpÚmoduler.   r2   r3   Ústorer   Úget_null_valueÚmake_helperr!   r„   )r   r   Ú	signaturer_   r7   r8   Ú
alloc_sizer!   Údata_pointerÚinst_structr¨   re   s             €€r   ÚcodegenÚnew.<locals>.codegen0  sâ   ø€ à×*Ñ*¨9×+BÑ+BÓ+DÑEˆØ×)Ñ)Ó+ˆ
Ø×+Ñ+¨JÓ7ˆ
à—+‘+×0Ñ0ØØ× Ñ ¤§¡¨jÓ9Ù�WŸn™n¨iÓ8ó
ˆð
 —{‘{×/Ñ/°ÓAˆØ—‘ |×5JÑ5JÓ5LÓMˆð 	�‰”g×,Ò,¨ZÓ8¸,ÔGà×)Ñ)¨'°9Ó=ˆØ%Ôà×$Ñ$Ó&Ð&r   )Ú numba.experimental.jitclass.baser¨   Úinstance_type)Ú	typingctxr   r¶   rd   r¨   re   s       @@r   r‘   r‘     s,   ù€ õ :à×)Ñ)€Iö'ñ, �KÓ
 €CØˆ<Ðr   c                   óP   ^ • \ rS rSrSrSr\U 4S j5       rS r\	S 5       r
SrU =r$ )ÚStructRefProxyiJ  z¤A PyObject proxy to the Numba allocated structref data structure.

Notes
-----

* Subclasses should not define ``__init__``.
* Subclasses can override ``__new__``.
)Ú_typer‚   c                 ó>   >• [         TU ]  U 5      nXl        X#l        U$ )zïCalled by boxing logic, the conversion of Numba internal
representation into a PyObject.

Parameters
----------
ty :
    a Numba type instance.
mi :
    a wrapped MemInfoPointer.

Returns
-------
instance :
     a StructRefProxy instance.
)ÚsuperÚ__new__r½   r‚   )ÚclsÚtyr"   rg   Ú	__class__s       €r   rŒ   ÚStructRefProxy._numba_box_U  s#   ø€ ô" ‘7‘? 3Ó'ˆØŒØÔØˆr   c                 ót   ^ •  T R                   nU" U6 $ ! [         a    [        U 4S j5       nUT l          N'f = f)z¬Construct a new instance of the structref.

This takes positional-arguments only due to limitation of the compiler.
The arguments are mapped to ``cls(*args)`` in jit-code.
c                  ó   >• T" U 6 $ rL   rF   )r_   rÁ   s    €r   r’   Ú$StructRefProxy.__new__.<locals>.ctorv  s   ø€ á˜D�zÐ!r   )Ú_StructRefProxy__numba_ctorÚAttributeErrorr   )rÁ   r_   r’   s   `  r   rÀ   ÚStructRefProxy.__new__k  sL   ø€ ð		$à×#Ñ#ˆDñ �Tˆ{Ðøô ó 	$äô"ó ð"ð  $ˆCÖð	$ús   ƒ ” 7¶7c                 ó   • U R                   $ )z^Returns the Numba type instance for this structref instance.

Subclasses should NOT override.
)r½   )r   s    r   Ú_numba_type_ÚStructRefProxy._numba_type_}  s   € ð �z‰zÐr   rF   )r@   rA   rB   rC   rD   Ú	__slots__ÚclassmethodrŒ   rÀ   ÚpropertyrÌ   rE   Ú__classcell__)rÃ   s   @r   r¼   r¼   J  s:   ø† ñð &€Iàôó ðò*ð$ ñó ör   r¼   c                 ó²   • Uu  pEUR                   u  pg[        U5      " XUS9R                  n[        U5      " XUS9R                  n	UR                  SX‰5      $ )z~
Define the 'is' operator for structrefs by comparing the memory addresses.
This is the identity check for structref objects.
r'   z==)r_   r   r!   Úicmp_unsigned)
r   r   rd   r_   ÚaÚbÚatyÚbtyÚa_ptrÚb_ptrs
             r   Ústructref_isrÚ   †  sW   € ð �D€AØ�x‰x�H€CÜ Ô$ W¸QÑ?×GÑG€EÜ Ô$ W¸QÑ?×GÑG€EØ× Ñ   uÓ4Ð4r   )$rD   ÚoperatorÚnumba.core.cgutilsr   Únumbar   Ú
numba.corer   r   r   Únumba.core.datamodelr   r	   Únumba.core.extendingr
   r   r   r   r   r   r   r   r   Únumba.core.typing.templatesr   r   rm   rŽ   r¡   r£   r¥   r‘   r¼   Úis_rŠ   rÚ   rF   r   r   Ú<module>rã      s¥   ðñó Ý 2Ý ß /Ñ /ß 8÷
÷ 
õ 
õ :÷Dñ DòN('òV6 òrò@.ò. ðF ñ'ó ð'÷T9ñ 9ñx ˆx�|‰|˜UŸ_™_¨e¯o©oÓ>ñ	5ó ?ñ	5r   