ó
\K]c           @@  s¹   d  Z  d d l m Z d d l Z d d l Z d d l m Z d d l m	 Z	 e	 e j
 ƒ d e f d „  ƒ  Yƒ Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s-   
Implements helpers to build LLVM debuginfo.
i    (   t   absolute_importN(   t   iri   (   t   add_metaclasst   AbstractDIBuilderc           B@  sP   e  Z e j d  „  ƒ Z e j d „  ƒ Z e j d „  ƒ Z e j d „  ƒ Z RS(   c         C@  s   d S(   s*   Emit debug info for the variable.
        N(    (   t   selft   buildert   allocavaluet   namet   lltypet   sizet   loc(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt   mark_variable   s    c         C@  s   d S(   sA   Emit source location information to the given IRBuilder.
        N(    (   R   R   R
   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt   mark_location   s    c         C@  s   d S(   sA   Emit source location information for the given function.
        N(    (   R   t   functionR   R
   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt   mark_subprogram   s    c         C@  s   d S(   sC   Finalize the debuginfo by emitting all necessary metadata.
        N(    (   R   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt   finalize#   s    (   t   __name__t
   __module__t   abct   abstractmethodR   R   R   R   (    (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR      s   t   DummyDIBuilderc           B@  s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C@  s   d  S(   N(    (   R   t   modulet   filepath(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt   __init__,   s    c         C@  s   d  S(   N(    (   R   R   R   R   R   R	   R
   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   /   s    c         C@  s   d  S(   N(    (   R   R   R
   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   2   s    c         C@  s   d  S(   N(    (   R   R   R   R
   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   5   s    c         C@  s   d  S(   N(    (   R   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   8   s    (   R   R   R   R   R   R   R   (    (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   *   s
   				t	   DIBuilderc           B@  s¹   e  Z d  Z d Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z e d d „ ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   i   i   s   llvm.dbg.cuc         C@  sI   | |  _  t j j | ƒ |  _ |  j ƒ  |  _ g  |  _ |  j ƒ  |  _	 d  S(   N(
   R   t   ost   patht   abspathR   t   _di_filet   difilet   subprogramst   _di_compile_unitt   dicompileunit(   R   R   R   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   A   s
    		c         C@  sK  |  j  } | d } t j f } t j t j f } t | | | ƒ r› | j d i t | ƒ d 6| d 6t | | ƒ r‚ t j d ƒ n t j d ƒ d 6ƒ } n¬ | } | j d i | d	 6ƒ }	 | j d i d
 d 6d d 6t j d ƒ d 6ƒ }
 | j d i t j d ƒ d 6|
 d 6t | ƒ d 6| d 6t | ƒ d 6| j	 |	 g ƒ d 6ƒ } | S(   Ni   t   DIBasicTypeR   R	   t   DW_ATE_unsignedt   DW_ATE_floatt   encodingt
   DISubranget   countt   bytet   DW_ATE_unsigned_chart   DICompositeTypet   DW_TAG_array_typet   tagt   baseTypet
   identifiert   elements(
   R   R   t   IntTypet	   FloatTypet
   DoubleTypet
   isinstancet   add_debug_infot   strt   DITokent   add_metadata(   R   R   R	   t   mt   bitsizet   int_typet	   real_typet   mdtypeR&   t   mdranget   mdbase(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt	   _var_typeH   s2    	
c         C@  sÛ   |  j  } t j t j ƒ  t j ƒ  g d ƒ } | j | d d ƒ}	 |  j | | ƒ }
 | j d d ƒ } | j d i | d 6d d 6|  j	 d	 d
 6|  j
 d 6| j d 6|
 d 6ƒ } | j d i  ƒ } | j |	 | | | g ƒ S(   Ni   R   s   llvm.dbg.declaret   .t   $t   DILocalVariablei    t   argiÿÿÿÿt   scopet   filet   linet   typet   DIExpression(   R   R   t   FunctionTypet   VoidTypet   MetaDataTypet   get_or_insert_functionR>   t   replaceR3   R   R   RE   t   call(   R   R   R   R   R   R	   R
   R7   t   fntyt   declR;   t
   mdlocalvart   mdexpr(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   m   s    	%

c         C@  s   |  j  | j ƒ | _ d  S(   N(   t   _add_locationRE   t   debug_metadata(   R   R   R
   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   €   s    c         C@  sH   |  j  d | d | j d | j ƒ } | j d | ƒ | j j d ƒ d  S(   NR   t   linkagenameRE   t   dbgt   noinline(   t   _add_subprogramR   RE   t   set_metadatat
   attributest   add(   R   R   R   R
   t   di_subp(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   ƒ   s    c         C@  s3   |  j  j |  j ƒ } | j |  j ƒ |  j ƒ  d  S(   N(   R   t   get_or_insert_named_metadatat   DBG_CU_NAMERZ   R    t   _set_module_flags(   R   t   dbgcu(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   Š   s    c         C@  sÃ   |  j  } | j d ƒ } |  j d ƒ } |  j d k	 r| | j | d |  j |  j ƒ g ƒ } | | j k r| | j | ƒ q| n  | j | d |  j |  j ƒ g ƒ } | | j k r¿ | j | ƒ n  d S(   s&   Set the module flags metadata
        s   llvm.module.flagsi   s   Dwarf Versions   Debug Info VersionN(	   R   R\   t
   _const_intt   DWARF_VERSIONt   NoneR6   t   operandsRZ   t   DEBUG_INFO_VERSION(   R   R   t   mflagst   require_warning_behaviort   dwarf_versiont   debuginfo_version(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR^   “   s     	c         C@  s)   |  j  | | | ƒ } |  j j | ƒ | S(   s    Emit subprogram metdata
        (   t   _di_subprogramR   t   append(   R   R   RT   RE   t   subp(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyRW   «   s    c         C@  s   |  j  | ƒ } | S(   s   Emit location metatdaa
        (   t   _di_location(   R   RE   R
   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyRR   ²   s    i    c         C@  s   t  j | ƒ | ƒ S(   s0   Util to create constant int in metadata
        (   R   R/   (   t   clst   numt   bits(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR`   ¸   s    c         C@  s   t  j d ƒ | ƒ S(   s4   Util to create constant boolean in metadata
        i   (   R   R/   (   Rm   t   boolean(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt   _const_bool¾   s    c         C@  s?   |  j  j d i t j j |  j ƒ d 6t j j |  j ƒ d 6ƒ S(   Nt   DIFilet	   directoryt   filename(   R   R3   R   R   t   dirnameR   t   basename(   R   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   È   s    c         C@  sO   |  j  j d i t j d ƒ d 6|  j d 6d d 6d d 6t d	 6d
 d 6d t ƒS(   Nt   DICompileUnitt   DW_LANG_Pythont   languageRD   t   Numbat   produceri    t   runtimeVersiont   isOptimizedi   t   emissionKindt   is_distinct(   R   R3   R   R5   R   t   True(   R   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   Î   s    

c         C@  s&   |  j  j d i |  j  j g  ƒ d 6ƒ S(   Nt   DISubroutineTypet   types(   R   R3   R6   (   R   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt   _di_subroutine_typeØ   s    c         C@  su   |  j  j d i | d 6| d 6|  j d 6|  j d 6| d 6|  j ƒ  d 6t d 6t d	 6| d
 6t d 6|  j d 6d t ƒS(   Nt   DISubprogramR   t   linkageNameRC   RD   RE   RF   t   isLocalt   isDefinitiont	   scopeLineR}   t   unitR   (   R   R3   R   Rƒ   t   FalseR€   R    (   R   R   RT   RE   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyRi   Ý   s    

c         C@  s/   |  j  j d i | d 6d d 6|  j d d 6ƒ S(   Nt
   DILocationRE   i   t   columniÿÿÿÿRC   (   R   R3   R   (   R   RE   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyRl   ì   s    (   R   R   Ra   Rd   R]   R   R>   R   R   R   R   R^   RW   RR   t   classmethodR`   Rq   R   R   Rƒ   Ri   Rl   (    (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   <   s(   		%								
		
		t   NvvmDIBuilderc           B@  s•   e  Z d  Z d Z d Z d Z d Z d Z d Z	 d Z
 d Z d Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s†   
    Only implemented the minimal metadata to get line number information.
    See http://llvm.org/releases/3.4/docs/LangRef.html
    i   i  i  i.  i)  i   s   numba.llvm.dbg.cuc         C@  s   d  S(   N(    (   R   R   R   R   R   R	   R
   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   
  s    c         C@  s™   |  j  | j k r d  S| j |  _  t j t j ƒ  g  ƒ } t j | d j | j ƒ d d t ƒ} | j | g  ƒ } |  j	 | j ƒ } | j
 d | ƒ d  S(   Ns	   // dbg {}t    t   side_effects	   numba.dbg(   t   _last_linenoRE   R   RH   RI   t	   InlineAsmt   formatR€   RM   Rl   RX   (   R   R   R
   t   asmtyt   asmRM   t   md(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR     s    	c         C@  s&   |  j  d | d | j d | j ƒ d  S(   NR   RT   RE   (   RW   R   RE   (   R   R   R   R
   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR     s    c         C@  s4   |  j  j t j j |  j ƒ t j j |  j ƒ g ƒ S(   N(   R   R6   R   R   Rv   R   Ru   (   R   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt	   _filepair#  s    	c         C@  s(   |  j  j |  j |  j ƒ |  j ƒ  g ƒ S(   N(   R   R6   R`   t   DI_FileR—   (   R   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   )  s    	c         C@  sš   |  j  ƒ  } |  j j |  j d ƒ g ƒ } |  j j |  j |  j ƒ | |  j |  j ƒ d |  j t ƒ d |  j d ƒ | | |  j j |  j ƒ | | d g ƒ S(   Ni    Rz   R   (	   R—   R   R6   R`   t   DI_Compile_unitRx   Rq   R€   R   (   R   t   filepairt   empty(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyR   /  s     	c         C@  s¦   |  j  j d  g ƒ } |  j  j |  j |  j ƒ |  j d ƒ d  d |  j d ƒ |  j d d ƒ |  j d d ƒ |  j d d ƒ |  j d ƒ d  | |  j d ƒ d  d  d  g ƒ S(   Ni    R   i@   (   R   R6   Rb   R`   t   DI_Subroutine_type(   R   R‚   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyRƒ   B  s"    	c         C@  sî   |  j  j | ƒ } |  j ƒ  } |  j  j |  j d ƒ g ƒ } |  j ƒ  } |  j  j |  j |  j ƒ |  j ƒ  | | | | |  j | ƒ | |  j t	 ƒ |  j t
 ƒ |  j d ƒ |  j d ƒ d  |  j d ƒ |  j t
 ƒ | d  d  | |  j | ƒ g ƒ S(   Ni    (   R   t
   get_globalRƒ   R6   R`   R   t   DI_SubprogramR—   Rq   RŠ   R€   Rb   (   R   R   RT   RE   t   function_ptrt   subroutine_typet   funcvarst   context(    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyRi   V  s2    		c         C@  s5   |  j  j |  j | ƒ |  j d ƒ |  j d d  g ƒ S(   Ni    iÿÿÿÿ(   R   R6   R`   R   Rb   (   R   RE   (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyRl   r  s
    	
N(   R   R   t   __doc__Rx   R™   Rœ   Rž   R˜   Rb   Ra   Rd   R]   R‘   R   R   R   R—   R   R   Rƒ   Ri   Rl   (    (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyRŽ   ô   s&   								(   R£   t
   __future__R    R   t   os.pathR   t   llvmliteR   t   sixR   t   ABCMetat   objectR   R   R   RŽ   (    (    (    s.   lib/python2.7/site-packages/numba/debuginfo.pyt   <module>   s   ¸