o
    ۾i
                     @   sT   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 edd Z
edd	 Zd
S )z6
Helpers to see the refcount information of an object
    )ir)typescgutils)	intrinsic)_meminfo_struct_typec                 C      dd }t |}||fS )zDump the refcount of an object to stdout.

    Returns True if and only if object is reference-counted and NRT is enabled.
    c                 S   s   |\}|j \}g }| jr| j|||}|| |rt| |}| }	|d| |D ]8\}}
|	|
t
 }t||dd}||}|d| ||td}t|dd||}|| q.|d ||	 tjS tjS )Nzdump refct of {}r   z | {} refct=       z%d [%p]z;
)args
enable_nrtnrtget_meminfosextendget_python_api
gil_ensureprint_stringformatbitcastr   
as_pointerr   gep_inboundsloadtruncr   IntTypesnprintf_stackbuffersys_write_stdoutgil_releasetrue_bit	false_bit)contextbuilder	signaturer
   objtymeminfostmp_mispyapi	gil_statemimiptrrefctptrrefctrefct_32bitprinted r-   N/home/ubuntu/.local/lib/python3.10/site-packages/numba/core/unsafe/refcount.pycodegen   s0   





zdump_refcount.<locals>.codegen)r   bool_	typingctxr!   r/   sigr-   r-   r.   dump_refcount   s   
!r4   c                 C   r   )zUGet the current refcount of an object.

    FIXME: only handles the first object
    c                 S   s   |\}|j \}g }| jr| j|||}|| g }|rG|D ]'\}}	||	t }
t	||
dd}|
|}||td}|| q|d S )Nr   r   )r
   r   r   r   r   r   r   r   r   r   r   r   r   r   append)r   r   r    r
   r!   r"   r#   r$   	refcountsr'   r(   r)   r*   r+   r-   r-   r.   r/   =   s   

zget_refcount.<locals>.codegen)r   int32r1   r-   r-   r.   get_refcount7   s   
r8   N)__doc__llvmliter   
numba.corer   r   numba.core.extendingr   numba.core.runtime.nrtdynmodr   r4   r8   r-   r-   r-   r.   <module>   s    
*