ó
C]c           @   s¶  d  d l  m Z m Z m Z m Z m Z m Z d  d l Z d d l m	 Z	 d d l
 m Z m Z d e j f d „  ƒ  YZ d e j f d	 „  ƒ  YZ d
 e j f d „  ƒ  YZ d e	 j f d „  ƒ  YZ d e	 j f d „  ƒ  YZ d e	 j f d „  ƒ  YZ d e	 j f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ e	 j e e ƒ g e	 j j _ e	 j g e	 j j  _ e	 j! e	 j j  _" e	 j g e	 j j# _ e e	 j j# _" e	 j e g e	 j j$ _ e	 j g e	 j j% _ e	 j& e	 j j% _" e	 j& g e	 j j' _ e e	 j j' _" e	 j& g e	 j j( _ e e	 j j( _" e	 j& g e	 j j) _ e	 j& e	 j j) _" e	 j& g e	 j j* _ e e	 j j* _" e	 j g e	 j j+ _ e e	 j j+ _" e	 j e g e	 j j, _ e	 j g e	 j j- _ e e	 j j- _" e	 j e g e	 j j. _ e	 j g e	 j j/ _ e e	 j j/ _" e	 j e g e	 j j0 _ e e g e	 j j1 _ e e	 j j1 _" e	 j e g e	 j j2 _ e	 j g e	 j j3 _ e e	 j j3 _" e	 j g e	 j j4 _ e	 j5 e	 j j4 _" e	 j g e	 j j6 _ e	 j5 e	 j j6 _" e	 j g e	 j j7 _ e	 j5 e	 j j7 _" e	 j g e	 j j8 _ e	 j9 e	 j j8 _" e	 j g e	 j j: _ e	 j9 e	 j j: _" e	 j g e	 j j; _ e	 j< e	 j j; _" e	 j g e	 j j= _ e	 j> e	 j j= _" e	 j g e	 j j? _ e	 j@ e	 j j? _" e	 j g e	 j jA _ e	 jB e	 j jA _" e	 j5 g e	 j jC _ e	 j9 g e	 j jD _ e	 j< g e	 j jE _ e	 j@ g e	 j jF _ e	 jB g e	 j jG _ e	 j5 g e	 j jH _ e e	 j jH _" e	 j9 g e	 j jI _ e e	 j jI _" e	 j< g e	 j jJ _ e	 j e	 j jJ _" e	 j> g e	 j jK _ e	 j e	 j jK _" e	 j@ g e	 j jL _ e	 j e	 j jL _" e	 jB g e	 j jM _ e	 j e	 j jM _" e	 j g e	 j jN _ e e	 j jN _" d S(    iÿÿÿÿ(   t   POINTERt   c_char_pt   c_intt   c_size_tt   c_uintt   c_boolNi   (   t   ffi(   t   _decode_stringt   _encode_stringt   Linkagec           B   sn   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 RS(   i    i   i   i   i   i   i   i   i   i	   i
   i   i   i   i   i   i   (   t   __name__t
   __module__t   externalt   available_externallyt   linkonce_anyt   linkonce_odrt   linkonce_odr_autohidet   weak_anyt   weak_odrt	   appendingt   internalt   privatet	   dllimportt	   dllexportt   external_weakt   ghostt   commont   linker_privatet   linker_private_weak(    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR	      s"   t
   Visibilityc           B   s   e  Z d  Z d Z d Z RS(   i    i   i   (   R
   R   t   defaultt   hiddent	   protected(    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR      s   t   StorageClassc           B   s   e  Z d  Z d Z d Z RS(   i    i   i   (   R
   R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR!   &   s   t   TypeRefc           B   sD   e  Z d  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z RS(   s$   A weak reference to a LLVM type
    c         C   s   t  t j j |  ƒ ƒ S(   s   
        Get type name
        (   R   R   t   libt   LLVMPY_GetTypeName(   t   self(    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   name1   s    c         C   s   t  j j |  ƒ S(   s=   
        Returns true is the type is a pointer type.
        (   R   R#   t   LLVMPY_TypeIsPointer(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt
   is_pointer8   s    c         C   s7   |  j  s! t d j |  ƒ ƒ ‚ n  t t j j |  ƒ ƒ S(   sh   
        Returns the pointed-to type. When the type is not a pointer,
        raises exception.
        s   Type {} is not a pointer(   R(   t
   ValueErrort   formatR"   R   R#   t   LLVMPY_GetElementType(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   element_type?   s    	c         C   s   t  t j j |  ƒ ƒ S(   N(   R   R   R#   t   LLVMPY_PrintType(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   __str__I   s    (   R
   R   t   __doc__t   propertyR&   R(   R,   R.   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR"   .   s
   
t   ValueRefc           B   s»  e  Z d  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d	 „  ƒ Z e d
 „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z RS(   s&   A weak reference to a LLVM value.
    c         C   s)   | |  _  | |  _ t j j |  | ƒ d  S(   N(   t   _kindt   _parentsR   t	   ObjectReft   __init__(   R%   t   ptrt   kindt   parents(    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR5   Q   s    		c         C   s6   t  j ƒ  $ } t  j j |  | ƒ t | ƒ SWd  QXd  S(   N(   R   t   OutputStringR#   t   LLVMPY_PrintValueToStringt   str(   R%   t   outstr(    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR.   V   s    c         C   s   |  j  j d ƒ S(   sV   
        The module this function or global variable value was obtained from.
        t   module(   R3   t   get(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR=   [   s    c         C   s   |  j  j d ƒ S(   sT   
        The function this argument or basic block value was obtained from.
        t   function(   R3   R>   (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR?   b   s    c         C   s   |  j  j d ƒ S(   sE   
        The block this instruction value was obtained from.
        t   block(   R3   R>   (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR@   i   s    c         C   s   |  j  j d ƒ S(   sG   
        The instruction this operand value was obtained from.
        t   instruction(   R3   R>   (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRA   p   s    c         C   s   |  j  d k S(   Nt   global(   R2   (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt	   is_globalw   s    c         C   s   |  j  d k S(   NR?   (   R2   (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   is_function{   s    c         C   s   |  j  d k S(   NR@   (   R2   (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   is_block   s    c         C   s   |  j  d k S(   Nt   argument(   R2   (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   is_argumentƒ   s    c         C   s   |  j  d k S(   NRA   (   R2   (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   is_instruction‡   s    c         C   s   |  j  d k S(   Nt   operand(   R2   (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt
   is_operand‹   s    c         C   s   t  t j j |  ƒ ƒ S(   N(   R   R   R#   t   LLVMPY_GetValueName(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR&      s    c         C   s   t  j j |  t | ƒ ƒ d  S(   N(   R   R#   t   LLVMPY_SetValueNameR   (   R%   t   val(    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR&   “   s    c         C   s   t  t j j |  ƒ ƒ S(   N(   R	   R   R#   t   LLVMPY_GetLinkage(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   linkage—   s    c         C   s3   t  | t ƒ s t | } n  t j j |  | ƒ d  S(   N(   t
   isinstanceR	   R   R#   t   LLVMPY_SetLinkage(   R%   t   value(    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRO   ›   s    c         C   s   t  t j j |  ƒ ƒ S(   N(   R   R   R#   t   LLVMPY_GetVisibility(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt
   visibility¡   s    c         C   s3   t  | t ƒ s t | } n  t j j |  | ƒ d  S(   N(   RP   R   R   R#   t   LLVMPY_SetVisibility(   R%   RR   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRT   ¥   s    c         C   s   t  t j j |  ƒ ƒ S(   N(   R!   R   R#   t   LLVMPY_GetDLLStorageClass(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   storage_class«   s    c         C   s3   t  | t ƒ s t | } n  t j j |  | ƒ d  S(   N(   RP   R!   R   R#   t   LLVMPY_SetDLLStorageClass(   R%   RR   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRW   ¯   s    c         C   sŠ   |  j  s" t d |  j f ƒ ‚ n  t | ƒ } t j j t | ƒ t | ƒ ƒ } | d k rs t d j	 | ƒ ƒ ‚ n  t j j
 |  | ƒ d S(   s{   Only works on function value

        Parameters
        -----------
        attr : str
            attribute name
        s   expected function value, got %si    s   no such attribute {!r}N(   RD   R)   R2   R;   R   R#   t"   LLVMPY_GetEnumAttributeKindForNameR   t   lenR*   t   LLVMPY_AddFunctionAttr(   R%   t   attrt   attrnamet   attrval(    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   add_function_attributeµ   s    		c         C   s   t  t j j |  ƒ ƒ S(   s)   
        This value's LLVM type.
        (   R"   R   R#   t   LLVMPY_TypeOf(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   typeÆ   s    c         C   s;   |  j  p |  j s+ t d |  j f ƒ ‚ n  t j j |  ƒ S(   sb   
        Whether this value (presumably global) is defined in the current
        module.
        s)   expected global or function value, got %s(   RC   RD   R)   R2   R   R#   t   LLVMPY_IsDeclaration(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   is_declarationÎ   s    c         C   sú   t  d ƒ } |  j r6 t j j |  ƒ } t | ƒ } nÀ |  j r¢ |  j d k ro t j j |  ƒ } t | ƒ } qö |  j d k rö t j j	 |  ƒ } t | ƒ } qö nT |  j
 rÌ t j j |  ƒ } t | ƒ } n* |  j rö t j j |  ƒ } t | ƒ } n  | S(   s   
        Return an iterator over this value's attributes.
        The iterator will yield a string for each attribute.
        t   callt   invoke(    (   t   iterRD   R   R#   t   LLVMPY_FunctionAttributesItert   _AttributeListIteratorRH   t   opcodet   LLVMPY_CallInstAttributesItert   LLVMPY_InvokeInstAttributesIterRC   t   LLVMPY_GlobalAttributesItert   _AttributeSetIteratorRG   t   LLVMPY_ArgumentAttributesIter(   R%   t   itrt   it(    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt
   attributesÙ   s$    				c         C   s`   |  j  s" t d |  j f ƒ ‚ n  t j j |  ƒ } |  j j ƒ  } | j d |  ƒ t	 | | ƒ S(   s|   
        Return an iterator over this function's blocks.
        The iterator will yield a ValueRef for each block.
        s   expected function value, got %sR?   (
   RD   R)   R2   R   R#   t   LLVMPY_FunctionBlocksIterR3   t   copyt   updatet   _BlocksIterator(   R%   Rp   R8   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   blocksò   s    	c         C   s`   |  j  s" t d |  j f ƒ ‚ n  t j j |  ƒ } |  j j ƒ  } | j d |  ƒ t	 | | ƒ S(   s‚   
        Return an iterator over this function's arguments.
        The iterator will yield a ValueRef for each argument.
        s   expected function value, got %sR?   (
   RD   R)   R2   R   R#   t   LLVMPY_FunctionArgumentsIterR3   Rs   Rt   t   _ArgumentsIterator(   R%   Rp   R8   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt	   argumentsÿ   s    	c         C   s`   |  j  s" t d |  j f ƒ ‚ n  t j j |  ƒ } |  j j ƒ  } | j d |  ƒ t	 | | ƒ S(   s…   
        Return an iterator over this block's instructions.
        The iterator will yield a ValueRef for each instruction.
        s   expected block value, got %sR@   (
   RE   R)   R2   R   R#   t   LLVMPY_BlockInstructionsIterR3   Rs   Rt   t   _InstructionsIterator(   R%   Rp   R8   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   instructions  s    	c         C   s`   |  j  s" t d |  j f ƒ ‚ n  t j j |  ƒ } |  j j ƒ  } | j d |  ƒ t	 | | ƒ S(   sƒ   
        Return an iterator over this instruction's operands.
        The iterator will yield a ValueRef for each operand.
        s"   expected instruction value, got %sRA   (
   RH   R)   R2   R   R#   t   LLVMPY_InstructionOperandsIterR3   Rs   Rt   t   _OperandsIterator(   R%   Rp   R8   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   operands  s    	c         C   s8   |  j  s" t d |  j f ƒ ‚ n  t t j j |  ƒ ƒ S(   Ns"   expected instruction value, got %s(   RH   R)   R2   R   R   R#   t   LLVMPY_GetOpcodeName(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRi   '  s    	(   R
   R   R/   R5   R.   R0   R=   R?   R@   RA   RC   RD   RE   RG   RH   RJ   R&   t   setterRO   RT   RW   R_   Ra   Rc   Rq   Rv   Ry   R|   R   Ri   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR1   M   s<   			t   _ValueIteratorc           B   s/   e  Z d Z d  „  Z d „  Z e Z d „  Z RS(   c         C   sN   t  j j |  | ƒ | |  _ |  j d  k rJ t d t |  ƒ j f ƒ ‚ n  d  S(   Ns   %s must specify kind attribute(	   R   R4   R5   R3   R7   t   Nonet   NotImplementedErrorRa   R
   (   R%   R6   R8   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR5   4  s
    	c         C   s2   |  j  ƒ  } | r( t | |  j |  j ƒ St ‚ d  S(   N(   t   _nextR1   R7   R3   t   StopIteration(   R%   t   vp(    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   __next__<  s    c         C   s   |  S(   N(    (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   __iter__E  s    N(   R
   R   Rƒ   R7   R5   Rˆ   t   nextR‰   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR‚   /  s
   		t   _AttributeIteratorc           B   s    e  Z d  „  Z e Z d „  Z RS(   c         C   s    |  j  ƒ  } | r | St ‚ d  S(   N(   R…   R†   (   R%   R‡   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRˆ   K  s    c         C   s   |  S(   N(    (   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR‰   T  s    (   R
   R   Rˆ   RŠ   R‰   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR‹   I  s   	Rh   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   |  j  j |  ƒ d  S(   N(   t   _capit   LLVMPY_DisposeAttributeListIter(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   _disposeZ  s    c         C   s   t  j j |  ƒ S(   N(   R   R#   t   LLVMPY_AttributeListIterNext(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR…   ]  s    (   R
   R   RŽ   R…   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRh   X  s   	Rm   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   |  j  j |  ƒ d  S(   N(   RŒ   t   LLVMPY_DisposeAttributeSetIter(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRŽ   c  s    c         C   s   t  j j |  ƒ S(   N(   R   R#   t   LLVMPY_AttributeSetIterNext(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR…   f  s    (   R
   R   RŽ   R…   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRm   a  s   	Ru   c           B   s    e  Z d  Z d „  Z d „  Z RS(   R@   c         C   s   |  j  j |  ƒ d  S(   N(   RŒ   t   LLVMPY_DisposeBlocksIter(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRŽ   n  s    c         C   s   t  j j |  ƒ S(   N(   R   R#   t   LLVMPY_BlocksIterNext(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR…   q  s    (   R
   R   R7   RŽ   R…   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRu   j  s   	Rx   c           B   s    e  Z d  Z d „  Z d „  Z RS(   RF   c         C   s   |  j  j |  ƒ d  S(   N(   RŒ   t   LLVMPY_DisposeArgumentsIter(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRŽ   y  s    c         C   s   t  j j |  ƒ S(   N(   R   R#   t   LLVMPY_ArgumentsIterNext(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR…   |  s    (   R
   R   R7   RŽ   R…   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRx   u  s   	R{   c           B   s    e  Z d  Z d „  Z d „  Z RS(   RA   c         C   s   |  j  j |  ƒ d  S(   N(   RŒ   t   LLVMPY_DisposeInstructionsIter(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRŽ   „  s    c         C   s   t  j j |  ƒ S(   N(   R   R#   t   LLVMPY_InstructionsIterNext(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR…   ‡  s    (   R
   R   R7   RŽ   R…   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR{   €  s   	R~   c           B   s    e  Z d  Z d „  Z d „  Z RS(   RI   c         C   s   |  j  j |  ƒ d  S(   N(   RŒ   t   LLVMPY_DisposeOperandsIter(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyRŽ     s    c         C   s   t  j j |  ƒ S(   N(   R   R#   t   LLVMPY_OperandsIterNext(   R%   (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR…   ’  s    (   R
   R   R7   RŽ   R…   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyR~   ‹  s   	(O   t   ctypesR    R   R   R   R   R   t   enumt    R   R   R   R   t   IntEnumR	   R   R!   R4   R"   R1   R‚   R‹   Rh   Rm   Ru   Rx   R{   R~   t   LLVMValueRefR#   R:   t   argtypest   LLVMPY_GetGlobalParentt   LLVMModuleReft   restypeRK   RL   R`   t   LLVMTypeRefR-   R'   R+   R$   RN   RQ   RS   RU   RV   RX   RY   R[   Rb   Rg   t   LLVMAttributeListIteratorRj   Rk   Rl   t   LLVMAttributeSetIteratorRn   Rr   t   LLVMBlocksIteratorRw   t   LLVMArgumentsIteratorRz   t   LLVMInstructionsIteratorR}   t   LLVMOperandsIteratorR   R   R’   R–   R˜   R   R‘   R“   R•   R—   R™   R€   (    (    (    s5   lib/python2.7/site-packages/llvmlite/binding/value.pyt   <module>   s¨   .â		