o
    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coverageCoveragecurrent)cov r   X/home/ubuntu/veenaModal/venv/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   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)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   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   r0   zNotifyLocBase.close)r   N)	__name__
__module____qualname____doc__r   r
   Locr/   r2   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_datar1   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endswithr:   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 )Nnumba_compiled)r*   _lockset_contextadd_arcsr:   )r.   r%   r   r   r   r2   ]   s
   
"zNotifyCompilerCoverage.closeN)	r3   r4   r5   r6   r;   r
   r7   r/   r2   r   r   r   r   r8   N   s
    r8   c                   C   s   t  d urt S d S r   )r   r8   r   r   r   r   _register_coverage_notifierd   s   
rD   )r6   typingr   r   r   r   collectionsr   abcr   r   r(   	functoolsr	   
numba.corer
   r   r   ImportErrorr   r   r   __annotations__r    r*   r   r8   appendrD   r   r   r   r   <module>   s.    
	
