a
    b:                     @   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   k/Users/vegardjervell/Documents/master/model/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   