o
    Xi                     @  sR   d Z ddlmZ ddlZddlmZ G dd dZeejegef Z	dddZ
dS )z5Source code information used for diagnostic messages.    )annotationsN)Callablec                   @  sB   e Zd ZdZddddd	d
Zedd ZdddZdddZdS )
SourceInfozKInformation about onnxscript source fragment, used for diagnostic messages.N)codefunction_nameast_nodeast.ASTr   
str | Noner   c                C  s   || _ || _|| _d S N)r   r   r   )selfr   r   r    r   S/home/ubuntu/.local/lib/python3.10/site-packages/onnxscript/_internal/sourceinfo.py__init__   s   
zSourceInfo.__init__c                 C  s   | j jS r
   )r   linenor   r   r   r   r      s   zSourceInfo.linenoerror_messagestrreturnc                 C  s   | j }| jrd| j d| }nd| }| jr3| jd}||d  }d| jj }| d| d}nd}d	| d
| d| S )Nz
Function 'z', line zLine 
    z^
 zERROR: z
at: )r   r   r   splitr   
col_offset)r   r   r   
source_loclineslinemarker_prefixsource_liner   r   r   msg   s   
zSourceInfo.msgc                 C  s   t d)NzCannot happen!)
ValueErrorr   r   r   r   __str__/   s   zSourceInfo.__str__)r   r   r   r	   r   r	   )r   r   r   r   )r   r   )	__name__
__module____qualname____doc__r   propertyr   r   r!   r   r   r   r   r      s    

r   source_coder	   r   	Formatterc                   s   d fdd}|S )	Nnoder   messager   r   c                   s   t |  d|S )N)r   )r   r   )r)   r*   r'   r   r   format7   s   zformatter.<locals>.format)r)   r   r*   r   r   r   r   )r'   r,   r   r+   r   	formatter6   s   r-   )r'   r	   r   r(   )r%   
__future__r   asttypingr   r   ASTr   r(   r-   r   r   r   r   <module>   s   '