ó
\K]c           @` s~   d  d l  m Z m Z m Z d  d l m Z d  d l m Z d e f d „  ƒ  YZ	 d e f d „  ƒ  YZ
 e
 ƒ  Z e j Z d S(	   i    (   t   print_functiont   divisiont   absolute_import(   t   defaultdict(   t   configt   Rewritec           B` s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s8   Defines the abstract base class for Numba rewrites.
    c         C` s   | |  _  d S(   s+   Constructor for the Rewrite class.
        N(   t   pipeline(   t   selfR   (    (    s6   lib/python2.7/site-packages/numba/rewrites/registry.pyt   __init__   s    c         C` s   t  S(   s]   Overload this method to check an IR block for matching terms in the
        rewrite.
        (   t   False(   R   t   func_irt   blockt   typemapt	   calltypes(    (    s6   lib/python2.7/site-packages/numba/rewrites/registry.pyt   match   s    c         C` s   t  d ƒ ‚ d S(   sg   Overload this method to return a rewritten IR basic block when a
        match has been found.
        s    Abstract Rewrite.apply() called!N(   t   NotImplementedError(   R   (    (    s6   lib/python2.7/site-packages/numba/rewrites/registry.pyt   apply   s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s6   lib/python2.7/site-packages/numba/rewrites/registry.pyR      s   		t   RewriteRegistryc           B` s;   e  Z d  Z e d d g ƒ Z d „  Z d „  Z d „  Z RS(   s+   Defines a registry for Numba rewrites.
    s   before-inferences   after-inferencec         C` s   t  t ƒ |  _ d S(   si   Constructor for the rewrite registry.  Initializes the rewrites
        member to an empty list.
        N(   R   t   listt   rewrites(   R   (    (    s6   lib/python2.7/site-packages/numba/rewrites/registry.pyR   #   s    c         ` s;   ˆ  ˆ j  k r% t d ˆ  f ƒ ‚ n  ‡  ‡ f d †  } | S(   sf   
        Decorator adding a subclass of Rewrite to the registry for
        the given *kind*.
        s   invalid kind %rc         ` s?   t  |  t ƒ s' t d j |  ƒ ƒ ‚ n  ˆ j ˆ  j |  ƒ |  S(   Ns    {0} is not a subclass of Rewrite(   t
   issubclassR   t	   TypeErrort   formatR   t   append(   t   rewrite_cls(   t   kindR   (    s6   lib/python2.7/site-packages/numba/rewrites/registry.pyt   do_register0   s
    	(   t   _kindst   KeyError(   R   R   R   (    (   R   R   s6   lib/python2.7/site-packages/numba/rewrites/registry.pyt   register)   s    c         C` s†  | |  j  k s t ‚ | j } | j ƒ  } x|  j | D]} | | ƒ } t | j ƒ  ƒ } xå | rC| j ƒ  \ }	 }
 | j | |
 | j	 | j
 ƒ } | r_ t j s­ t j rç t d d ƒ t d | j ƒ |
 j ƒ  t d d ƒ n  | j ƒ  } | | |	 <| j |	 | f ƒ t j s"t j r@| j ƒ  t d d ƒ q@q_ q_ Wq8 Wx7 | j ƒ  D]) \ }	 }
 |
 | |	 k rU|
 j ƒ  qUqUWd S(   sŽ   Given a pipeline and a dictionary of basic blocks, exhaustively
        attempt to apply all registered rewrites to all basic blocks.
        t   _iF   s   REWRITING (%s):i<   N(   R   t   AssertionErrort   blockst   copyR   R   t   itemst   popR   R   R   R   t   DEBUGt   DUMP_IRt   printR   t   dumpR   R   t   verify(   R   R   R   R
   R#   t
   old_blocksR   t   rewritet	   work_listt   keyR   t   matchest	   new_block(    (    s6   lib/python2.7/site-packages/numba/rewrites/registry.pyR   8   s2    		


(   R   R   R   t	   frozensetR   R   R    R   (    (    (    s6   lib/python2.7/site-packages/numba/rewrites/registry.pyR      s
   		N(   t
   __future__R    R   R   t   collectionsR   t   numbaR   t   objectR   R   t   rewrite_registryR    t   register_rewrite(    (    (    s6   lib/python2.7/site-packages/numba/rewrites/registry.pyt   <module>   s   ;	