Ë
    øÇ:jk3  ã                   ó\  — d dl Z d dlZd dlZd dlmZ d dlmZmZ d dl	m
Z
 d„ Z ed«      Z ed«      Z ed«      Z ed«      Z ed	«      Z ed
«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z  ed«      Z! ed«      Z" ed«      Z# ed«      Z$ ed«      Z% ed«      Z& ed «      Z' ed!«      Z( ed"«      Z) ed#«      Z* ed$«      Z+ ed%«      Z, G d&„ d'«      Z- G d(„ d)«      Z. G d*„ d+e/«      Z0 G d,„ d-e/«      Z1d.„ Z2e jf                  dd/ d0k\  re2nejh                  Z5 e0«       Z6d1„ Z7d2„ Z8 G d3„ d4e/«      Z9 G d5„ d6e/«      Z:d7„ Z;d8„ Z< G d9„ d:e/«      Z=y);é    N)Ú_decode_stringÚ_is_shutting_down)Úget_library_namec                 ód   — t        | t        j                  fi «      }t        j                  |«      S ©N)ÚtypeÚctypesÚ	StructureÚPOINTER)ÚnameÚnewclss     úi/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/llvmlite/binding/ffi.pyÚ_make_opaque_refr   
   s(   € Ü�$œ×)Ñ)Ð+¨RÓ0€FÜ�>‰>˜&Ó!Ð!ó    ÚLLVMContextÚ
LLVMModuleÚ	LLVMValueÚLLVMTypeÚLLVMExecutionEngineÚLLVMPassManagerBuilderÚLLVMPassManagerÚLLVMTargetDataÚLLVMTargetLibraryInfoÚ
LLVMTargetÚLLVMTargetMachineÚLLVMMemoryBufferÚLLVMAttributeListIteratorÚLLVMElementIteratorÚLLVMAttributeSetIteratorÚLLVMGlobalsIteratorÚLLVMFunctionsIteratorÚLLVMBlocksIteratorÚLLVMArgumentsIteratorÚLLVMInstructionsIteratorÚLLVMOperandsIteratorÚLLVMIncomingBlocksIteratorÚLLVMTypesIteratorÚLLVMObjectCacheÚLLVMObjectFileÚLLVMSectionIteratorÚLLVMOrcLLJITRefÚLLVMOrcDylibTrackerRefÚLLVMTimePassesHandlerÚLLVMPipeLineTuningOptionsÚLLVMModulePassManagerÚLLVMFunctionPassManagerÚLLVMPassBuilderc                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)Ú	_LLVMLocka6  A Lock to guarantee thread-safety for the LLVM C-API.

    This class implements __enter__ and __exit__ for acquiring and releasing
    the lock as a context manager.

    Also, callbacks can be attached so that every time the lock is acquired
    and released the corresponding callbacks will be invoked.
    c                 óD   — t        j                  «       | _        g | _        y r   )Ú	threadingÚRLockÚ_lockÚ_cblist©Úselfs    r   Ú__init__z_LLVMLock.__init__;   s   € ô —_‘_Ó&ˆŒ
Øˆ�r   c                 ó>   — | j                   j                  ||f«       y)z®Register callbacks that are invoked immediately after the lock is
        acquired (``acq_fn()``) and immediately before the lock is released
        (``rel_fn()``).
        N)r8   Úappend©r:   Úacq_fnÚrel_fns      r   Úregisterz_LLVMLock.registerA   s   € ð
 	�‰×Ñ˜V VÐ,Õ-r   c                 ó>   — | j                   j                  ||f«       y)z)Remove the registered callbacks.
        N)r8   Úremover>   s      r   Ú
unregisterz_LLVMLock.unregisterH   s   € ð 	�‰×Ñ˜V VÐ,Õ-r   c                 ón   — | j                   j                  «        | j                  D ]  \  }} |«        Œ y r   )r7   Úacquirer8   r>   s      r   Ú	__enter__z_LLVMLock.__enter__M   s.   € Ø�
‰
×ÑÔà"Ÿl™lò 	‰NˆF�FÙ�Hñ	r   c                 ón   — | j                   D ]  \  }} |«        Œ | j                  j                  «        y r   )r8   r7   Úrelease)r:   Úexc_detailsr?   r@   s       r   Ú__exit__z_LLVMLock.__exit__S   s.   € à"Ÿl™lò 	‰NˆF�FÙ�Hð	à�
‰
×ÑÕr   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r;   rA   rD   rG   rK   © r   r   r3   r3   2   s    „ ñòò.ò.ò
ór   r3   c                   ó   — e Zd Zd„ Zd„ Zd„ Zy)Ú_suppress_cleanup_errorsc                 ó   — || _         y r   )Ú_context)r:   Úcontexts     r   r;   z!_suppress_cleanup_errors.__init__[   s	   € Øˆ�r   c                 ó6   — | j                   j                  «       S r   )rT   rG   r9   s    r   rG   z"_suppress_cleanup_errors.__enter__^   s   € Ø�}‰}×&Ñ&Ó(Ð(r   c                 ó\   — 	 | j                   j                  |||«      S # t        $ r Y y w xY wr   )rT   rK   ÚPermissionError)r:   Úexc_typeÚ	exc_valueÚ	tracebacks       r   rK   z!_suppress_cleanup_errors.__exit__a   s2   € ð	Ø—=‘=×)Ñ)¨(°I¸yÓIÐIøÜò 	Ùð	ús   ‚ Ÿ	+ª+N)rL   rM   rN   r;   rG   rK   rP   r   r   rR   rR   Z   s   „ ò ò)ór   rR   c                   óZ   — e Zd ZdZg d¢Zd„ Zd„ Zed„ «       Zd„ Z	ed„ «       Z
ed„ «       Zy	)
Ú_lib_wrapperz{Wrap libllvmlite with a lock such that only one thread may access it at
    a time.

    This class duck-types a CDLL.
    )Ú_lib_handleÚ_fntabr7   c                 ó>   — d | _         i | _        t        «       | _        y r   )r^   r_   r3   r7   r9   s    r   r;   z_lib_wrapper.__init__p   s   € ØˆÔØˆŒÜ“[ˆ�
r   c                 óš  — d}t         j                  d«      d   }t        «       }t        t	        ||«      «      5 }	 t        j                  t        |«      «      | _         t        | j                  |«      «        	 d d d «       y # t        $ r d|› d|› d�}t        |«      ‚t        $ r d|› d|› d	�}t        |«      ‚w xY w# 1 sw Y   y xY w)
NÚLLVMPY_GetVersionInfoú.r   z(Could not find/load shared object file 'z' from resource location: 'zº'. This could mean that the library literally cannot be found, but may also mean that the permissions are incorrect or that a dependency of/a symbol in the library could not be resolved.z-During testing of symbol lookup, the symbol 'z%' could not be found in the library 'ú')rL   Ú
rpartitionr   rR   Ú_importlib_resources_pathr	   ÚCDLLÚstrr^   ÚgetattrÚOSErrorÚAttributeError)r:   Útest_symÚmod_nameÚlib_nameÚlib_pathÚmsgs         r   Ú	_load_libz_lib_wrapper._load_libu   sô   € Ø*ˆÜ×&Ñ& sÓ+¨AÑ.ˆÜ#Ó%ˆä%Ô&?Ø&.°ó':ó ;ð 	#Ø>Fð#Ü#)§;¡;¬s°8«}Ó#=�Ô à3”˜×(Ñ(¨(Ó3Õ5÷	#ð 	#øô ò 	#ð BÀ(Àð L3Ø3;°*ð =#ð#�ô ˜c“lÐ"Ü!ò #ðØ#˜*ð %Ø#˜* Að'�ô ˜c“lÐ"ð#ú÷!	#ð 	#ús   ºC¼>BÂ:B>Â>CÃC
c                 óR   — | j                   s| j                  «        | j                   S r   )r^   rq   r9   s    r   Ú_libz_lib_wrapper._lib’   s#   € ð ×ÒØ�N‰NÔØ×ÑÐr   c                 óº   — 	 | j                   |   S # t        $ r Y nw xY wt        | j                  |«      }t	        | j
                  |«      }|| j                   |<   |S r   )r_   ÚKeyErrorri   rs   Ú_lib_fn_wrapperr7   )r:   r   ÚcfnÚwrappeds       r   Ú__getattr__z_lib_wrapper.__getattr__™   s]   € ð	Ø—;‘;˜tÑ$Ð$øÜò 	Ùð	úô �d—i‘i Ó&ˆÜ! $§*¡*¨cÓ2ˆØ#ˆ�‰�DÑØˆs   ‚ ‘	œc                 ó.   — | j                   j                  S )zgThe name of the library passed in the CDLL constructor.

        For duck-typing a ctypes.CDLL
        )rs   Ú_namer9   s    r   r{   z_lib_wrapper._name¤   s   € ð �y‰y�‰Ðr   c                 ó.   — | j                   j                  S )z]The system handle used to access the library.

        For duck-typing a ctypes.CDLL
        )rs   Ú_handler9   s    r   r}   z_lib_wrapper._handle¬   s   € ð �y‰y× Ñ Ð r   N)rL   rM   rN   rO   Ú	__slots__r;   rq   Úpropertyrs   ry   r{   r}   rP   r   r   r]   r]   h   sY   „ ñò
 3€Iò!ò
#ð: ñ ó ð ò	ð ñó ðð ñ!ó ñ!r   r]   c                   óŒ   — e Zd ZdZddgZd„ Zed„ «       Zej                  d„ «       Zed„ «       Z	e	j                  d„ «       Z	d	„ Z
y
)rv   zîWraps and duck-types a ctypes.CFUNCTYPE to provide
    automatic locking when the wrapped function is called.

    TODO: we can add methods to mark the function as threadsafe
          and remove the locking-step on call when marked.
    r7   Ú_cfnc                 ó    — || _         || _        y r   ©r7   r�   )r:   Úlockrw   s      r   r;   z_lib_fn_wrapper.__init__¾   s   € ØˆŒ
Øˆ�	r   c                 ó.   — | j                   j                  S r   ©r�   Úargtypesr9   s    r   r‡   z_lib_fn_wrapper.argtypesÂ   s   € à�y‰y×!Ñ!Ð!r   c                 ó&   — || j                   _        y r   r†   )r:   r‡   s     r   r‡   z_lib_fn_wrapper.argtypesÆ   s   € à%ˆ�	‰	Õr   c                 ó.   — | j                   j                  S r   ©r�   Úrestyper9   s    r   r‹   z_lib_fn_wrapper.restypeÊ   s   € à�y‰y× Ñ Ð r   c                 ó&   — || j                   _        y r   rŠ   )r:   r‹   s     r   r‹   z_lib_fn_wrapper.restypeÎ   s   € à#ˆ�	‰	Õr   c                 ój   — | j                   5   | j                  |i |¤Žcd d d «       S # 1 sw Y   y xY wr   rƒ   )r:   ÚargsÚkwargss      r   Ú__call__z_lib_fn_wrapper.__call__Ò   s1   € Ø�Z‰Zñ 	.Ø�4—9‘9˜dÐ- fÑ-÷	.÷ 	.ò 	.ús   �)©2N)rL   rM   rN   rO   r~   r;   r   r‡   Úsetterr‹   r�   rP   r   r   rv   rv   µ   su   „ ñð ˜&Ð!€Iòð ñ"ó ð"ð ‡_�_ñ&ó ð&ð ñ!ó ð!ð ‡^�^ñ$ó ð$ó.r   rv   c                 óX   — t        j                  t        j                  | «      |z  «      S )a  Replacement implementation of `import.resources.path` to avoid
    deprecation warning following code at importlib_resources/_legacy.py
    as suggested by https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy

    Notes on differences from importlib.resources implementation:

    The `_common.normalize_path(resource)` call is skipped because it is an
    internal API and it is unnecessary for the use here. What it does is
    ensuring `resource` is a str and that it does not contain path separators.
    )Ú_impresÚas_fileÚfiles)ÚpackageÚresources     r   Ú_importlib_resources_path_replr˜   ×   s!   € ô �?‰?œ7Ÿ=™=¨Ó1°HÑ<Ó=Ð=r   é   )é   é
   c                 óD   — t         j                  j                  | |«       y)z~Register callback functions for lock acquire and release.
    *acq_fn* and *rel_fn* are callables that take no arguments.
    N)Úlibr7   rA   ©r?   r@   s     r   Úregister_lock_callbackrŸ   í   s   € ô ‡I�I×Ñ�v˜vÕ&r   c                 óD   — t         j                  j                  | |«       y)z‘Remove the registered callback functions for lock acquire and release.
    The arguments are the same as used in `register_lock_callback()`.
    N)r�   r7   rD   rž   s     r   Úunregister_lock_callbackr¡   ô   s   € ô ‡I�I×Ñ˜ Õ(r   c                   ó   — e Zd ZdZy)Ú_DeadPointerz:
    Dummy class to make error messages more helpful.
    N)rL   rM   rN   rO   rP   r   r   r£   r£   û   s   „ òr   r£   c                   ór   — e Zd ZdZ e«       Zed„ «       Zdd„Zd„ Z	d„ Z
d„ Zefd„Zd	„ Zd
„ ZeZed„ «       Zy)ÚOutputStringz<
    Object for managing the char* output of LLVM APIs.
    c                 óX   —  | t        j                  |t         j                  «      ¬«      S )a%  Constructing from a pointer returned from the C-API.
        The pointer must be allocated with LLVMPY_CreateString.

        Note
        ----
        Because ctypes auto-converts *restype* of *c_char_p* into a python
        string, we must use *c_void_p* to obtain the raw pointer.
        )Úinit)r	   ÚcastÚc_char_p)ÚclsÚptrs     r   Úfrom_returnzOutputString.from_return  s   € ñ œŸ™ C¬¯©Ó9Ô:Ð:r   Nc                 ó–   — |�|nt        j                  d «      | _        t        j                  | j                  «      | _        || _        y r   )r	   r©   Ú_ptrÚbyrefÚ_as_parameter_Ú_owned)r:   Úownedr§   s      r   r;   zOutputString.__init__  s5   € Ø Ð,‘D´&·/±/À$Ó2GˆŒ	Ü$Ÿl™l¨4¯9©9Ó5ˆÔØˆ�r   c                 ó†   — | j                   �5| j                  rt        j                  | j                   «       d | _         | `y y r   )r®   r±   r�   ÚLLVMPY_DisposeStringr°   r9   s    r   ÚclosezOutputString.close  s7   € Ø�9‰9Ð Ø�{Š{Ü×(Ñ(¨¯©Ô3ØˆDŒIØÑ#ð	 !r   c                 ó   — | S r   rP   r9   s    r   rG   zOutputString.__enter__  s   € Øˆr   c                 ó$   — | j                  «        y r   ©rµ   ©r:   rY   Úexc_valÚexc_tbs       r   rK   zOutputString.__exit__"  ó   € Ø�
‰
�r   c                 óN   —  |«       s| j                   �| j                  «        y y y r   r¸   ©r:   r   s     r   Ú__del__zOutputString.__del__%  s'   € ñ !Ô"Ø�z‰zÐ%Ø—
‘
•ð &ð #r   c                 óf   — | j                   €y| j                   j                  }|€J ‚t        |«      S )Nz<dead OutputString>)r®   Úvaluer   )r:   Úss     r   Ú__str__zOutputString.__str__,  s1   € Ø�9‰9ÐØ(Ø�I‰I�O‰OˆØˆ}Ðˆ}Ü˜aÓ Ð r   c                 ó,   — t        | j                  «      S r   ©Úboolr®   r9   s    r   Ú__bool__zOutputString.__bool__3  ó   € Ü�D—I‘I‹Ðr   c                 ó.   — | j                   j                  S )z:Get the raw bytes of content of the char pointer.
        )r®   rÁ   r9   s    r   ÚbyteszOutputString.bytes8  s   € ð �y‰y�‰Ðr   )TN)rL   rM   rN   rO   r£   r°   Úclassmethodr¬   r;   rµ   rG   rK   r   r¿   rÃ   rÇ   Ú__nonzero__r   rÊ   rP   r   r   r¥   r¥     sc   „ ññ "“^€Nàñ	;ó ð	;óò
$òòð ):ó ò!òð €Kàñó ñr   r¥   c                 óD   — | �t        t        j                  | «      «      S y)z,To wrap string return-value from C-API.
    N)rh   r¥   r¬   ©r«   s    r   Ú
ret_stringrÏ   ?  s$   € ð €Ü”<×+Ñ+¨CÓ0Ó1Ð1ð r   c                 óF   — | �t         j                  | «      j                  S y)z+To wrap bytes return-value from C-API.
    N)r¥   r¬   rÊ   rÎ   s    r   Ú	ret_bytesrÑ   F  s%   € ð €Ü×'Ñ'¨Ó,×2Ñ2Ð2ð r   c                   óz   — e Zd ZdZdZ e«       ZdZd„ Zd„ Z	d„ Z
d„ Zed„ «       Zd„ Zd	„ Zefd
„Zd„ Zd„ ZeZd„ Zy)Ú	ObjectRefzJ
    A wrapper around a ctypes pointer to a LLVM object ("resource").
    Fc                 óP   — |€t        d«      ‚|| _        || _        t        | _        y )NzNULL pointer)Ú
ValueErrorr®   r°   r�   Ú_capi)r:   r«   s     r   r;   zObjectRef.__init__V  s(   € Øˆ;Ü˜^Ó,Ð,ØˆŒ	Ø!ˆÔÜˆ�
r   c                 ó    — 	 | j                   s| j                  s| j                  «        | j                  «        y# | j                  «        w xY w)zI
        Close this object and do any required clean-up actions.
        N)Ú_closedr±   Ú_disposeÚdetachr9   s    r   rµ   zObjectRef.close]  s0   € ð	Ø—<’<¨¯ªØ—‘”à�K‰K�MøˆD�K‰K�Mús	   ‚(; »Ac                 ó>   — | j                   s| `d| _         d| _        yy)zN
        Detach the underlying LLVM resource without disposing of it.
        TN)rØ   r°   r®   r9   s    r   rÚ   zObjectRef.detachg  s$   € ð �|Š|ØÐ#ØˆDŒLØˆD�Ið r   c                  ó   — y)zÒ
        Dispose of the underlying LLVM resource.  Should be overriden
        by subclasses.  Automatically called by close(), __del__() and
        __exit__() (unless the resource has been detached).
        NrP   r9   s    r   rÙ   zObjectRef._disposep  s   � r   c                 ó   — | j                   S )zf
        Whether this object has been closed.  A closed object can't
        be used anymore.
        )rØ   r9   s    r   ÚclosedzObjectRef.closedw  s   € ð �|‰|Ðr   c                 ój   — t        | d«      sJ ‚| j                  rt        | j                  ›d�«      ‚| S )Nrµ   z instance already closed)ÚhasattrrØ   ÚRuntimeErrorÚ	__class__r9   s    r   rG   zObjectRef.__enter__  s0   € Ü�t˜WÔ%Ð%Ð%Ø�<Š<Ü¸t¿~»~ÐOÓPÐPØˆr   c                 ó$   — | j                  «        y r   r¸   r¹   s       r   rK   zObjectRef.__exit__…  r¼   r   c                 óN   —  |«       s| j                   �| j                  «        y y y r   r¸   r¾   s     r   r¿   zObjectRef.__del__ˆ  s%   € Ù Ô"Ø�z‰zÐ%Ø—
‘
•ð &ð #r   c                 ó,   — t        | j                  «      S r   rÅ   r9   s    r   rÇ   zObjectRef.__bool__�  rÈ   r   c                 ó¦   — t        |d«      syt        j                  | j                  d   «      t        j                  |j                  d   «      k(  S )Nr®   Fr   )rà   r	   Ú	addressofr®   )r:   Úothers     r   Ú__eq__zObjectRef.__eq__�  sE   € Ü�u˜fÔ%ØÜ×Ñ §	¡	¨!¡Ó-Ü×Ñ˜UŸZ™Z¨™]Ó+ñ,ð 	,r   c                 ó„   — t        t        j                  | j                  t        j                  «      j
                  «      S r   )Úhashr	   r¨   r®   Úc_void_prÁ   r9   s    r   Ú__hash__zObjectRef.__hash__™  s&   € Ü”F—K‘K §	¡	¬6¯?©?Ó;×AÑAÓBÐBr   N)rL   rM   rN   rO   rØ   r£   r°   r±   r;   rµ   rÚ   rÙ   r   rÞ   rG   rK   r   r¿   rÇ   ré   rÌ   rí   rP   r   r   rÓ   rÓ   M  sm   „ ñð €GÙ!“^€Nà€Fòòòòð ñó ðòòð ):ó ò
ò,ð €KóCr   rÓ   )>Úsysr	   r5   Úimportlib.resourcesÚ	resourcesr“   Úllvmlite.binding.commonr   r   Úllvmlite.utilsr   r   ÚLLVMContextRefÚLLVMModuleRefÚLLVMValueRefÚLLVMTypeRefÚLLVMExecutionEngineRefÚLLVMPassManagerBuilderRefÚLLVMPassManagerRefÚLLVMTargetDataRefÚLLVMTargetLibraryInfoRefÚLLVMTargetRefÚLLVMTargetMachineRefÚLLVMMemoryBufferRefr   r   r   r    r!   r"   r#   r$   r%   r&   r'   ÚLLVMObjectCacheRefÚLLVMObjectFileRefÚLLVMSectionIteratorRefr+   r,   ÚLLVMTimePassesHandlerRefÚLLVMPipelineTuningOptionsRefÚLLVMModulePassManagerRefÚLLVMFunctionPassManagerRefÚLLVMPassBuilderRefr3   rR   Úobjectr]   rv   r˜   Úversion_infoÚpathrf   r�   rŸ   r¡   r£   r¥   rÏ   rÑ   rÓ   rP   r   r   ú<module>r
     sC  ðÛ 
Û Û Ý %ç EÝ +ò"ñ
 " -Ó0€Ù  Ó.€Ù Ó,€Ù˜zÓ*€Ù)Ð*?Ó@Ð Ù,Ð-EÓFÐ Ù%Ð&7Ó8Ð Ù$Ð%5Ó6Ð Ù+Ð,CÓDÐ Ù  Ó.€Ù'Ð(;Ó<Ð Ù&Ð'9Ó:Ð Ù,Ð-HÓIÐ Ù&Ð'<Ó=Ð Ù+Ð,FÓGÐ Ù&Ð'<Ó=Ð Ù(Ð)@ÓAÐ Ù%Ð&:Ó;Ð Ù(Ð)@ÓAÐ Ù+Ð,FÓGÐ Ù'Ð(>Ó?Ð Ù-Ð.JÓKÐ Ù$Ð%8Ó9Ð Ù%Ð&7Ó8Ð Ù$Ð%5Ó6Ð Ù)Ð*?Ó@Ð Ù"Ð#4Ó5€Ù)Ð*BÓCÐ Ù+Ð,CÓDÐ Ù/Ð0KÓLÐ Ù+Ð,CÓDÐ Ù-Ð.GÓHÐ Ù%Ð&7Ó8Ð ÷%ñ %÷Pñ ôJ!�6ô J!ôZ.�fô .òD>ð !$× 0Ñ 0°°!Ð 4¸Ò ?ñ <à")§,¡,ð ñ
 ƒn€ò'ò)ô�6ô ô;�6ô ;ò|2ò3ôMC�õ MCr   