B
    Í‹d:  ã               @   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/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/Cython/Compiler/Interpreter.pyÚlookup   s    zEmptyScope.lookupN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r
   r      s   r   Nr   c                s~   ‡‡fdd„‰ | r(‡ fdd„t | ƒD ƒ} |rvt|tƒs:t‚i }x2|jD ](}ˆ |jdƒ\}}ˆ |j|jjƒ||< qFW |}| |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€   |ˆ kr>ˆr0|   ˆ¡}|s&t| jdƒ‚|| jfS t| jdƒ‚n>tjd dkrlt| tƒrl| jd k	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   s    z1interpret_compiletime_options.<locals>.<listcomp>N)Ú	enumerater   ZDictNodeÚAssertionErrorZ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   