a
    3¹Df:  ã                   @   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   úh/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/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 ƒ} |rrt|tƒs:J ‚i }|jD ](}ˆ |jdƒ\}}ˆ |j|jjƒ||< qD|}| |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                    s€   |ˆ v r>ˆr0|   ˆ¡}|s&t| jdƒ‚|| jfS t| jdƒ‚n>tjd dkrlt| tƒrl| jd url| j| jfS |  t	¡| jfS d S )NzInvalid type.zType not allowed here.r   é   )
Zanalyse_as_typer   ÚposÚsysÚversion_infoÚ
isinstanceZ
StringNodeZunicode_valueZ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   ó    z1interpret_compiletime_options.<locals>.<listcomp>N)Ú	enumerater   ZDictNodeZkey_value_pairsÚkeyÚvalue)ZoptlistÚoptdictr   r   Znew_optdictÚitemZnew_keyÚdummyr   )r   r   r   r
   Úinterpret_compiletime_options   s    
r%   )Nr   )Ú__doc__Ú
__future__r   ZNodesZ	ExprNodesZErrorsr   Úobjectr   r   r%   r   r   r   r
   Ú<module>   s   