B
      ›\  ã               @   sP   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	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   s   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r2| j |||¡}| |¡ |rð|  |¡}| ¡ }	| d |¡¡ x||D ]t\}}
| 	|
t
 ¡ ¡}t ||dd¡}| |¡}| d |¡¡ | |t d¡¡}t |dd |¡|¡}| |¡ q^W | d¡ | |	¡ tjS tjS d S )Nzdump refct of {}r   z | {} refct=é    é   z%dz;
)ÚargsZ
enable_nrtZnrtZget_meminfosÚextendZget_python_apiZ
gil_ensureZprint_stringÚformatZbitcastr   Z
as_pointerr   Zgep_inboundsÚloadZtruncr   ZIntTypeZsnprintf_stackbufferZsys_write_stdoutZgil_releaseZtrue_bitZ	false_bit)ÚcontextZbuilderZ	signaturer	   ÚobjZtyZmeminfosZtmp_misZpyapiZ	gil_stateZmiZmiptrZrefctptrZrefctZrefct_32bitZprinted© r   ú4lib/python3.7/site-packages/numba/unsafe/refcount.pyÚcodegen   s.    




zdump_refcount.<locals>.codegen)r   Zbool_)Z	typingctxr   r   Zsigr   r   r   Údump_refcount   s    !
r   N)Ú__doc__Zllvmliter   Znumbar   r   Znumba.extendingr   Znumba.runtime.nrtdynmodr   r   r   r   r   r   Ú<module>   s   