o
    i                     @   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	   ]/home/ubuntu/maya3_transcribe/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   possible_start_linesfirst_decor
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.   


rC   )r#   r   r2   r7   NodeVisitorr   r   rC   r	   r	   r	   r
   <module>   s    6