o
    wÖi'  ã                   @   s>   d Z ddlmZ ddlmZ G dd„ dƒZeƒ Zd
dd	„ZdS )z±
This module deals with interpreting the parse tree as Python
would have done, in the compiler.

For now this only covers parse tree to value conversion of
compile-time values.
é   )ÚDictNode)ÚCompileErrorc                   @   s   e Zd Zdd„ ZdS )Ú
EmptyScopec                 C   s   d S )N© )ÚselfÚnamer   r   úX/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/Cython/Compiler/Interpreter.pyÚlookup   s   zEmptyScope.lookupN)Ú__name__Ú
__module__Ú__qualname__r	   r   r   r   r   r      s    r   Nr   c                    sz   ‡‡fdd„‰ | r‡ fdd„t | ƒD ƒ} |r9t|tƒsJ ‚i }|jD ]}ˆ |jdƒ\}}ˆ |j|jjƒ||< q"|}| |fS )a,  
    Tries to interpret a list of compile time option nodes.
    The result will be a tuple (optlist, optdict) but where
    all expression nodes have been interpreted. The result is
    in the form of tuples (value, pos).

    optlist is a list of nodes, while optdict is a DictNode (the
    result optdict is a dict)

    If type_env is set, all type nodes will be analysed and the resulting
    type set. Otherwise only interpretateable ExprNodes
    are allowed, other nodes raises errors.

    A CompileError will be raised if there are problems.
    c                    sL   |ˆ v rˆr|   ˆ¡}|st| jdƒ‚|| jfS t| jdƒ‚|  t¡| jfS )NzInvalid type.zType not allowed here.)Úanalyse_as_typer   ÚposÚcompile_time_valueÚempty_scope)ÚnodeÚixÚtype)Ú	type_argsÚtype_envr   r   Ú	interpret%   s   

z0interpret_compiletime_options.<locals>.interpretc                    s   g | ]	\}}ˆ ||ƒ‘qS r   r   )Ú.0r   Úx)r   r   r   Ú
<listcomp>1   s    z1interpret_compiletime_options.<locals>.<listcomp>N)Ú	enumerateÚ
isinstancer   Úkey_value_pairsÚkeyÚvalue)ÚoptlistÚoptdictr   r   Únew_optdictÚitemÚnew_keyÚdummyr   )r   r   r   r   Úinterpret_compiletime_options   s   
r%   )Nr   )Ú__doc__Ú	ExprNodesr   ÚErrorsr   r   r   r%   r   r   r   r   Ú<module>   s    	