ó
Nä²Wc           @@  s®   d  d l  m Z d d l m Z m Z d d l m Z d d l m Z d d l m Z d e j	 f d „  ƒ  YZ
 d	 e f d
 „  ƒ  YZ d e j f d „  ƒ  YZ e d „ Z d S(   i    (   t   absolute_importi   (   t   parse_from_stringst   StringParseContext(   t   Symtab(   t   Naming(   t   Codet   NonManglingModuleScopec           B@  s,   e  Z e Z d  „  Z d „  Z d d „ Z RS(   c         O@  s,   | |  _  d  |  _ t j j |  | | Ž d  S(   N(   t   prefixt   Nonet   cython_scopeR   t   ModuleScopet   __init__(   t   selfR   t   argst   kw(    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyR      s    		c         C@  s%   t  | _ t t |  ƒ j | | | ƒ S(   N(   t   Truet   usedt   superR   t   add_imported_entry(   R   t   namet   entryt   pos(    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyR      s    	c         C@  s[   | rD | t  j t  j t  j t  j f k r6 |  j } n  d | | f St j j |  | ƒ Sd  S(   Ns   %s%s(	   R   t   typeobj_prefixt   func_prefixt
   var_prefixt   pyfunc_prefixR   R   R
   t   mangle(   R   R   R   (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyR      s
    $N(   t   __name__t
   __module__t   Falset   cppR   R   R   R   (    (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyR   	   s   		t   CythonUtilityCodeContextc           B@  s#   e  Z d Z d d e e d  „ Z RS(   c         C@  sŠ   | r t  d ƒ ‚ n  | |  j k rP | |  j k rB t  d ƒ ‚ qP |  j | Sn  |  j d  k rƒ t |  j | d d  d |  ƒ|  _ n  |  j S(   Ns/   Relative imports not supported in utility code.s%   Only the cython cimport is supported.t   parent_modulet   context(   t   AssertionErrort   module_namet   modulest   scopeR   R   R   (   R   R#   t   relative_toR   t   need_pxdt   absolute_fallback(    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   find_module$   s    !N(   R   R   R   R%   R   R)   (    (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyR   !   s   t   CythonUtilityCodec        	   B@  sŒ   e  Z d  Z e Z d d d d d d d d d „ Z d „  Z d „  Z d „  Z	 e
 d d „ Z d „  Z e d d	 „ ƒ Z e
 d d d
 „ Z RS(   sR  
    Utility code written in the Cython language itself.

    The @cname decorator can set the cname for a function, method of cdef class.
    Functions decorated with @cname('c_func_name') get the given cname.

    For cdef classes the rules are as follows:
        obj struct      -> <cname>_obj
        obj type ptr    -> <cname>_type
        methods         -> <class_cname>_<method_cname>

    For methods the cname decorator is optional, but without the decorator the
    methods will not be prototyped. See Cython.Compiler.CythonScope and
    tests/run/cythonscope.pyx for examples.
    t	   __pyxutilt    c
   
      C@  sy   | d  k	 r' t j | | | | ƒ } n  | |  _ | |  _ | |  _ | |  _ | pT g  |  _ | |  _ |	 |  _	 | |  _
 d  S(   N(   R   R   t   sub_tempitat   implR   t   fileR   t   requirest
   from_scopet   outer_module_scopet   compiler_directives(
   R   R.   R   R   R0   R/   R1   R!   R3   R2   (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyR   G   s    							c         C@  s-   t  | t ƒ r% |  j ƒ  | j ƒ  k St Sd  S(   N(   t
   isinstanceR*   t   _equality_paramsR   (   R   t   other(    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   __eq__[   s    c         C@  s;   |  j  } x t | t ƒ r' | j } q W|  j | |  j f S(   N(   R2   R4   R   t   outer_scopeR.   R3   (   R   R8   (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyR5   a   s    	c         C@  s   t  |  j ƒ S(   N(   t   hashR.   (   R   (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   __hash__g   s    c         @  s  d d l  m } | g } d d l m } m } t ˆ  j d ˆ  j ƒ} ˆ  j | _ | | _	 t
 ˆ  j ˆ  j d | d t ƒ} | j | d d | ƒ}	 | rÞ g  }
 x1 |	 D]) } |
 j | ƒ t |
 | j ƒ r¨ Pq¨ q¨ W|
 }	 n  | j | ƒ } | j } | j |	 | d	 | ƒ}	 d
 „  } ˆ  j rG| j |	 | ˆ  j ƒ d	 | j ƒ}	 n  x` ˆ  j D]U } t | t ƒ rQt | d ƒ rQ| rQ| j |	 | | j j ƒ d	 | j ƒ}	 qQqQWˆ  j rà‡  f d †  } | j |	 | d	 | j ƒ}	 n  | j |	 | d t ƒ\ } } | st | ƒ ‚ | ˆ  _ | S(   Ni   (   t   AutoTestDictTransform(   t   Pipelinet   ParseTreeTransformsR3   R!   t   allow_struct_enum_decoratort   pyxt   exclude_classest   beforec         @  s   ‡  f d †  } | S(   Nc         @  s   |  j  j ˆ  ƒ |  S(   N(   R%   t   merge_in(   t   module_node(   R%   (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   merge_scope_transformŒ   s    (    (   R%   RD   (    (   R%   s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   merge_scope‹   s    t   treec         @  s   ˆ  j  |  j _ |  S(   N(   R2   R%   R8   (   RC   (   R   (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   scope_transformž   s    t	   printtree(   t   AnalysedTreeTransformsR;   R,   R<   R=   R   R   R3   R   R	   R   R.   R   t   create_pipelinet   appendR4   t   AnalyseDeclarationsTransformt   CnameDirectivesTransformt   InterpretCompilerDirectivest   insert_into_pipelineR1   R0   R*   t   hasattrRF   R%   R2   t   run_pipelineR   R"   (   R   t   entries_onlyR	   R;   t   excludesR<   R=   R!   RF   t   pipelinet   pt   tt	   transformRA   RE   t   depRG   t   err(    (   R   s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   get_treej   sP    							%			c         C@  s   d  S(   N(    (   R   t   output(    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   put_code«   s    c         K@  s%   |  j  | | |  } | j | j f S(   sR   
        Load a utility code as a string. Returns (proto, implementation)
        (   t   loadt   protoR.   (   t   clst   util_code_namet	   from_filet   kwargst   util(    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   load_as_string®   s    c   
      C@  sÝ   |  j  d t d | ƒ } | j j } | j d ƒ | j d ƒ | j d ƒ | j d ƒ x& | j ƒ  D] } |  | _ | | _ qe W| j } | j | d t d | ƒ| | _ x* |  j	 D] }	 |	 j
 r¶ |	 j | ƒ q¶ q¶ W| S(	   sÉ   
        Declare all entries from the utility code in dest_scope. Code will only
        be included for used entries. If module_name is given, declare the
        type entries with that name.
        RR   R	   R   t   __file__t   __builtins__t   __doc__t   merge_unusedt	   whitelist(   RZ   R   R%   t   entriest   popt   valuest   utility_code_definitionR   RB   R0   t   is_cython_utilityt   declare_in_scope(
   R   t
   dest_scopeR   R	   Ri   RF   Rj   R   t   original_scopeRX   (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyRo   ¶   s     				N(   R   R   Rg   R   Rn   R   R   R7   R5   R:   R   RZ   R\   t   classmethodRd   Ro   (    (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyR*   4   s   				A	c         O@  s   t  |  | | Ž j | ƒ d S(   s`   
    Declare some declarations given as Cython code in declaration_string
    in scope env.
    N(   R*   Ro   (   t   declaration_stringt   envt   private_typeR   Rb   (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   declare_declarations_in_scopeÔ   s    N(   t
   __future__R    t   TreeFragmentR   R   R,   R   R   R   R
   R   R   t   UtilityCodeBaseR*   R   Rv   (    (    (    s>   /bar/jli/Chip-seq/script/cython/Cython/Compiler/UtilityCode.pyt   <module>   s    