
    Ae:                     `    d Z ddlmZ ddl ddl ddlmZ  G d de      Z e       Z	d
d	Z
y)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                       e Zd Zd Zy)
EmptyScopec                      y )N )selfnames     ;lib/python3.12/site-packages/Cython/Compiler/Interpreter.pylookupzEmptyScope.lookup   s        N)__name__
__module____qualname__r   r
   r   r   r   r      s    r   r   Nc                 D   fd}| r$t        |       D cg c]  \  }} |||       } }}|rgt        |t              sJ i }|j                  D ]B  } ||j                  d      \  }	}
 ||j
                  |j                  j
                        ||	<   D |}| fS c c}}w )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                    |v rOr7| j                        }|st        | j                  d      || j                  fS t        | j                  d      t        j                  d   dk\  r4t        | t              r$| j                  | j                  | j                  fS | j                  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_envs      r   	interpretz0interpret_compiletime_options.<locals>.interpret'   s    ?++H5&txxAAdhh''"488-EFF  #a'4,"".**DHH55++K8$((CCr   N)	enumerater   DictNodekey_value_pairskeyvalue)optlistoptdictr#   r"   r$   r    xnew_optdictitemnew_keydummys     ``       r   interpret_compiletime_optionsr1      s    "D  1:71CDA9Q#DD'8,,++ 	ID&txx6NGU#,TZZ#HK 	I [!! Es   B)Nr
   )__doc__
__future__r   Nodes	ExprNodesErrorsr   objectr   r   r1   r
   r   r   <module>r8      s2    '      l*"r   