
    pi                     V    d Z ddlZddlZddlZ G d dej                        Zd Zd Zy)zR
This module provides helper functions to find the first line of a function
body.
    Nc                   H     e Zd ZdZd Z fdZdej                  fdZ x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                 .    || _         || _        d| _        y)zf
        Parameters
        ----------
        code :
            The function's code object.
        N)_co_name_co_firstlinenofirst_stmt_line)selfnamefirstlinenos      \/opt/services/ai/voice_agent/venv/lib/python3.12/site-packages/numba/misc/firstlinefinder.py__init__zFindDefFirstLine.__init__   s     *#    c                 X    t        j                  |      D ]  }t        |   |        y )N)astiter_child_nodessupervisit)r	   nodechild	__class__s      r   _visit_childrenz FindDefFirstLine._visit_children   s)    ))$/ 	!EGM% 	!r   r   c                    |j                   | j                  k(  rt        |j                  g      }|j                  r*|j                  d   }|j                  |j                         | j                  |v rH|j                  r;|j                  d   }t        |      r|j                  d   }|j                  | _	        y 	 | j                  |       y )Nr      )r
   r   setlinenodecorator_listaddr   body_is_docstringr   r   )r	   r   possible_start_linesfirst_decor
first_stmts        r   visit_FunctionDefz"FindDefFirstLine.visit_FunctionDef#   s    99% $'}#5 "" #11!4$((););<##';; 99!%1J$Z0%)YYq\
+5+<+<D(
 T"r   )
__name__
__module____qualname____doc__r   r   r   FunctionDefr#   __classcell__)r   s   @r   r   r      s"    	$!#coo #r   r   c                     t        | t        j                        rIt        | j                  t        j                        r%t        | j                  j                  t
              ryy)NTF)
isinstancer   ExprvalueConstantstr)r   s    r   r   r   A   s<    $!tzz3<<0tzz//5r   c                 :   | j                   }	 t        |j                        5 }|j                         }d}ddd       t        j                  t        j                              }t        |j                  |j                   z
        }|j#                  |       |j$                  r|j$                  |z   S y# 1 sw Y   xY w# t        t
        f$ rI 	 t        j                  |       \  }}dj                  |      }|dz
  }n# t
        t        f$ r Y Y yw xY wY w xY w)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finders           r   get_func_body_first_linenorI   I   s    
B
"..! 	SXXZFF	 99X__V,-Dbjj"*;*;f*DEF
LL%%.. %	 	 w' 	#226:ME6WWU^FaZF# 		 	sK   C B6C 6B?;C D.D DDDDDD)r'   r   r8   r=   NodeVisitorr   r   rI    r   r   <module>rL      s0   
   3#s 3#lr   