U
    {h                     @   s   d Z ddlZdd ZejeeejejdddZejdd	d
ejeejejdddZ	ejdd	d
ejeejejejdddZ
ejdd	d
ejeejejejejdddZejdd	d
ejeejejdddZdS )a%  
Build a line table for CodeObjects, according to PEP-626 / Python 3.11.

See  https://github.com/python/cpython/blob/1054a755a3016f95fcd24b3ad20e8ed9048b7939/InternalDocs/locations.md
See  https://github.com/python/cpython/blob/1054a755a3016f95fcd24b3ad20e8ed9048b7939/Python/assemble.c#L192
    Nc                 C   s,   g }|}| D ]}t |||}qd|}|S )N )encode_single_positionjoin)Z	positionsZfirstlinenotable_byteslast_linenoposition_infoZ	linetable r   =/tmp/pip-unpacked-wheel-fhl22ezh/Cython/Compiler/LineTable.pybuild_line_table   s    
r
   )r   r   r   returnc                 C   s   |\}}}}||ks&t | d| || }||kr|dkrr|dk rrd||   kr^dk rrn nt| || |S d|  krdk rn n"|dk r|dk rt| ||| |S t| d t| |d>  t| ||  t| |d  t| |d  |S )	Nz >= r   P                  )AssertionErrorencode_location_shortencode_location_onelineencode_location_startencode_varint)r   r   r   Zstart_linenoZ
end_linenostart_column
end_columnZlast_lineno_deltar   r   r	   r      s     ,(
r   F)check)r   coder   c                 C   s   |  td|d> B  dS )Nr   r   r   )appendchr)r   r   r   r   r	   r   @   s    r   )r   r   r   r   c                 C   s>   |d@ }|d? }|  d|d> B d|d> || B d dS )N   r   r   c   r   r   )r   r   r   Zlow_bitsr   r   r   r	   r   I   s    *r   )r   
line_deltar   r   r   c                 C   s0   d| }|  d|d> B d|d|d dS )N
   r   r   r   r   r!   )r   r"   r   r   r   r   r   r	   r   S   s    $r   )r   valuer   c                 C   sN   |dks|dkst |dkr<| td|d@ B  |dL }q| t| dS )Nr   @   ?      )r   r   r   )r   r$   r   r   r	   r   j   s    
r   )__doc__Zcythonr
   Zcfunclisttupleintr   Z	exceptvalr   r   r   Zuintr   r   r   r   r	   <module>   s     "