o
    ¯ôjµ  ã                   @   sB   d Z ddlZddlZddlZG dd„ dejƒZdd„ Zdd„ ZdS )	zR
This module provides helper functions to find the first line of a function
body.
é    Nc                       s8   e Zd ZdZdd„ Z‡ fdd„Zdejfdd„Z‡  Z	S )	ÚFindDefFirstLinezÊ
    Attributes
    ----------
    first_stmt_line : int or None
        This stores the first statement line number if the definition is found.
        Or, ``None`` if the definition is not found.
    c                 C   s   || _ || _d| _dS )zf
        Parameters
        ----------
        code :
            The function's code object.
        N)Ú_co_nameÚ_co_firstlinenoÚfirst_stmt_line)ÚselfÚnameÚfirstlineno© r	   úk/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/numba/misc/firstlinefinder.pyÚ__init__   s   
zFindDefFirstLine.__init__c                    s    t  |¡D ]}tƒ  |¡ qd S )N)ÚastÚiter_child_nodesÚsuperÚvisit)r   ÚnodeÚchild©Ú	__class__r	   r
   Ú_visit_children   s   ÿz FindDefFirstLine._visit_childrenr   c                 C   s|   |j | jkr7t|jgƒ}|jr|jd }| |j¡ | j|v r7|jr6|jd }t|ƒr0|jd }|j| _	d S 	 |  
|¡ d S )Nr   é   )r   r   ÚsetÚlinenoÚdecorator_listÚaddr   ÚbodyÚ_is_docstringr   r   )r   r   Zpossible_start_linesZfirst_decorZ
first_stmtr	   r	   r
   Úvisit_FunctionDef#   s   



z"FindDefFirstLine.visit_FunctionDef)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   ÚFunctionDefr   Ú__classcell__r	   r	   r   r
   r      s
    r   c                 C   s0   t | tjƒrt | jtjƒrt | jjtƒrdS dS )NTF)Ú
isinstancer   ÚExprÚvalueÚConstantÚstr)r   r	   r	   r
   r   A   s   ÿr   c                 C   sØ   | j }zt|jƒ�}| ¡ }d}W d  ƒ n1 sw   Y  W n+ ttfyK   zt | ¡\}}d |¡}|d }W n tt	fyH   Y Y dS w Y nw t
 t |¡¡}t|j|j| ƒ}| |¡ |jrj|j| S dS )a  
    Look up the first line of function body using the file in
    ``pyfunc.__code__.co_filename``.

    Returns
    -------
    lineno : int; or None
        The first line number of the function body; or ``None`` if the first
        line cannot be determined.
    r   NÚ r   )Ú__code__ÚopenÚco_filenameÚreadÚFileNotFoundErrorÚOSErrorÚinspectÚgetsourcelinesÚjoinÚ	TypeErrorr   ÚparseÚtextwrapÚdedentr   Úco_nameÚco_firstlinenor   r   )ÚpyfuncÚcoÚfinÚsourceÚoffsetÚlinesÚtreeÚfinderr	   r	   r
   Úget_func_body_first_linenoI   s.   þ€
ÿÿü

r@   )r    r   r/   r4   ÚNodeVisitorr   r   r@   r	   r	   r	   r
   Ú<module>   s    6