ó
\K]c           @  sÙ   d  d l  m Z d  d l Z d  d l j Z d  d l m Z m Z d  d l	 m
 Z
 m Z d „  Z d „  Z d „  Z e
 d k r„ e n e Z d
 e j f d „  ƒ  YZ d e j f d „  ƒ  YZ e d k rÕ e j ƒ  n  d S(   iÿÿÿÿ(   t   print_functionN(   t   compilert   ir(   t	   PYVERSIONt   StringIOc         C  s5   | |  }  } | | | } } } |  | | | | S(   sÚ  
    label 0:
        a = arg(0, name=a)                       ['a']
        b = arg(1, name=b)                       ['b']
        c = arg(2, name=c)                       ['c']
        d = arg(3, name=d)                       ['d']
        e = arg(4, name=e)                       ['e']
        a.1 = b                                  ['a.1', 'b']
        del b                                    []
        b.1 = a                                  ['a', 'b.1']
        del a                                    []
        c.1 = e                                  ['c.1', 'e']
        del e                                    []
        d.1 = c                                  ['c', 'd.1']
        del c                                    []
        e.1 = d                                  ['d', 'e.1']
        del d                                    []
        $0.8 = a.1 + b.1                         ['$0.8', 'a.1', 'b.1']
        del b.1                                  []
        del a.1                                  []
        $0.10 = $0.8 + c.1                       ['$0.10', '$0.8', 'c.1']
        del c.1                                  []
        del $0.8                                 []
        $0.12 = $0.10 + d.1                      ['$0.10', '$0.12', 'd.1']
        del d.1                                  []
        del $0.10                                []
        $0.14 = $0.12 + e.1                      ['$0.12', '$0.14', 'e.1']
        del e.1                                  []
        del $0.12                                []
        $0.15 = cast(value=$0.14)                ['$0.14', '$0.15']
        del $0.14                                []
        return $0.15                             ['$0.15']
    (    (   t   at   bt   ct   dt   e(    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyt   var_swapping
   s    "c         C  s    |  | k r |  n | d } | S(   sn  
    label 0:
        a = arg(0, name=a)                       ['a']
        b = arg(1, name=b)                       ['b']
        $0.3 = a > b                             ['$0.3', 'a', 'b']
        branch $0.3, 12, 18                      ['$0.3']
    label 12:
        del b                                    []
        del $0.3                                 []
        $phi21.2 = a                             ['$phi21.2', 'a']
        del a                                    []
        jump 21                                  []
    label 18:
        del a                                    []
        del $0.3                                 []
        $phi21.2 = b                             ['$phi21.2', 'b']
        del b                                    []
        jump 21                                  []
    label 21:
        $const21.1 = const(int, 5)               ['$const21.1']
        $21.3 = $phi21.2 + $const21.1            ['$21.3', '$const21.1', '$phi21.2']
        del $phi21.2                             []
        del $const21.1                           []
        c = $21.3                                ['$21.3', 'c']
        del $21.3                                []
        $21.5 = cast(value=c)                    ['$21.5', 'c']
        del c                                    []
        return $21.5                             ['$21.5']
    i   (    (   R   R   R   (    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyt   var_propagate1_pre360   s    c         C  s    |  | k r |  n | d } | S(   sm  
    label 0:
        a = arg(0, name=a)                       ['a']
        b = arg(1, name=b)                       ['b']
        $0.3 = a > b                             ['$0.3', 'a', 'b']
        branch $0.3, 8, 12                       ['$0.3']
    label 8:
        del b                                    []
        del $0.3                                 []
        $phi14.2 = a                             ['$phi14.2', 'a']
        del a                                    []
        jump 14                                  []
    label 12:
        del a                                    []
        del $0.3                                 []
        $phi14.2 = b                             ['$phi14.2', 'b']
        del b                                    []
        jump 14                                  []
    label 14:
        $const14.1 = const(int, 5)               ['$const14.1']
        $14.3 = $phi14.2 + $const14.1            ['$14.3', '$const14.1', '$phi14.2']
        del $phi14.2                             []
        del $const14.1                           []
        c = $14.3                                ['$14.3', 'c']
        del $14.3                                []
        $14.5 = cast(value=c)                    ['$14.5', 'c']
        del c                                    []
        return $14.5                             ['$14.5']
    i   (    (   R   R   R   (    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyt   var_propagate1_post36Q   s    i   i   t   TestIRc           B  s   e  Z d  „  Z RS(   c      	   C  s  d } t  j d d  d t  j d | d d ƒ ƒ } t  j d | d t  j d | d d ƒ ƒ } | j d d t  j d | d d	 ƒ ƒ} |  j | j d ƒ | ƒ |  j t | j	 ƒ d ƒ | j d
 d t  j d | d d ƒ ƒ} |  j t | j	 ƒ d ƒ |  j t | j	 ƒ d ƒ |  j | j d
 ƒ | ƒ |  j | j d
 ƒ | ƒ | j d
 d t  j d | d d ƒ ƒ} |  j | j d
 ƒ | ƒ |  j
 | j d
 ƒ | ƒ |  j | j d
 ƒ | ƒ y+ | j d
 d t  j d | d d ƒ ƒ} Wn t  j k
 ròn X|  j d t  j ƒ d  S(   Ns   <?>t   parentt   loct   filenamet   linei   i   t   applei   t   orangei   i   s   Expecting an %s(   R   t   Scopet   Nonet   Loct   definet   assertIst   gett   assertEqualt   lent	   localvarst   assertIsNott   RedefinedErrort   fail(   t   selfR   t   topt   localR   R   t   more_oranget
   bad_orange(    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyt   test_IRScopez   s,    **''(   t   __name__t
   __module__R%   (    (    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyR   x   s   t
   TestIRDumpc           B  s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   så   
    Exercise the IR dump of some constructs.  These tests are fragile
    (may need to be updated when details of IR generation change, may
    need to be skipped for some Python versions) but help find out
    regressions.
    c         C  s   t  j | ƒ S(   N(   R   t   run_frontend(   R    t   pyfunc(    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyt   get_ir    s    c         C  s   |  j  | ƒ } t ƒ  } | j d | ƒ t j | j ƒ j ƒ  j ƒ  } | j ƒ  j ƒ  j ƒ  } |  j	 | | d | j ƒ  ƒ d  S(   Nt   files=   dump might need to be refreshed; here is the actual dump:
%s
(
   R+   R   t   dumpt   textwrapt   dedentt   __doc__t   stript
   splitlinest   getvalueR   (   R    R*   t   func_irt   outt   expectedt   got(    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyt   check_ir_dump£   s    	c         C  s   |  j  t ƒ d  S(   N(   R8   R
   (   R    (    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyt   test_var_swapping­   s    c         C  s   |  j  t ƒ d  S(   N(   R8   t   var_propagate1(   R    (    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyt   test_var_propagate1±   s    (   R&   R'   R0   R+   R8   R9   R;   (    (    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyR(   ˜   s
   		
	t   __main__(   i   i   (   t
   __future__R    R.   t   numba.unittest_supportt   unittest_supportt   unittestt   numbaR   R   t   numba.utilsR   R   R
   R   R   R:   t   TestCaseR   R(   R&   t   main(    (    (    s2   lib/python2.7/site-packages/numba/tests/test_ir.pyt   <module>   s   	&	!	# 