ó
ĤV]c           @@  sl   d  Z  d d l m Z d d l Td d l Td d l m Z d e f d     YZ e   Z	 d	 d
 d  Z d	 S(   sħ   
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.
i    (   t   absolute_importi   (   t   *(   t   CompileErrort
   EmptyScopec           B@  s   e  Z d    Z RS(   c         C@  s   d  S(   N(   t   None(   t   selft   name(    (    s:   lib/python2.7/site-packages/Cython/Compiler/Interpreter.pyt   lookup   s    (   t   __name__t
   __module__R   (    (    (    s:   lib/python2.7/site-packages/Cython/Compiler/Interpreter.pyR      s   c         @  sĊ      f d   } |  rI g  t  |   D] \ } } | | |  ^ q% }  n  | rğ t | t  sd t  i  } xE | j D]: } | | j d  \ }	 }
 | | j | j j  | |	 <qt W| } n  |  | f S(   s,  
    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^  rI |  j    } | s< t |  j d   n  | |  j f St |  j d   nW t j d d k r t |  t  r |  j d  k	 r |  j |  j f S|  j	 t
  |  j f Sd  S(   Ns   Invalid type.s   Type not allowed here.i    i   (   t   analyse_as_typeR   t   post   syst   version_infot
   isinstancet
   StringNodet   unicode_valueR   t   compile_time_valuet   empty_scope(   t   nodet   ixt   type(   t	   type_argst   type_env(    s:   lib/python2.7/site-packages/Cython/Compiler/Interpreter.pyt	   interpret'   s    N(   t	   enumerateR   t   DictNodet   AssertionErrort   key_value_pairst   keyR   t   value(   t   optlistt   optdictR   R   R   R   t   xt   new_optdictt   itemt   new_keyt   dummy(    (   R   R   s:   lib/python2.7/site-packages/Cython/Compiler/Interpreter.pyt   interpret_compiletime_options   s    1 	N(    (   t   __doc__t
   __future__R    t   Nodest	   ExprNodest   ErrorsR   t   objectR   R   R   R&   (    (    (    s:   lib/python2.7/site-packages/Cython/Compiler/Interpreter.pyt   <module>   s   

	