o
    0 i	                     @   s   U d Z ddlmZmZmZmZ ddlmZ ddlm	Z	m
Z
 ddlZddlmZ ddlmZmZ zddlZW n ey@   dZY nw d	Zed
d Zg Zeg ed f ed< ded fddZedd ZG dd de	ZG dd deZejdd ZdS )zw
Implement code coverage support.

Currently contains logic to extend ``coverage`` with lines covered by the
compiler.
    )OptionalSequenceCallableno_type_check)defaultdict)ABCabstractmethodN)cache)irconfigFTc                  C   s   d} t r	tj } | S )z>Get active coverage instance or return None if not found.
    N)coverage_availablecoverageZCoveragecurrent)cov r   g/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/numba/misc/coverage_support.pyget_active_coverage   s   
r   NotifyLocBase_the_registryreturnc                   C   s&   t jsg S ttdd dd tD S )zC
    Returns a list of the registered NotifyLocBase instances.
    c                 S   s   | d uS Nr   )xr   r   r   <lambda>,   s    z+get_registered_loc_notify.<locals>.<lambda>c                 s   s    | ]}| V  qd S r   r   ).0factoryr   r   r   	<genexpr>-   s    z,get_registered_loc_notify.<locals>.<genexpr>)r   ZJIT_COVERAGElistfilterr   r   r   r   r   get_registered_loc_notify%   s
   
r   c                     s:   t jddt   dusJ dtj fdd} S )zm
    Make a singleton ``CoverageData``.
    Avoid writing to disk. Other processes can corrupt the file.
    T)Zno_diskNzno active Coverage instancec                      s       d S r   )get_dataupdater   r   covdatar   r   	_finalize:   s   z%_get_coverage_data.<locals>._finalize)r   ZCoverageDatar   atexitregister)r#   r   r!   r   _get_coverage_data0   s   r&   c                   @   s6   e Zd ZdZedejddfddZed	ddZdS )
r   zAInterface for notifying visiting of a ``numba.core.ir.Loc``.
    locr   Nc                 C      d S r   r   selfr'   r   r   r   notifyE      zNotifyLocBase.notifyc                 C   r(   r   r   r*   r   r   r   closeI   r,   zNotifyLocBase.close)r   N)	__name__
__module____qualname____doc__r   r
   Locr+   r.   r   r   r   r   r   B   s    c                   @   s0   e Zd ZdZdd ZdejfddZdd Zd	S )
NotifyCompilerCoveragez
    Use to notify ``coverage`` about compiled lines.

    The compiled lines are under the "numba_compiled" context in the coverage
    data.
    c                 C   s   t t| _d S r   )r   set
_arcs_datar-   r   r   r   __init__U   s   zNotifyCompilerCoverage.__init__r'   c                 C   s.   |j dr| j|j  |j|jf d S d S )Nz.py)filenameendswithr6   addliner)   r   r   r   r+   X   s   zNotifyCompilerCoverage.notifyc                 C   sH   t  }|j |d || j W d    d S 1 sw   Y  d S )NZnumba_compiled)r&   _lockZset_contextZadd_arcsr6   )r*   r"   r   r   r   r.   ]   s
   
"zNotifyCompilerCoverage.closeN)	r/   r0   r1   r2   r7   r
   r3   r+   r.   r   r   r   r   r4   N   s
    r4   c                   C   s   t  d urt S d S r   )r   r4   r   r   r   r   _register_coverage_notifierd   s   
r=   )r2   typingr   r   r   r   collectionsr   abcr   r   r$   	functoolsr	   Z
numba.corer
   r   r   ImportErrorr   r   r   __annotations__r   r&   r   r4   appendr=   r   r   r   r   <module>   s.    
	
