o
    ٷiz                     @   s    d Z G dd deZdd ZdS )z7Simple and tiny yield-based trampoline implementation.
c                   @   s   e Zd ZdZdd ZdS )TailCallz-Raised to signal a tail call to trampoline().c                 C   s
   || _ d S )N)call)selfr    r   G/home/ubuntu/.local/lib/python3.10/site-packages/trampoline/__init__.py__init__   s   
zTailCall.__init__N)__name__
__module____qualname____doc__r   r   r   r   r   r      s    r   c              
   C   s  | g}d}d}|rz/|dur|d}}|d  |}n|du r&t|d }n|d}}|d |}|| W nF tyQ } z|  |j}W Y d}~n2d}~w tyg } z|j|d< W Y d}~nd}~w t	y~ } z|  |}W Y d}~nd}~ww |s	|dur||S )z3Invoke a generator for a trampolined function call.N)
thrownextsendappendStopIterationpopvaluer   r   BaseException)r   stackretval	exceptionexresr   er   r   r   
trampoline   s:   

r   N)r
   r   r   r   r   r   r   r   <module>   s    