o
    &[hB  ã                   @   sP   d Z ddlmZ ddlT ddlT ddlmZ G dd„ deƒ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.
é    )Úabsolute_importé   )Ú*)ÚCompileErrorc                   @   s   e Zd Zdd„ ZdS )Ú
EmptyScopec                 C   s   d S )N© )ÚselfÚnamer   r   úP/var/www/vscode/pina/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                    sz   |ˆ v rˆr|   ˆ¡}|st| jdƒ‚|| jfS t| jdƒ‚tjd dkr5t| tƒr5| jd ur5| j| jfS |  t	¡| jfS )NzInvalid type.zType not allowed here.r   é   )
Úanalyse_as_typer   ÚposÚsysÚversion_infoÚ
isinstanceÚ
StringNodeÚunicode_valueÚ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>8   s    z1interpret_compiletime_options.<locals>.<listcomp>N)Ú	enumerater   ÚDictNodeÚ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__Ú
__future__r   ÚNodesÚ	ExprNodesÚErrorsr   Úobjectr   r   r-   r   r   r   r
   Ú<module>   s    