
    `i-                         d Z ddlmZ ddlZ	 ddlmZ n# e$ r	 ddlmZ Y nw xY wddlm	Z	 ddl
Z
ddlmZ ddlZddlmZ d Zd	 Zd
 Zd Zd ZdZdZd ZddZedk    r e             dS dS )z`
Generate documentation for all registered implementation for lowering
using reStructured text.
    )check_outputN)StringIO)defaultdict)partial)
cpu_targetc                  t    t          g d          } |                     d                              d          S )N)gitlogz--pretty=format:'%H'z-n1ascii'")r   decodestrip)outs    x/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/numba/scripts/generate_lower_listing.pygit_hashr      s6    
HHH
I
IC::g$$U+++    c                 .    t          | d| j                  S )N__qualname__)getattr__name__)fns    r   get_func_namer      s    2~r{333r   c           	      V   t          t                    }t          j                            t          j                            t
          j                            }| j                                        D ]\  }}|j	        D ]\  }}i }||         
                    |           ||d<   ||d<   t          j        |          \  }}	t          j        |          }
t          |          t          j                            |
|          |	|	t!          |          z   dz
  f|j        d|d<   |S )Nr   sig)start   )namefilenamelines	docstringimpl)r   listospathdirnamenumba__file___defnsitemsversionsappendinspectgetsourcelinesgetsourcefiler   relpathlen__doc__)backendfninfosbasepathr   oselr   r"   infocodefirstlinenor%   s              r   gather_function_infor:      s   $Gwrwu~>>??HN((**  D 	 	ICDBKt$$$DJDK ' 6t < <D+(..D%d++GOODOAA%{SYY'>'BC!\	 DLL	 Nr   c                 .    t          t          |           S )Nfile)r   print)fobjs    r   bind_file_to_printr@   4   s    5t$$$$r   c                     d }t          t          ||                     }d                    d                    |                    S )Nc                 v    	 | j         S # t          $ r% t          |                               d          cY S w xY w)Nr   )r   AttributeErrorreprr   )cs    r   fmtzformat_signature.<locals>.fmt9   sH    	(: 	( 	( 	(77=='''''	(s   	 ,88z`({0})`z, )tuplemapformatjoin)r   rF   r   s      r   format_signaturerK   8   sF    ( ( (
 C

CDIIcNN+++r   zLhttps://github.com/numba/numba/blob/{commit}/{path}#L{firstline}-L{lastline}a8  
This lists all lowering definition registered to the CPU target.
Each subsection corresponds to a Python function that is supported by numba
nopython mode. These functions have one or more lower implementation with
different signatures. The compiler chooses the most specific implementation
from all overloads.
c           	         t                      }	 t          |          }d} ||            |dt          |          z              |t                     t	                      }d }t          t          ||           d           D ]\  }}| |         }d                    |          }	 ||	            |dt          |	          z              |             t          d |          }
t          t          |
|          d	           }d
g}dg}|D ]\  }}|d         }|d         }|d         }|d         } dj        |g|R  }t                              |||d         |d                   }d                    |||          }|
                    |           |
                    |           t          t          t          |                    }t          t          t          |                    }d}|dz  |z   }|dz  |z   }d                    ||          } ||                    d|z  d|z                        ||                    |d         |d                               ||                    d|z  d|z                       t          |dd          |dd                    D ]$\  }} ||                    ||                     % ||                    d|z  d|z                        |             |                                |                                 S # |                                 w xY w)NzLowering Listing=c                     	 d                     | j        t          |                     }n# t          $ r t	          |           }Y nw xY w| |fS )Nz{0}.{1})rI   
__module__r   rC   rD   )r   fnames     r   format_fnamez+format_function_infos.<locals>.format_fname[   s\    !!((b8I8IJJ! ! ! !R!u9s   (+ AAc                     | d         S )Nr    xs    r   <lambda>z'format_function_infos.<locals>.<lambda>b   s
    !A$ r   )keyz``{0}``-c                 ,    t          | d                   S )Nr   )rK   rT   s    r   rV   z'format_function_infos.<locals>.<lambda>j   s    *1U844 r   c                     | d         S )Nr   rS   rT   s    r   rV   z'format_function_infos.<locals>.<lambda>l   s
    1Q4 r   	Signature
Definitionr"   r   r    r   z{0} lines {1}-{2}r   r   )commitr%   	firstlinelastlinez``{0}`` `{1} <{2}>`_   z{{0:^{0}}}  {{1:^{1}}})r   r@   r1   descriptionr   sortedrH   rI   zip
github_urlr,   maxgetvalueclose)r4   bufr>   
title_liner]   rQ   r   rP   impinfosheader_lineformatted_sigssorted_impinfoscol_signaturescol_urlsfmtsigr7   r"   r   r    sourcelinkurlmax_width_col_sigmax_width_col_urlpaddingwidth_col_sigwidth_col_urlline_formatr   s                                r   format_function_infosrz   N   s   
**CB"3'''
jcC
OO#$$$k	 	 	  L' : :OOO ,	 ,	IBr{H#**511KE+E#K((()))EGGG 44h@ @N$S%B%B)79 9 9O *]N$~H / % %F|
+WV3,3HEuEEE!((X388eAh ) P P,33E64HH%%f---$$$$ !$C^$<$< = = #CX$6$6 7 7G#aK*;;M#aK*;;M299-:GI IKE+$$S=%8#:MNNOOOE+$$^A%6DDEEEE+$$S=%8#:MNNOOOqrr 2HQRRLAA 4 4Sk((c223333E+$$S=%8#:MNNOOOEGGGG||~~				s   LL2 2Mc                    t           j        }|                                 t          |          }t	          |          }| t          |           dS t          | d          5 }t          ||           ddd           dS # 1 swxY w Y   dS )zG
    Generate lowering listing to ``path`` or (if None) to stdout.
    Nwr<   )r   target_contextrefreshr:   rz   r>   open)r%   cpu_backendr4   r   r?   s        r   gen_lower_listingr      s     +K";//G

(
(C|c




$__ 	"#D!!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   "BBB__main__)N)r2   
subprocessr   os.pathr$   r   ImportErroriocollectionsr   r-   	functoolsr   r'   numba.core.registryr   r   r   r:   r@   rK   rd   ra   rz   r   r   rS   r   r   <module>r      sk    $ # # # # # !!!!!!!    # # # # # #         * * * * * *, , ,
4 4 4  *% % %, , ,9
D D DR" " " "" z s    ##