
    wg
                     \    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        Z
ed        Zy)	z6
Helpers to see the refcount information of an object
    )ir)typescgutils)	intrinsic)_meminfo_struct_typec                 :    d }t        j                  |      }||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                 6   |\  }|j                   \  }g }| j                  r.| j                  j                  |||      }|j	                  |       |r9| j                  |      }|j                         }	|j                  dj                  |             |D ]  \  }}
|j                  |
t        j                               }t        j                  ||dd      }|j                  |      }|j                  dj                  |             |j                  |t!        j"                  d            }t        j$                  |dd||      }|j'                  |        |j                  d       |j)                  |	       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printeds                   _/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/numba/core/unsafe/refcount.pycodegenzdump_refcount.<locals>.codegen   sf   ~~kk..wC@GOOG$**73E((*I188<=" 0B,@,K,K,MN"//1EX."">#8#8#<= &mmE2::b>B!66RK &&w/0 u%i(###$$$    )r   bool_	typingctxr#   r0   sigs       r/   dump_refcountr6      s"    %B ++c
C<r1   c                 :    d }t        j                  |      }||fS )zUGet the current refcount of an object.

    FIXME: only handles the first object
    c                    |\  }|j                   \  }g }| j                  r.| j                  j                  |||      }|j	                  |       g }|r|D ]  \  }}	|j                  |	t        j                               }
t        j                  ||
dd      }|j                  |      }|j                  |t        j                  d            }|j                  |        |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-   s                 r/   r0   zget_refcount.<locals>.codegen=   s    ~~kk..wC@GOOG$	" .B,@,K,K,MN"//1EX.%mmE2::b>B  -. |r1   )r   int32r3   s       r/   get_refcountr<   7   s!    $ ++c
C<r1   N)__doc__llvmliter   
numba.corer   r   numba.core.extendingr   numba.core.runtime.nrtdynmodr   r6   r<    r1   r/   <module>rC      sA     % * = ' 'T  r1   